oai

package
v0.0.0-...-8699900 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatCompletion

type ChatCompletion struct {
	Object string `json:"object"` // "chat.completion" | "chat.completion.chunk"

	ID string `json:"id"`

	Model   string `json:"model"`
	Created int64  `json:"created"`

	Choices []ChatCompletionChoice `json:"choices"`
}

https://platform.openai.com/docs/api-reference/chat/object

type ChatCompletionChoice

type ChatCompletionChoice struct {
	Index int `json:"index"`

	Delta   *ChatCompletionMessage `json:"delta,omitempty"`
	Message *ChatCompletionMessage `json:"message,omitempty"`

	FinishReason *FinishReason `json:"finish_reason"`
}

https://platform.openai.com/docs/api-reference/chat/object

type ChatCompletionMessage

type ChatCompletionMessage struct {
	Role MessageRole `json:"role,omitempty"`

	Content  string           `json:"content"`
	Contents []MessageContent `json:"-"`

	ToolCalls  []ToolCall `json:"tool_calls,omitempty"`
	ToolCallID string     `json:"tool_call_id,omitempty"`
}

https://platform.openai.com/docs/api-reference/chat/object

func (*ChatCompletionMessage) MarshalJSON

func (m *ChatCompletionMessage) MarshalJSON() ([]byte, error)

func (*ChatCompletionMessage) UnmarshalJSON

func (m *ChatCompletionMessage) UnmarshalJSON(data []byte) error

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model string `json:"model"`

	Messages []ChatCompletionMessage `json:"messages"`

	Stream bool   `json:"stream,omitempty"`
	Stop   any    `json:"stop,omitempty"`
	Tools  []Tool `json:"tools,omitempty"`

	MaxTokens   *int     `json:"max_tokens,omitempty"`
	Temperature *float32 `json:"temperature,omitempty"`

	ResponseFormat *ChatCompletionResponseFormat `json:"response_format,omitempty"`
}

https://platform.openai.com/docs/api-reference/chat/create

type ChatCompletionResponseFormat

type ChatCompletionResponseFormat struct {
	Type ResponseFormat `json:"type"`
}

https://platform.openai.com/docs/api-reference/chat/create

type Embedding

type Embedding struct {
	Object string `json:"object"` // "embedding"

	Index     int       `json:"index"`
	Embedding []float32 `json:"embedding"`
}

https://platform.openai.com/docs/api-reference/embeddings/object

type EmbeddingList

type EmbeddingList struct {
	Object string `json:"object"` // "list"

	Model string      `json:"model"`
	Data  []Embedding `json:"data"`
}

https://platform.openai.com/docs/api-reference/embeddings/create

type EmbeddingsRequest

type EmbeddingsRequest struct {
	Input any    `json:"input"`
	Model string `json:"model"`
}

https://platform.openai.com/docs/api-reference/embeddings/create

type Error

type Error struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

type ErrorResponse

type ErrorResponse struct {
	Error Error `json:"error,omitempty"`
}

type FinishReason

type FinishReason string

// https://platform.openai.com/docs/api-reference/chat/object

var (
	FinishReasonStop   FinishReason = "stop"
	FinishReasonLength FinishReason = "length"

	FinishReasonToolCalls     FinishReason = "tool_calls"
	FinishReasonContentFilter FinishReason = "content_filter"
)

type Function

type Function struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`

	Parameters any `json:"parameters"`
}

type FunctionCall

type FunctionCall struct {
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

https://platform.openai.com/docs/api-reference/chat/object

type MessageContent

type MessageContent struct {
	Type string `json:"type,omitempty"`
	Text string `json:"text,omitempty"`

	ImageURL *MessageContentURL `json:"image_url,omitempty"`
}

type MessageContentURL

type MessageContentURL struct {
	URL string `json:"url"`
}

type MessageRole

type MessageRole string
var (
	MessageRoleSystem    MessageRole = "system"
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
	MessageRoleTool      MessageRole = "tool"
)

type Model

type Model struct {
	Object string `json:"object"` // "model"

	ID      string `json:"id"`
	Created int64  `json:"created"`
	OwnedBy string `json:"owned_by"`
}

https://platform.openai.com/docs/api-reference/models/object

type ModelList

type ModelList struct {
	Object string `json:"object"` // "list"

	Models []Model `json:"data"`
}

https://platform.openai.com/docs/api-reference/models

type ResponseFormat

type ResponseFormat string
var (
	ResponseFormatText ResponseFormat = "text"
	ResponseFormatJSON ResponseFormat = "json_object"
)

type Server

type Server struct {
	*config.Config
	http.Handler
}

func New

func New(cfg *config.Config) (*Server, error)

type SpeechRequest

type SpeechRequest struct {
	Model string `json:"model"`

	Input string `json:"input"`
	Voice string `json:"voice"`
}

https://platform.openai.com/docs/api-reference/audio/createSpeech

type Tool

type Tool struct {
	Type ToolType `json:"type"`

	ToolFunction *Function `json:"function"`
}

type ToolCall

type ToolCall struct {
	ID string `json:"id"`

	Type ToolType `json:"type"`

	Function *FunctionCall `json:"function,omitempty"`
}

https://platform.openai.com/docs/api-reference/chat/object

type ToolType

type ToolType string

https://platform.openai.com/docs/api-reference/chat/object

var (
	ToolTypeFunction ToolType = "function"
)

type Transcription

type Transcription struct {
	Task string `json:"task"`

	Language string  `json:"language"`
	Duration float64 `json:"duration"`

	Text string `json:"text"`
}

Jump to

Keyboard shortcuts

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