Merge remote-tracking branch 'origin/farm/8b26bc9b/force-command-not-working'

This commit is contained in:
Can Bölük
2026-05-21 13:22:53 +09:00
6 changed files with 116 additions and 8 deletions
@@ -2,7 +2,8 @@ import type { Api, Model, ToolChoice } from "@oh-my-pi/pi-ai";
/**
* Build a provider-aware tool choice that targets one specific tool when supported.
* Some providers only support "any tool" forcing, not a named tool.
* Providers that only expose required/any forcing may still honor named choices by
* narrowing their request tool list before transport.
*/
export function buildNamedToolChoice(toolName: string, model?: Model<Api>): ToolChoice | undefined {
if (!model) return undefined;
@@ -20,12 +21,11 @@ export function buildNamedToolChoice(toolName: string, model?: Model<Api>): Tool
return { type: "function", name: toolName };
}
if (
model.api === "google-generative-ai" ||
model.api === "google-gemini-cli" ||
model.api === "google-vertex" ||
model.api === "ollama-chat"
) {
if (model.api === "ollama-chat") {
return { type: "function", name: toolName };
}
if (model.api === "google-generative-ai" || model.api === "google-gemini-cli" || model.api === "google-vertex") {
return "required";
}