model

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeText       = "text"
	ContentTypeImageURL   = "image_url"
	ContentTypeInputAudio = "input_audio"
)
View Source
const (
	StopFinishReason    = "stop"
	ChatCompletionChunk = "chat.completion.chunk"
	ChatCompletion      = "chat.completion"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	Voice  string `json:"voice,omitempty"`
	Format string `json:"format,omitempty"`
}

type ChatCompletionsStreamResponse added in v0.1.5

type ChatCompletionsStreamResponse struct {
	Usage   *Usage                                 `json:"usage,omitempty"`
	ID      string                                 `json:"id"`
	Object  string                                 `json:"object"`
	Model   string                                 `json:"model"`
	Choices []*ChatCompletionsStreamResponseChoice `json:"choices"`
	Created int64                                  `json:"created"`
}

type ChatCompletionsStreamResponseChoice added in v0.1.5

type ChatCompletionsStreamResponseChoice struct {
	FinishReason *string `json:"finish_reason,omitempty"`
	Delta        Message `json:"delta"`
	Index        int     `json:"index"`
	Text         string  `json:"text,omitempty"`
}

type Document

type Document struct {
	Text string `json:"text"`
}

type EmbeddingRequest added in v0.1.5

type EmbeddingRequest struct {
	Input          string `json:"input"`
	Model          string `json:"model"`
	EncodingFormat string `json:"encoding_format"`
	Dimensions     int    `json:"dimensions"`
}

type EmbeddingResponse added in v0.1.5

type EmbeddingResponse struct {
	Object string                   `json:"object"`
	Model  string                   `json:"model"`
	Data   []*EmbeddingResponseItem `json:"data"`
	Usage  `json:"usage"`
}

type EmbeddingResponseItem added in v0.1.5

type EmbeddingResponseItem struct {
	Object    string    `json:"object"`
	Embedding []float64 `json:"embedding"`
	Index     int       `json:"index"`
}

type Error

type Error struct {
	Code    any    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Type    string `json:"type,omitempty"`
	Param   string `json:"param,omitempty"`
}

func (*Error) IsEmpty

func (e *Error) IsEmpty() bool

func (*Error) JSONOrEmpty

func (e *Error) JSONOrEmpty() string

type ErrorWithStatusCode

type ErrorWithStatusCode struct {
	Error      Error `json:"error,omitempty"`
	StatusCode int   `json:"-"`
}

func (*ErrorWithStatusCode) JSONOrEmpty

func (e *ErrorWithStatusCode) JSONOrEmpty() string

type Function

type Function struct {
	Parameters  any    `json:"parameters,omitempty"`
	Arguments   string `json:"arguments"`
	Description string `json:"description,omitempty"`
	Name        string `json:"name,omitempty"`
}

type GeneralOpenAIRequest

