Skip to content

Commit b982338

Browse files
authored
Improve tool call example (#194)
1 parent 153ee14 commit b982338

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ const session = await LanguageModel.create({
176176
initialPrompts: [
177177
{
178178
role: "system",
179-
content: `You are a helpful assistant. You can use tools to help the user.`
180-
}
179+
content: `You are a helpful assistant. You can use tools to help the user.`,
180+
},
181181
],
182+
expectedInputs: [{ type: "text", languages: ["en"] }],
183+
expectedOutputs: [{ type: "tool-call" }, { type: "text", languages: ["en"] }],
182184
tools: [
183185
{
184186
name: "getWeather",
@@ -194,12 +196,14 @@ const session = await LanguageModel.create({
194196
required: ["location"],
195197
},
196198
async execute({ location }) {
197-
const res = await fetch("https://weatherapi.example/?location=" + location);
199+
const res = await fetch(
200+
"https://weatherapi.example/?location=" + location,
201+
);
198202
// Returns the result as a JSON string.
199203
return JSON.stringify(await res.json());
200204
},
201-
}
202-
]
205+
},
206+
],
203207
});
204208

205209
const result = await session.prompt("What is the weather in Seattle?");

0 commit comments

Comments
 (0)