From 47526ac0b2371d6a4a8fad2e6abee76627fe8005 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Mon, 16 Mar 2026 09:05:28 +0100 Subject: [PATCH] Improve tool call example --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 39427b6..791616a 100644 --- a/README.md +++ b/README.md @@ -176,9 +176,11 @@ const session = await LanguageModel.create({ initialPrompts: [ { role: "system", - content: `You are a helpful assistant. You can use tools to help the user.` - } + content: `You are a helpful assistant. You can use tools to help the user.`, + }, ], + expectedInputs: [{ type: "text", languages: ["en"] }], + expectedOutputs: [{ type: "tool-call" }, { type: "text", languages: ["en"] }], tools: [ { name: "getWeather", @@ -194,12 +196,14 @@ const session = await LanguageModel.create({ required: ["location"], }, async execute({ location }) { - const res = await fetch("https://weatherapi.example/?location=" + location); + const res = await fetch( + "https://weatherapi.example/?location=" + location, + ); // Returns the result as a JSON string. return JSON.stringify(await res.json()); }, - } - ] + }, + ], }); const result = await session.prompt("What is the weather in Seattle?");