x

Programs, configuration and documentation that don't fit anywhere else
Log | Files | Refs | README | LICENSE

commit 3fc4ee00f4702eccf8874731057ecbbf1ad770c2
parent 27d0f5eda9e06b282956de36b2336519a1a32a61
Author: Oliver Lowe <o@olowe.co>
Date:   Thu, 27 Aug 2026 16:25:04 +1000

openai: initial tool-calling support

Diffstat:
Msrc/openai/openai.go | 35++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/src/openai/openai.go b/src/openai/openai.go @@ -18,16 +18,37 @@ const ( ) type Message struct { - Role string `json:"role"` - Content string `json:"content"` + Role string `json:"role"` + Content string `json:"content"` + Reasoning string `json:"reasoning,omitempty"` + ToolCalls []ToolCall `json:"tool_calls,omitempty"` + ToolCallID string `json:"tool_call_id,omitempty"` +} + +type Function struct { + Name string `json:"name"` + Description string `json:"description"` + Parameters json.RawMessage `json:"parameters"` // JSON Schema for tool arguments +} + +type Tool struct { + Type string `json:"type"` + Function Function `json:"function"` +} + +type ToolCall struct { + ID string `json:"id"` + Type string `json:"type"` // "function" + Function struct { + Name string `json:"name"` + Arguments string `json:"arguments"` // JSON string; parse per tool + } `json:"function"` } type Chat struct { - Messages []Message `json:"messages"` - Model string `json:"model"` - ResponseFormat *struct { - Type string `json:"type"` - } `json:"response_format,omitempty"` + Messages []Message `json:"messages"` + Model string `json:"model"` + Reasoning string `json:"reasoning_effort,omitempty"` } type Model struct {