ToLLMToolCall (openai/inbound_convert.go)

axonhub · llm/transformer/openai/inbound_convert.go · go · Apache-2.0
ai, AI / Agents

Converts OpenAI request/response structures to unified llm types.

// Source: https://github.com/looplj/axonhub | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package openai

import (
	"github.com/samber/lo"

	"github.com/looplj/axonhub/llm"
)

// ToLLMToolCall converts OpenAI ToolCall to unified llm.ToolCall.
func (tc ToolCall) ToLLMToolCall() llm.ToolCall {
	toolCall := llm.ToolCall{
		ID:   tc.ID,
		Type: tc.Type,
		Function: llm.FunctionCall{
			Name:      tc.Function.Name,
			Arguments: tc.Function.Arguments,
		},
		Index: tc.Index,
	}

	extraContent := tc.ExtraContent
	if extraContent == nil && tc.ExtraFields != nil {
		extraContent = tc.ExtraFields.ExtraContent
	}

	if extraContent != nil &&
		extraContent.Google != nil &&
		extraContent.

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key