Documentation
¶
Index ¶
- type ChatRequest
- type ChatResponse
- type Choice
- type Client
- func (c *Client) RunWithTools(ctx context.Context, messages []Message, tools []Tool, stream bool, ...) ([]Message, error)
- func (c *Client) Send(ctx context.Context, req ChatRequest) (*ChatResponse, error)
- func (c *Client) SendStream(ctx context.Context, req ChatRequest, onDelta func(Delta, string)) (*ChatResponse, error)
- type Delta
- type DocsGPTMeta
- type DocsGPTRequest
- type FunctionCall
- type Message
- type Tool
- type ToolCall
- type ToolCallHandler
- type ToolFunction
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRequest ¶
type ChatResponse ¶
type ChatResponse struct {
Choices []Choice `json:"choices"`
DocsGPT DocsGPTMeta `json:"docsgpt,omitempty"`
Usage *Usage `json:"usage,omitempty"`
}
type Client ¶
func (*Client) RunWithTools ¶
func (c *Client) RunWithTools( ctx context.Context, messages []Message, tools []Tool, stream bool, onDelta func(Delta, string), onToolCall ToolCallHandler, ) ([]Message, error)
RunWithTools sends a chat request and handles tool call loops. When the model returns tool_calls, onToolCall is invoked for each one, and results are sent back in a continuation request. This repeats until the model returns finish_reason "stop" (or non-tool_calls).
func (*Client) Send ¶
func (c *Client) Send(ctx context.Context, req ChatRequest) (*ChatResponse, error)
Send performs a non-streaming chat completion request.
func (*Client) SendStream ¶
func (c *Client) SendStream(ctx context.Context, req ChatRequest, onDelta func(Delta, string)) (*ChatResponse, error)
SendStream performs a streaming chat completion request. onDelta is called for each SSE chunk with the delta and finish_reason. Returns the accumulated final response.
type DocsGPTMeta ¶
type DocsGPTMeta struct {
ConversationID string `json:"conversation_id,omitempty"`
Sources json.RawMessage `json:"sources,omitempty"`
ToolCalls json.RawMessage `json:"tool_calls,omitempty"`
}
DocsGPTMeta is the response-side "docsgpt" extension object. Sources and ToolCalls stay raw so a surprising shape can never fail the whole response decode (which would drop an otherwise valid answer).
type DocsGPTRequest ¶
type DocsGPTRequest struct {
Attachments []string `json:"attachments,omitempty"`
}
DocsGPTRequest is the request-side "docsgpt" extension object. It currently carries server-side attachment ids for the /v1 endpoint.
type FunctionCall ¶
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
type ToolCall ¶
type ToolCall struct {
Index int `json:"index,omitempty"`
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Function FunctionCall `json:"function"`
}
type ToolCallHandler ¶
ToolCallHandler is called when the model requests a tool call. It receives the tool call and should return the result string.
type ToolFunction ¶
type ToolFunction struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters json.RawMessage `json:"parameters"`
}