type GeneralOpenAIRequest struct {
	Prediction          any             `json:"prediction,omitempty"`
	Prompt              any             `json:"prompt,omitempty"`
	Input               any             `json:"input,omitempty"`
	Metadata            any             `json:"metadata,omitempty"`
	Functions           any             `json:"functions,omitempty"`
	LogitBias           any             `json:"logit_bias,omitempty"`
	FunctionCall        any             `json:"function_call,omitempty"`
	ToolChoice          any             `json:"tool_choice,omitempty"`
	Stop                any             `json:"stop,omitempty"`
	MaxCompletionTokens *int            `json:"max_completion_tokens,omitempty"`
	TopLogprobs         *int            `json:"top_logprobs,omitempty"`
	Style               *string         `json:"style,omitempty"`
	Quality             *string         `json:"quality,omitempty"`
	Audio               *Audio          `json:"audio,omitempty"`
	PresencePenalty     *float64        `json:"presence_penalty,omitempty"`
	ResponseFormat      *ResponseFormat `json:"response_format,omitempty"`
	Store               *bool           `json:"store,omitempty"`
	ServiceTier         *string         `json:"service_tier,omitempty"`
	FrequencyPenalty    *float64        `json:"frequency_penalty,omitempty"`
	Logprobs            *bool           `json:"logprobs,omitempty"`
	StreamOptions       *StreamOptions  `json:"stream_options,omitempty"`
	Temperature         *float64        `json:"temperature,omitempty"`
	TopP                *float64        `json:"top_p,omitempty"`
	ParallelToolCalls   *bool           `json:"parallel_tool_calls,omitempty"`
	EncodingFormat      string          `json:"encoding_format,omitempty"`
	Model               string          `json:"model,omitempty"`
	Instruction         string          `json:"instruction,omitempty"`
	User                string          `json:"user,omitempty"`
	Size                string          `json:"size,omitempty"`
	Modalities          []string        `json:"modalities,omitempty"`
	Messages            []*Message      `json:"messages,omitempty"`
	Tools               []*Tool         `json:"tools,omitempty"`
	N                   int             `json:"n,omitempty"`
	Dimensions          int             `json:"dimensions,omitempty"`
	Seed                float64         `json:"seed,omitempty"`
	MaxTokens           int             `json:"max_tokens,omitempty"`
	TopK                int             `json:"top_k,omitempty"`
	NumCtx              int             `json:"num_ctx,omitempty"`
	Stream              bool            `json:"stream,omitempty"`
}

func (GeneralOpenAIRequest) ParseInput

func (r GeneralOpenAIRequest) ParseInput() []string

type ImageData added in v0.1.5

type ImageData struct {
	URL           string `json:"url,omitempty"`
	B64Json       string `json:"b64_json,omitempty"`
	RevisedPrompt string `json:"revised_prompt,omitempty"`
}

type ImageRequest

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

type ImageResponse added in v0.1.5

type ImageResponse struct {
	Data    []*ImageData `json:"data"`
	Created int64        `json:"created"`
}

type ImageURL

type ImageURL struct {
	URL    string `json:"url,omitempty"`
	Detail string `json:"detail,omitempty"`
}

type JSONSchema

type JSONSchema struct {
	Schema      map[string]interface{} `json:"schema,omitempty"`
	Strict      *bool                  `json:"strict,omitempty"`
	Description string                 `json:"description,omitempty"`
	Name        string                 `json:"name"`
}

type Message

type Message struct {
	Content          any     `json:"content,omitempty"`
	ReasoningContent string  `json:"reasoning_content,omitempty"`
	Name             *string `json:"name,omitempty"`
	Role             string  `json:"role,omitempty"`
	ToolCallID       string  `json:"tool_call_id,omitempty"`
	ToolCalls        []*Tool `json:"tool_calls,omitempty"`
}

func (*Message) IsStringContent

func (m *Message) IsStringContent() bool

func (*Message) ParseContent

func (m *Message) ParseContent() []MessageContent

func (*Message) StringContent

func (m *Message) StringContent() string

func (*Message) ToStringContentMessage

func (m *Message) ToStringContentMessage()

type MessageContent

type MessageContent struct {
	ImageURL *ImageURL `json:"image_url,omitempty"`
	Type     string    `json:"type,omitempty"`
	Text     string    `json:"text,omitempty"`
}

type ParsePdfListResponse

type ParsePdfListResponse struct {
	Markdowns []string `json:"markdowns"`
}

type ParsePdfResponse

type ParsePdfResponse struct {
	Pages    int64  `json:"pages"`
	Markdown string `json:"markdown"`
}

type PromptTokensDetails added in v0.1.4

type PromptTokensDetails struct {
	CachedTokens        int64 `json:"cached_tokens"`
	CacheCreationTokens int64 `json:"cache_creation_tokens,omitempty"`
}

func (*PromptTokensDetails) Add added in v0.1.5

type RerankMeta

type RerankMeta struct {
	Tokens *RerankMetaTokens `json:"tokens,omitempty"`
	Model  string            `json:"model,omitempty"`
}

type RerankMetaTokens

