MCPcopy Create free account
hub / github.com/betta-tech/byo-coding-agent / toTools

Method toTools

internal/provider/openai.go:195–217  ·  view source on GitHub ↗

toTools builds the OpenAI tool list. OpenAI expects the *full* JSON Schema envelope (`{"type":"object","properties":..., "required":...}`); our ToolDef.InputSchema only holds the inner properties map, so we wrap.

(tools []api.ToolDef)

Source from the content-addressed store, hash-verified

193// envelope (`{"type":"object","properties":..., "required":...}`); our
194// ToolDef.InputSchema only holds the inner properties map, so we wrap.
195func (p *OpenAIProvider) toTools(tools []api.ToolDef) []openai.ChatCompletionToolParam {
196 if len(tools) == 0 {
197 return nil
198 }
199 out := make([]openai.ChatCompletionToolParam, 0, len(tools))
200 for _, t := range tools {
201 parameters := map[string]any{
202 "type": "object",
203 "properties": t.InputSchema,
204 }
205 if len(t.Required) > 0 {
206 parameters["required"] = t.Required
207 }
208 out = append(out, openai.ChatCompletionToolParam{
209 Function: shared.FunctionDefinitionParam{
210 Name: t.Name,
211 Description: param.NewOpt(t.Description),
212 Parameters: shared.FunctionParameters(parameters),
213 },
214 })
215 }
216 return out
217}
218
219func fromFinishReason(r string) api.StopReason {
220 switch r {

Callers 1

SendMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected