Quelle pi-mcp-style.cache.live.test.ts
Sprache: JAVA
import type { AssistantMessage, Tool } from "@mariozechner/pi-ai"; import { Type } from "typebox"; import { describe, expect, it } from "vitest"; import {
buildAssistantHistoryTurn,
buildStableCachePrefix,
completeSimpleWithLiveTimeout,
computeCacheHitRate,
extractAssistantText,
LIVE_CACHE_TEST_ENABLED,
logLiveCache,
resolveLiveDirectModel,
} from "./live-cache-test-support.js";
async function runToolOnlyTurn(params: ToolOnlyTurnParams) {
let prompt = `Call the tool \`${MCP_TOOL.name}\` with {}. IMPORTANT: respond ONLY with the tool call and no other text.`;
let response = await completeToolOnlyTurn(params, prompt, "openai mcp-style tool-only turn");
let toolCall = extractFirstToolCall(response);
let text = extractAssistantText(response); for (let attempt = 0; attempt < 2 && (!toolCall || text.length > 0); attempt += 1) {
prompt = `Return only a tool call for \`${MCP_TOOL.name}\` with {}. No text.`;
response = await completeToolOnlyTurn(
params,
prompt,
`openai mcp-style tool-only retry ${attempt + 1}`,
);
toolCall = extractFirstToolCall(response);
text = extractAssistantText(response);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.