type RerankMetaTokens struct {
	InputTokens  int64 `json:"input_tokens"`
	OutputTokens int64 `json:"output_tokens"`
}

type RerankRequest

type RerankRequest struct {
	TopN            *int     `json:"top_n,omitempty"`
	MaxChunksPerDoc *int     `json:"max_chunks_per_doc,omitempty"`
	ReturnDocuments *bool    `json:"return_documents,omitempty"`
	OverlapTokens   *int     `json:"overlap_tokens,omitempty"`
	Model           string   `json:"model"`
	Query           string   `json:"query"`
	Documents       []string `json:"documents"`
}

type RerankResponse

type RerankResponse struct {
	Meta    RerankMeta      `json:"meta"`
	ID      string          `json:"id"`
	Results []*RerankResult `json:"results"`
}

type RerankResult

type RerankResult struct {
	Document       *Document `json:"document,omitempty"`
	Index          int       `json:"index"`
	RelevanceScore float64   `json:"relevance_score"`
}

type ResponseFormat

type ResponseFormat struct {
	JSONSchema *JSONSchema `json:"json_schema,omitempty"`
	Type       string      `json:"type,omitempty"`
}

type Segment added in v0.1.5

type Segment struct {
	Text             string  `json:"text"`
	Tokens           []int   `json:"tokens"`
	ID               int     `json:"id"`
	Seek             int     `json:"seek"`
	Start            float64 `json:"start"`
	End              float64 `json:"end"`
	Temperature      float64 `json:"temperature"`
	AvgLogprob       float64 `json:"avg_logprob"`
	CompressionRatio float64 `json:"compression_ratio"`
	NoSpeechProb     float64 `json:"no_speech_prob"`
}

type SlimRerankResponse added in v0.1.5

type SlimRerankResponse struct {
	Meta RerankMeta `json:"meta"`
}

type StreamOptions

type StreamOptions struct {
	IncludeUsage bool `json:"include_usage,omitempty"`
}

type SttJSONResponse added in v0.1.5

type SttJSONResponse struct {
	Text string `json:"text,omitempty"`
}

type SttVerboseJSONResponse added in v0.1.5

type SttVerboseJSONResponse struct {
	Task     string     `json:"task,omitempty"`
	Language string     `json:"language,omitempty"`
	Text     string     `json:"text,omitempty"`
	Segments []*Segment `json:"segments,omitempty"`
	Duration float64    `json:"duration,omitempty"`
}

type TextResponse added in v0.1.5

type TextResponse struct {
	ID      string                `json:"id"`
	Model   string                `json:"model,omitempty"`
	Object  string                `json:"object"`
	Choices []*TextResponseChoice `json:"choices"`
	Usage   `json:"usage"`
	Created int64 `json:"created"`
}

type TextResponseChoice added in v0.1.5

type TextResponseChoice struct {
	FinishReason string  `json:"finish_reason"`
	Message      Message `json:"message"`
	Index        int     `json:"index"`
	Text         string  `json:"text,omitempty"`
}

type TextToSpeechRequest

type TextToSpeechRequest struct {
	Model          string  `binding:"required"     json:"model"`
	Input          string  `binding:"required"     json:"input"`
	Voice          string  `binding:"required"     json:"voice"`
	ResponseFormat string  `json:"response_format"`
	Speed          float64 `json:"speed"`
}

type Tool

type Tool struct {
	ID       string   `json:"id,omitempty"`
	Type     string   `json:"type,omitempty"`
	Function Function `json:"function"`
}

type Usage

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

	WebSearchCount int64 `json:"web_search_count,omitempty"`

	PromptTokensDetails *PromptTokensDetails `json:"prompt_tokens_details,omitempty"`
}

func (*Usage) Add added in v0.1.5

func (u *Usage) Add(other *Usage)

func (*Usage) ToModelUsage added in v0.1.7

func (u *Usage) ToModelUsage() *model.Usage

Jump to

Keyboard shortcuts

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