openai_provider

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAskRequest

type BasicAskRequest struct {
	Model       string    `json:"model"`
	Messages    []Message `json:"messages"`
	Temperature float64   `json:"temperature"`
}

type BasicAskResponse

type BasicAskResponse struct {
	ID                string        `json:"id"`
	Object            string        `json:"object"` // will be set to "chat.completion"
	Created           int64         `json:"created"`
	Model             string        `json:"model"`
	Choices           []Choice      `json:"choices"`
	Usage             BasicAskUsage `json:"usage"`
	SystemFingerprint any           `json:"system_fingerprint"`
}

func (BasicAskResponse) GetChoices

func (o BasicAskResponse) GetChoices() []domain.Choice

func (BasicAskResponse) GetCreated

func (o BasicAskResponse) GetCreated() int64

func (BasicAskResponse) GetID

func (o BasicAskResponse) GetID() string

func (BasicAskResponse) GetModel

func (o BasicAskResponse) GetModel() string

func (BasicAskResponse) GetObjectType

func (o BasicAskResponse) GetObjectType() string

func (BasicAskResponse) GetSystemFingerprint

func (o BasicAskResponse) GetSystemFingerprint() any

func (BasicAskResponse) GetUsage

func (o BasicAskResponse) GetUsage() domain.Usage

type BasicAskUsage

type BasicAskUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

type Choice

type Choice struct {
	Index        int     `json:"index"`
	Message      Message `json:"message"`
	LogProbs     any     `json:"logprobs"`
	FinishReason string  `json:"finish_reason"`
}

type Config

type Config struct {
	APIKey       string  `yaml:"api_key"`
	Organization string  `yaml:"organization"`
	Project      string  `yaml:"project"`
	Temperature  float64 `yaml:"temperature"`
	Model        string  `yaml:"model"`
}

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewOpenAIProvider

func NewOpenAIProvider(cfg Config, verbose bool) *Provider

func (Provider) BasicAsk

func (o Provider) BasicAsk(question domain.Question) (domain.Response, error)

func (Provider) BasicAskStream

func (o Provider) BasicAskStream(question domain.Question) <-chan domain.RespChunk

func (Provider) ListModels

func (o Provider) ListModels() ([]string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL