🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(llm): add Google AI Studio to single system message conversion list (#10158)
Nanook15bfb09071eb
diff --git a/packages/shared/src/server/llm/fetchLLMCompletion.ts b/packages/shared/src/server/llm/fetchLLMCompletion.tsindex ff6be03736..3d0565a4da 100644--- a/packages/shared/src/server/llm/fetchLLMCompletion.ts+++ b/packages/shared/src/server/llm/fetchLLMCompletion.ts@@ -52,6 +52,7 @@ const isLangfuseCloud = Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION);const PROVIDERS_WITH_REQUIRED_USER_MESSAGE = [LLMAdapter.VertexAI,+ LLMAdapter.GoogleAIStudio,LLMAdapter.Anthropic,];diff --git a/worker/src/__tests__/llmConnections.test.ts b/worker/src/__tests__/llmConnections.test.tsindex ef8a9771be..93dcbe08e9 100644--- a/worker/src/__tests__/llmConnections.test.ts+++ b/worker/src/__tests__/llmConnections.test.ts@@ -761,5 +761,38 @@ describe("LLM Connection Tests", () => {expect(completion.tool_calls[0].name).toBe("get_weather");expect(completion.tool_calls[0].args).toHaveProperty("location");}, 30_000);++ test("single system message is converted to user message", async () => {+ checkEnvVar();++ // Regression test: Text prompts create a single system message.+ // GoogleAIStudio must convert it to a user message to prevent:+ // "GenerateContentRequest.contents is not specified" error+ const completion = await fetchLLMCompletion({+ streaming: false,+ messages: [+ {+ role: "system",+ content: "What is 2+2? Answer only with the number.",+ type: ChatMessageType.System,+ },+ ],+ modelParams: {+ provider: "google-ai-studio",+ adapter: LLMAdapter.GoogleAIStudio,+ model: MODEL,+ temperature: 0,+ max_tokens: 10,+ },+ llmConnection: {+ secretKey: encrypt(+ process.env.LANGFUSE_LLM_CONNECTION_GOOGLEAISTUDIO_KEY!,+ ),+ },+ });++ expect(typeof completion).toBe("string");+ expect(completion).toContain("4");+ }, 30_000);});});