openai

package
v0.0.0-...-3b69c6d Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Messages            []Message             `json:"messages"`
	Model               string                `json:"model"`
	FrequencyPenalty    *float32              `json:"frequency_penalty,omitempty"`
	LogitBias           map[string]float32    `json:"logit_bias,omitempty"`
	Logprobs            *bool                 `json:"logprobs,omitempty"`
	TopLogprobs         *int32                `json:"top_logprobs,omitempty"`
	MaxTokens           *int32                `json:"max_tokens,omitempty"`
	MaxCompletionTokens *int32                `json:"max_completion_tokens,omitempty"`
	CandidateCount      *int32                `json:"n,omitempty"`
	PresencePenalty     *float32              `json:"presence_penalty,omitempty"`
	ResponseFormat      *ResponseFormat       `json:"response_format,omitempty"`
	Seed                *int32                `json:"seed,omitempty"`
	ServiceTier         *string               `json:"service_tier,omitempty"`
	StopSequences       *StopSequences        `json:"stop,omitempty"`
	Stream              *bool                 `json:"stream,omitempty"`
	StreamOptions       *StreamOptions        `json:"stream_options,omitempty"`
	Temperature         *float32              `json:"temperature,omitempty"`
	TopP                *float32              `json:"top_p,omitempty"`
	Tools               []Tool                `json:"tools,omitempty"`
	ToolChoice          *ToolChoice           `json:"tool_choice,omitempty"`
	ParallelToolCalls   *bool                 `json:"parallel_tool_calls,omitempty"`
	User                *string               `json:"user,omitempty"`
	FunctionCall        *LegacyFunctionChoice `json:"function_call,omitempty"`
	Functions           []LegacyFunction      `json:"functions,omitempty"`
}

type ChatCompletionResponse

type ChatCompletionResponse struct {
	Id                string   `json:"id"`
	Choices           []Choice `json:"choices"`
	Created           int64    `json:"created"`
	Model             string   `json:"model"`
	ServiceTier       *string  `json:"service_tier,omitempty"`
	SystemFingerprint string   `json:"system_fingerprint"`
	Object            string   `json:"object"`
	Usage             Usage    `json:"usage"`
}

func FinalizeResponse

func FinalizeResponse(provider string, region string, model string, response *ChatCompletionResponse) *ChatCompletionResponse

type Choice

type Choice struct {
	Index        int32     `json:"index"`
	Message      Message   `json:"message"`
	Logprobs     *Logprobs `json:"logprobs"`
	FinishReason string    `json:"finish_reason"`
}

type CompletionTokensDetails

type CompletionTokensDetails struct {
	ReasoningTokens int32 `json:"reasoning_tokens"`
}

type Content

type Content struct {
	TextContent  *TextContent
	ImageContent *ImageContent
}

func (*Content) MarshalJSON

func (p *Content) MarshalJSON() ([]byte, error)

func (*Content) UnmarshalJSON

func (p *Content) UnmarshalJSON(data []byte) error

type Function

type Function struct {
	Name string `json:"name"`
}

type FunctionCall

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

type FunctionTool

type FunctionTool struct {
	Name        string          `json:"name"`
	Description *string         `json:"description,omitempty"`
	Parameters  *orderedmap.Map `json:"parameters,omitempty"`
	Strict      *bool           `json:"strict,omitempty"`
}

type ImageContent

type ImageContent struct {
	Url    string `json:"url"`
	Detail string `json:"detail"`
}

type JsonSchema

type JsonSchema struct {
	Description *string         `json:"description,omitempty"`
	Name        string          `json:"name"`
	Schema      *orderedmap.Map `json:"schema,omitempty"`
	Strict      *bool           `json:"strict,omitempty"`
}

type LegacyFunction

type LegacyFunction struct {
	Name        string          `json:"name"`
	Description *string         `json:"description,omitempty"`
	Parameters  *orderedmap.Map `json:"parameters,omitempty"`
}

type LegacyFunctionChoice

type LegacyFunctionChoice struct {
	Value    *string
	Function *Function
}

func (*LegacyFunctionChoice) MarshalJSON

func (fc *LegacyFunctionChoice) MarshalJSON() ([]byte, error)

func (*LegacyFunctionChoice) UnmarshalJSON

func (fc *LegacyFunctionChoice) UnmarshalJSON(data []byte) error

type Logprob

type Logprob struct {
	Token       string       `json:"token"`
	Logprob     float32      `json:"logprob"`
	Bytes       []byte       `json:"bytes,omitempty"`
	TopLogprobs []TopLogprob `json:"top_logprobs,omitempty"`
}

type Logprobs

type Logprobs struct {
	Content []Logprob `json:"content,omitempty"`
	Refusal []Logprob `json:"refusal,omitempty"`
}

type Message

type Message struct {
	Role string `json:"role"`
	// When the role is "tool" or "function", the content must be a JSON string.
	Content      *MessageContent `json:"content"`
	Name         *string         `json:"name,omitempty"`
	Refusal      *string         `json:"refusal,omitempty"`
	ToolCalls    []ToolCall      `json:"tool_calls,omitempty"`
	ToolCallId   *string         `json:"tool_call_id,omitempty"`
	FunctionCall *FunctionCall   `json:"function_call,omitempty"`
}

type MessageContent

type MessageContent struct {
	String *string
	Parts  []Part
}

func (*MessageContent) MarshalJSON

func (sop *MessageContent) MarshalJSON() ([]byte, error)

func (*MessageContent) UnmarshalJSON

func (sop *MessageContent) UnmarshalJSON(data []byte) error

type Part

type Part struct {
	Type    string  `json:"type"`
	Content Content `json:"content"`
}

type ResponseFormat

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

type StopSequences

type StopSequences struct {
	Sequences []string `json:"tokens"`
}

func (*StopSequences) MarshalJSON

func (ss *StopSequences) MarshalJSON() ([]byte, error)

func (*StopSequences) UnmarshalJSON

func (ss *StopSequences) UnmarshalJSON(data []byte) error

type StreamOptions

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

type TextContent

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

type Tool

type Tool struct {
	Type     string       `json:"type"`
	Function FunctionTool `json:"function"`
}

type ToolCall

type ToolCall struct {
	Id       string        `json:"id"`
	Type     string        `json:"type"`
	Function *FunctionCall `json:"function,omitempty"`
}

type ToolChoice

type ToolChoice struct {
	Value  *ToolChoiceValue
	Struct *ToolChoiceStruct
}

func (*ToolChoice) MarshalJSON

func (tc *ToolChoice) MarshalJSON() ([]byte, error)

func (*ToolChoice) UnmarshalJSON

func (tc *ToolChoice) UnmarshalJSON(data []byte) error

type ToolChoiceStruct

type ToolChoiceStruct struct {
	Type     string    `json:"type"`
	Function *Function `json:"function,omitempty"`
}

type ToolChoiceValue

type ToolChoiceValue string
const (
	ToolChoiceUnspecified ToolChoiceValue = ""
	ToolChoiceNone        ToolChoiceValue = "none"
	ToolChoiceAuto        ToolChoiceValue = "auto"
	ToolChoiceRequired    ToolChoiceValue = "required"
)

type TopLogprob

type TopLogprob struct {
	Token   string  `json:"token"`
	Logprob float32 `json:"logprob"`
	Bytes   []byte  `json:"bytes,omitempty"`
}

type Usage

type Usage struct {
	PromptTokens            int32                   `json:"prompt_tokens"`
	CompletionTokens        int32                   `json:"completion_tokens"`
	TotalTokens             int32                   `json:"total_tokens"`
	CompletionTokensDetails CompletionTokensDetails `json:"completion_tokens_details"`
}

Jump to

Keyboard shortcuts

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