Documentation
¶
Index ¶
- Constants
- func ConvertAIChatToUIChat(aiChat uctypes.AIChat) (*uctypes.UIChat, error)
- func UpdateToolUseData(chatId string, callId string, newToolUseData *uctypes.UIMessageDataToolUse) error
- type OpenAIChatMessage
- func ConvertAIMessageToOpenAIChatMessage(aiMsg uctypes.AIMessage) (*OpenAIChatMessage, error)
- func ConvertToolResultsToOpenAIChatMessage(toolResults []uctypes.AIToolResult) ([]*OpenAIChatMessage, error)
- func RunOpenAIChatStep(ctx context.Context, sse *sse.SSEHandlerCh, chatOpts uctypes.WaveChatOpts, ...) (*uctypes.WaveStopReason, []*OpenAIChatMessage, *uctypes.RateLimitInfo, error)
- type OpenAIFunctionCallErrorOutput
- type OpenAIFunctionCallInput
- type OpenAIFunctionCallOutputInput
- type OpenAIMessage
- type OpenAIMessageContent
- type OpenAIRequest
- type OpenAIRequestTool
- type OpenAIUsage
- type PromptType
- type ReasoningType
- type StreamOptionsType
- type TextType
Constants ¶
View Source
const ( OpenAIDefaultAPIVersion = "2024-12-31" OpenAIDefaultMaxTokens = 4096 )
Variables ¶
This section is empty.
Functions ¶
func ConvertAIChatToUIChat ¶
ConvertAIChatToUIChat converts an AIChat to a UIChat for OpenAI
func UpdateToolUseData ¶
func UpdateToolUseData(chatId string, callId string, newToolUseData *uctypes.UIMessageDataToolUse) error
Types ¶
type OpenAIChatMessage ¶
type OpenAIChatMessage struct {
MessageId string `json:"messageid"` // internal field for idempotency (cannot send to openai)
Message *OpenAIMessage `json:"message,omitempty"`
FunctionCall *OpenAIFunctionCallInput `json:"functioncall,omitempty"`
FunctionCallOutput *OpenAIFunctionCallOutputInput `json:"functioncalloutput,omitempty"`
Usage *OpenAIUsage
}
func ConvertAIMessageToOpenAIChatMessage ¶
func ConvertAIMessageToOpenAIChatMessage(aiMsg uctypes.AIMessage) (*OpenAIChatMessage, error)
ConvertAIMessageToOpenAIChatMessage converts an AIMessage to OpenAIChatMessage These messages are ALWAYS role "user" Handles text parts, images, PDFs, and text/plain files
func ConvertToolResultsToOpenAIChatMessage ¶
func ConvertToolResultsToOpenAIChatMessage(toolResults []uctypes.AIToolResult) ([]*OpenAIChatMessage, error)
ConvertToolResultsToOpenAIChatMessage converts AIToolResult slice to OpenAIChatMessage slice
func RunOpenAIChatStep ¶
func RunOpenAIChatStep( ctx context.Context, sse *sse.SSEHandlerCh, chatOpts uctypes.WaveChatOpts, cont *uctypes.WaveContinueResponse, ) (*uctypes.WaveStopReason, []*OpenAIChatMessage, *uctypes.RateLimitInfo, error)
func (*OpenAIChatMessage) ConvertToUIMessage ¶
func (m *OpenAIChatMessage) ConvertToUIMessage() *uctypes.UIMessage
ConvertToUIMessage converts an OpenAIChatMessage to a UIMessage
func (*OpenAIChatMessage) GetMessageId ¶
func (m *OpenAIChatMessage) GetMessageId() string
func (*OpenAIChatMessage) GetUsage ¶
func (m *OpenAIChatMessage) GetUsage() *uctypes.AIUsage
type OpenAIFunctionCallInput ¶
type OpenAIFunctionCallInput struct {
Type string `json:"type"` // Required: The type of the function tool call. Always function_call
CallId string `json:"call_id"` // Required: The unique ID of the function tool call generated by the model
Name string `json:"name"` // Required: The name of the function to run
Arguments string `json:"arguments"` // Required: A JSON string of the arguments to pass to the function
Status string `json:"status,omitempty"` // Optional: The status of the item. One of in_progress, completed, or incomplete
ToolUseData *uctypes.UIMessageDataToolUse `json:"toolusedata,omitempty"` // Internal field for UI tool use data (must be cleaned before sending to API)
}
func GetFunctionCallInputByToolCallId ¶
func GetFunctionCallInputByToolCallId(aiChat uctypes.AIChat, toolCallId string) *OpenAIFunctionCallInput
GetFunctionCallInputByToolCallId returns the OpenAIFunctionCallInput associated with the given ToolCallId, or nil if not found in the AIChat
func (*OpenAIFunctionCallInput) Clean ¶
func (f *OpenAIFunctionCallInput) Clean() *OpenAIFunctionCallInput
type OpenAIFunctionCallOutputInput ¶
type OpenAIFunctionCallOutputInput struct {
Type string `json:"type"` // Required: The type of the function tool call output. Always function_call_output
CallId string `json:"call_id"` // Required: The unique ID of the function tool call generated by the model
Output interface{} `json:"output"` // Required: Text, image, or file output of the function tool call
}
type OpenAIMessage ¶
type OpenAIMessage struct {
Role string `json:"role"`
Content []OpenAIMessageContent `json:"content"`
}
func (*OpenAIMessage) CleanAndCopy ¶
func (m *OpenAIMessage) CleanAndCopy() *OpenAIMessage
type OpenAIMessageContent ¶
type OpenAIMessageContent struct {
Type string `json:"type"` // "input_text", "output_text", "input_image", "input_file", "function_call"
Text string `json:"text,omitempty"`
ImageUrl string `json:"image_url,omitempty"`
PreviewUrl string `json:"previewurl,omitempty"` // internal field for 128x128 webp data url (cannot send to API)
Filename string `json:"filename,omitempty"`
FileData string `json:"file_data,omitempty"`
// for Tools (type will be "function_call")
Arguments any `json:"arguments,omitempty"`
CallId string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
}
func (*OpenAIMessageContent) Clean ¶
func (c *OpenAIMessageContent) Clean() *OpenAIMessageContent
type OpenAIRequest ¶
type OpenAIRequest struct {
Background bool `json:"background,omitempty"`
Conversation string `json:"conversation,omitempty"`
Include []string `json:"include,omitempty"`
Input []any `json:"input,omitempty"` // either OpenAIMessage or OpenAIFunctionCallInput
Instructions string `json:"instructions,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
MaxToolCalls int `json:"max_tool_calls,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Model string `json:"model,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
Prompt *PromptType `json:"prompt,omitempty"`
PromptCacheKey string `json:"prompt_cache_key,omitempty"`
Reasoning *ReasoningType `json:"reasoning,omitempty"`
SafetyIdentifier string `json:"safety_identifier,omitempty"`
ServiceTier string `json:"service_tier,omitempty"` // "auto", "default", "flex", "priority"
Store bool `json:"store,omitempty"`
Stream bool `json:"stream,omitempty"`
StreamOptions *StreamOptionsType `json:"stream_options,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Text *TextType `json:"text,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"` // "none", "auto", "required", or object
Tools []OpenAIRequestTool `json:"tools,omitempty"`
TopLogprobs int `json:"top_logprobs,omitempty"`
TopP float64 `json:"top_p,omitempty"`
Truncation string `json:"truncation,omitempty"` // "auto", "disabled"
}
type OpenAIRequestTool ¶
type OpenAIRequestTool struct {
Type string `json:"type"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Parameters any `json:"parameters,omitempty"`
Strict bool `json:"strict,omitempty"`
}
func ConvertToolDefinitionToOpenAI ¶
func ConvertToolDefinitionToOpenAI(tool uctypes.ToolDefinition) OpenAIRequestTool
ConvertToolDefinitionToOpenAI converts a generic ToolDefinition to OpenAI format
type OpenAIUsage ¶
type OpenAIUsage struct {
InputTokens int `json:"input_tokens,omitempty"`
OutputTokens int `json:"output_tokens,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
InputTokensDetails *openaiInputTokensDetails `json:"input_tokens_details,omitempty"`
OutputTokensDetails *openaiOutputTokensDetails `json:"output_tokens_details,omitempty"`
Model string `json:"model,omitempty"` // internal field (not from OpenAI API)
NativeWebSearchCount int `json:"nativewebsearchcount,omitempty"` // internal field (not from OpenAI API)
}
type PromptType ¶
type ReasoningType ¶
type StreamOptionsType ¶
type StreamOptionsType struct {
IncludeObfuscation bool `json:"include_obfuscation"`
}
Click to show internal directories.
Click to hide internal directories.