2026-05-19 20:26:20 +00:00
|
|
|
using AIStudio.Tools.ToolCallingSystem;
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Provider.OpenAI;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts the canonical AI Studio tool definition into provider-specific wire shapes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class ProviderToolAdapters
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the nested function tool shape used by Chat Completions compatible APIs.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static object ToChatCompletionTool(ToolDefinition definition) => new
|
|
|
|
|
{
|
|
|
|
|
type = "function",
|
|
|
|
|
function = new
|
|
|
|
|
{
|
|
|
|
|
name = definition.Function.Name,
|
2026-07-17 15:14:12 +00:00
|
|
|
description = definition.Function.DescriptionForLLM,
|
2026-05-19 20:26:20 +00:00
|
|
|
parameters = definition.Function.Parameters,
|
|
|
|
|
strict = definition.Function.Strict,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the flat function tool shape used by the OpenAI Responses API.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static ResponsesFunctionTool ToResponsesTool(ToolDefinition definition) => new()
|
|
|
|
|
{
|
|
|
|
|
Name = definition.Function.Name,
|
2026-07-17 15:14:12 +00:00
|
|
|
Description = definition.Function.DescriptionForLLM,
|
2026-05-19 20:26:20 +00:00
|
|
|
Parameters = definition.Function.Parameters,
|
|
|
|
|
Strict = definition.Function.Strict,
|
|
|
|
|
};
|
|
|
|
|
}
|