model

package
v0.0.0-...-1389cd0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeText       = "text"
	ContentTypeImageURL   = "image_url"
	ContentTypeInputAudio = "input_audio"
)

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 Document

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

type Error

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

func (*Error) Error

func (e *Error) Error() string

func (*Error) String

func (e *Error) String() string

type ErrorWithStatusCode

type ErrorWithStatusCode struct {
	Error
	StatusCode int `json:"status_code"`
}

func (*ErrorWithStatusCode) String

func (e *ErrorWithStatusCode) String() string

type Function

type Function struct {
	Parameters  any    `json:"parameters,omitempty"`
	Arguments   string `json:"arguments,omitempty"`
	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"`
	ParallelTooCalls    *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 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 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"`
	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"`
}

type RerankMeta

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

type RerankMetaTokens

type RerankMetaTokens struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `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"`
	Result []*RerankResult `json:"result"`
}

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 StreamOptions

type StreamOptions struct {
	IncludeUsage bool `json:"include_usage,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"` // when splicing claude tools stream messages, it is empty
	Function Function `json:"function"`
}

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