Documentation
¶
Index ¶
- Constants
- func ConvertAIChatToUIChat(aiChat uctypes.AIChat) (*uctypes.UIChat, error)
- func ConvertToolResultsToNativeChatMessage(toolResults []uctypes.AIToolResult) ([]uctypes.GenAIMessage, error)
- func GetFunctionCallInputByToolCallId(aiChat uctypes.AIChat, toolCallId string) *uctypes.AIFunctionCallInput
- func UpdateToolUseData(chatId string, callId string, newToolUseData uctypes.UIMessageDataToolUse) error
- type ChatRequest
- type ChatRequestMessage
- type ChatUsage
- type ContentDelta
- type StoredChatMessage
- type StreamChoice
- type StreamChunk
- type ToolCall
- type ToolCallDelta
- type ToolDefinition
- type ToolFunctionCall
- type ToolFunctionDef
- type ToolFunctionDelta
Constants ¶
View Source
const (
OpenAIChatDefaultMaxTokens = 4096
)
Variables ¶
This section is empty.
Functions ¶
func ConvertAIChatToUIChat ¶
ConvertAIChatToUIChat converts stored chat to UI format
func ConvertToolResultsToNativeChatMessage ¶
func ConvertToolResultsToNativeChatMessage(toolResults []uctypes.AIToolResult) ([]uctypes.GenAIMessage, error)
ConvertToolResultsToNativeChatMessage converts tool results to OpenAI tool messages
func GetFunctionCallInputByToolCallId ¶
func GetFunctionCallInputByToolCallId(aiChat uctypes.AIChat, toolCallId string) *uctypes.AIFunctionCallInput
GetFunctionCallInputByToolCallId searches for a tool call by ID in the chat history
func UpdateToolUseData ¶
func UpdateToolUseData(chatId string, callId string, newToolUseData uctypes.UIMessageDataToolUse) error
UpdateToolUseData updates the ToolUseData for a specific tool call in the chat history
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []ChatRequestMessage `json:"messages"`
Stream bool `json:"stream"`
MaxTokens int `json:"max_tokens,omitempty"` // legacy
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"` // newer
Temperature float64 `json:"temperature,omitempty"`
Tools []ToolDefinition `json:"tools,omitempty"` // if you use tools
ToolChoice any `json:"tool_choice,omitempty"` // "auto", "none", or struct
}
type ChatRequestMessage ¶
type ChatRequestMessage struct {
Role string `json:"role"` // "system","user","assistant","tool"
Content string `json:"content,omitempty"` // normal text messages
ToolCalls []ToolCall `json:"tool_calls,omitempty"` // assistant tool-call message
ToolCallID string `json:"tool_call_id,omitempty"` // for role:"tool"
Name string `json:"name,omitempty"` // tool name on role:"tool"
}
func (*ChatRequestMessage) FindToolCallIndex ¶
func (cm *ChatRequestMessage) FindToolCallIndex(toolCallId string) int
type ContentDelta ¶
type ContentDelta struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
ToolCalls []ToolCallDelta `json:"tool_calls,omitempty"`
}
This is the important part:
type StoredChatMessage ¶
type StoredChatMessage struct {
MessageId string `json:"messageid"`
Message ChatRequestMessage `json:"message"`
Usage *ChatUsage `json:"usage,omitempty"`
}
StoredChatMessage is the stored message type
func ConvertAIMessageToStoredChatMessage ¶
func ConvertAIMessageToStoredChatMessage(aiMsg uctypes.AIMessage) (*StoredChatMessage, error)
ConvertAIMessageToStoredChatMessage converts an AIMessage to StoredChatMessage These messages are ALWAYS role "user"
func RunChatStep ¶
func RunChatStep( ctx context.Context, sseHandler *sse.SSEHandlerCh, chatOpts uctypes.WaveChatOpts, cont *uctypes.WaveContinueResponse, ) (*uctypes.WaveStopReason, []*StoredChatMessage, *uctypes.RateLimitInfo, error)
RunChatStep executes a chat step using the chat completions API
func (*StoredChatMessage) Copy ¶
func (m *StoredChatMessage) Copy() *StoredChatMessage
func (*StoredChatMessage) GetMessageId ¶
func (m *StoredChatMessage) GetMessageId() string
func (*StoredChatMessage) GetRole ¶
func (m *StoredChatMessage) GetRole() string
func (*StoredChatMessage) GetUsage ¶
func (m *StoredChatMessage) GetUsage() *uctypes.AIUsage
type StreamChoice ¶
type StreamChoice struct {
Index int `json:"index"`
Delta ContentDelta `json:"delta"`
FinishReason *string `json:"finish_reason"` // "stop", "length" | "tool_calls" | "content_filter"
}
type StreamChunk ¶
type StreamChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []StreamChoice `json:"choices"`
}
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"` // "function"
Function ToolFunctionCall `json:"function"`
ToolUseData *uctypes.UIMessageDataToolUse `json:"toolusedata,omitempty"` // Internal field (must be cleaned before sending to API)
}
type ToolCallDelta ¶
type ToolCallDelta struct {
Index int `json:"index"`
ID string `json:"id,omitempty"` // only on first chunk
Type string `json:"type,omitempty"` // "function"
Function *ToolFunctionDelta `json:"function,omitempty"`
}
type ToolDefinition ¶
type ToolDefinition struct {
Type string `json:"type"` // "function"
Function ToolFunctionDef `json:"function"`
}
type ToolFunctionCall ¶
type ToolFunctionDef ¶
type ToolFunctionDelta ¶
Click to show internal directories.
Click to hide internal directories.