openai

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatURL  = "https://api.openai.com/v1/chat/completions"
	PhotoURL = "https://api.openai.com/v1/images/generations"
)

Variables

View Source
var GPT_DEFAULT = ChatGPT{
	Model:       "gpt-4-turbo",
	Temperature: 1.0,
	TopP:        1.0,
	Url:         ChatURL,
}

Functions

func NewPhotoQuerier

func NewPhotoQuerier(pConf photo.Configurations) (models.Querier, error)

Types

type ChatCompletion

type ChatCompletion struct {
	ID                string   `json:"id"`
	Object            string   `json:"object"`
	Created           int64    `json:"created"`
	Model             string   `json:"model"`
	Choices           []Choice `json:"choices"`
	Usage             Usage    `json:"usage"`
	SystemFingerprint string   `json:"system_fingerprint"`
}

type ChatGPT

type ChatGPT struct {
	generic.StreamCompleter
	Model            string  `json:"model"`
	FrequencyPenalty float64 `json:"frequency_penalty"`
	MaxTokens        *int    `json:"max_tokens"` // Use a pointer to allow null value
	PresencePenalty  float64 `json:"presence_penalty"`
	Temperature      float64 `json:"temperature"`
	TopP             float64 `json:"top_p"`
	Url              string  `json:"url"`
}

func (*ChatGPT) RegisterTool added in v1.2.8

func (g *ChatGPT) RegisterTool(tool tools.AiTool)

func (*ChatGPT) Setup added in v1.2.1

func (g *ChatGPT) Setup() error

type Choice

type Choice struct {
	Index        int         `json:"index"`
	Delta        Delta       `json:"delta"`
	Logprobs     interface{} `json:"logprobs"` // null or complex object, hence interface{}
	FinishReason string      `json:"finish_reason"`
}

type DallE

type DallE struct {
	Model   string       `json:"model"`
	N       int          `json:"n"`
	Size    string       `json:"size"`
	Quality string       `json:"quality"`
	Style   string       `json:"style"`
	Output  photo.Output `json:"output"`
	// Don't save this as this is set via the Output struct
	ResponseFormat string `json:"-"`
	Prompt         string `json:"-"`
	// contains filtered or unexported fields
}

func (*DallE) Query

func (q *DallE) Query(ctx context.Context) error

type DallERequest

type DallERequest struct {
	Model          string `json:"model"`
	N              int    `json:"n"`
	Size           string `json:"size"`
	Quality        string `json:"quality"`
	Style          string `json:"style"`
	ResponseFormat string `json:"response_format"`
	Prompt         string `json:"prompt"`
}

type Delta added in v1.2.8

type Delta struct {
	Content   any         `json:"content"`
	Role      string      `json:"role"`
	ToolCalls []ToolsCall `json:"tool_calls"`
}

type GptFunc added in v1.2.8

type GptFunc struct {
	Arguments string `json:"arguments"`
	Name      string `json:"name"`
}

type GptTool added in v1.2.8

type GptTool struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Inputs      tools.InputSchema `json:"parameters"`
}

type GptToolSuper added in v1.2.8

type GptToolSuper struct {
	Type     string  `json:"type"`
	Function GptTool `json:"function"`
}

type ImageResponse

type ImageResponse struct {
	RevisedPrompt string `json:"revised_prompt"`
	URL           string `json:"url"`
	B64_JSON      string `json:"b64_json"`
}

type ImageResponses

type ImageResponses struct {
	Created int             `json:"created"`
	Data    []ImageResponse `json:"data"`
}

type ToolsCall added in v1.2.8

type ToolsCall struct {
	Function GptFunc `json:"function"`
	ID       string  `json:"id"`
	Index    int     `json:"index"`
	Type     string  `json:"type"`
}

type Usage

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

Jump to

Keyboard shortcuts

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