adapter

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitValidator

func InitValidator(val *validator.Validate)

Types

type Adapter

type Adapter interface {
	Completion(ctx context.Context, messages []Message, params CompletionParams) (Completion, error)
	Embeddings(ctx context.Context, input string, params EmbeddingsParams) (Embeddings, error)
}

type AssistantMessage

type AssistantMessage struct {
	Content   *string    `json:"content,omitempty"`
	Refusal   *string    `json:"refusal,omitempty"`
	ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}

type Completion

type Completion struct {
	Message AssistantMessage `json:"message" validate:"required"`
	Usage   *CompletionUsage `json:"usage,omitempty"`
}

type CompletionParams

type CompletionParams struct {
	Model            string          `json:"model" validate:"required"`
	FrequencyPenalty *float64        `json:"frequency_penalty,omitempty" validate:"omitempty,gte=-2.0,lte=2.0"`
	PresencePenalty  *float64        `json:"presence_penalty,omitempty" validate:"omitempty,gte=-2.0,lte=2.0"`
	ResponseFormat   *ResponseFormat `json:"response_format,omitempty"`
	Stop             []string        `json:"stop,omitempty" validate:"omitempty,max=4"`
	Temperature      *float64        `json:"temperature,omitempty" validate:"omitempty,gte=0.0,lte=2.0"`
	Tools            []Tool          `json:"tools,omitempty"`
	TopP             *float64        `json:"top_p,omitempty" validate:"omitempty,gte=0.0,lte=1.0"`
}

type CompletionUsage

type CompletionUsage struct {
	CompletionTokens int64 `json:"completion_tokens"`
	PromptTokens     int64 `json:"prompt_tokens"`
}

type ContentPart

type ContentPart struct {
	OfContentPartText     *ContentPartText  `json:"text,omitempty"`
	OfContentPartImageUrl *ContentPartImage `json:"image_url,omitempty"`
}

type ContentPartImage

type ContentPartImage struct {
	ImageUrl string `json:"image_url" validate:"required,url"`
}

type ContentPartText

type ContentPartText struct {
	Text string `json:"text" validate:"required"`
}

type Embeddings

type Embeddings struct {
	Data  []float64        `json:"data" validate:"required,min=1"`
	Usage *EmbeddingsUsage `json:"usage,omitempty"`
}

type EmbeddingsParams

type EmbeddingsParams struct {
	Model      string `json:"model" validate:"required"`
	Dimensions *int64 `json:"dimensions,omitempty" validate:"omitempty,min=1"`
}

type EmbeddingsUsage

type EmbeddingsUsage struct {
	PromptTokens int64 `json:"prompt_tokens"`
}

type JSONSchema

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

type Message

type Message struct {
	OfSystemMessage    *SystemMessage    `json:"system,omitempty"`
	OfUserMessage      *UserMessage      `json:"user,omitempty"`
	OfAssistantMessage *AssistantMessage `json:"assistant,omitempty"`
	OfToolMessage      *ToolMessage      `json:"tool,omitempty"`
}

func CreateSystemMessage

func CreateSystemMessage(content string) Message

func CreateToolMessage

func CreateToolMessage(callId string, response string) Message

func CreateUserMessage

func CreateUserMessage(content string) Message

type ResponseFormat

type ResponseFormat struct {
	OfResponseFormatText       *ResponseFormatText       `json:"text,omitempty"`
	OfResponseFormatJSONSchema *ResponseFormatJSONSchema `json:"json_schema,omitempty"`
}

type ResponseFormatJSONSchema

type ResponseFormatJSONSchema struct {
	JSONSchema JSONSchema `json:"json_schema" validate:"required"`
}

type ResponseFormatText

type ResponseFormatText struct{}

type SystemMessage

type SystemMessage struct {
	Content string `json:"content" validate:"required"`
}

type Tool

type Tool struct {
	Function ToolFunction `json:"function" validate:"required"`
}

type ToolCall

type ToolCall struct {
	Id       string           `json:"id" validate:"required"`
	Function ToolCallFunction `json:"function" validate:"required"`
}

type ToolCallFunction

type ToolCallFunction struct {
	Name      string `json:"name" validate:"required"`
	Arguments string `json:"arguments" validate:"required"`
}

type ToolFunction

type ToolFunction struct {
	Name        string         `json:"name" validate:"required"`
	Description *string        `json:"description,omitempty"`
	Parameters  map[string]any `json:"parameters" validate:"required"`
	Strict      *bool          `json:"strict,omitempty"`
}

type ToolMessage

type ToolMessage struct {
	ToolCallId string            `json:"tool_call_id" validate:"required"`
	Content    []ContentPartText `json:"content" validate:"required,min=1"`
}

type UserMessage

type UserMessage struct {
	Parts []ContentPart `json:"parts" validate:"required,min=1"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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