openaitools

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package openaitools renders existing go-codex tool/call declarations into the OpenAI "tools" array JSON shape used by Chat Completions/Responses API function calling (and by extension, most OpenAI-compatible providers and client frameworks such as LangChain that accept the same convention).

It is a pure renderer, the same category as render/openapi/ render/asyncapi/render/jsonschema/render/pipeline — no new declaration surface. FromMCPSpec and FromLLMSpec convert an EXISTING [mcp.MCPSpec]/llm.LLMSpec catalog (already accumulated by registering tools/calls against their respective Builders) into the OpenAI shape with zero additional declaration.

Usage

mcpSpec, _ := mcpBuilder.MCPSpec()
tools := openaitools.FromMCPSpec(mcpSpec)
toolsJSON, err := openaitools.Render(tools)
// toolsJSON is ready to embed directly in an OpenAI-style "tools" request field.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(tools []Tool) (json.RawMessage, error)

Render produces the exact OpenAI tools-array JSON shape for tools.

Types

type Tool

type Tool struct {
	Name        string
	Description string
	Parameters  json.RawMessage // JSON Schema
}

Tool is one entry in the OpenAI "tools" array.

func FromLLMSpec

func FromLLMSpec(spec *llm.LLMSpec) []Tool

FromLLMSpec converts every declared llm.Call in spec into Tool entries, using each llm.CallSpec's RequestSchema as Parameters — lets one LLM-backed Call be exposed as a callable "tool" to a DIFFERENT orchestrating LLM (agent-calls-agent via the tool-calling convention, without needing a full Agent2Agent protocol implementation).

func FromMCPSpec

func FromMCPSpec(spec *apimcp.MCPSpec) []Tool

FromMCPSpec converts every tool in spec into Tool entries, using each apimcp.ToolSpec's InputSchema as Parameters. Lets an application expose its EXISTING MCP tool declarations to a raw OpenAI-style tool-calling loop with zero additional declaration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL