import { schemasWeather } from "https://esm.town/v/webup/schemasWeather?v=4";
import { chat } from "https://esm.town/v/webup/chat?v=23";
export const chatSampleFunctionMultiple = (async () => {
const callAssistant = async (messages) => {
const response = await chat(messages, {
functions: schemasWeather,
});
typeof response === "object"
? console.log(`Assistant: ${JSON.stringify(response)}`)
: console.log(`Assistant: ${response}`);
return response;
};
const messages = [
{
role: "system",
content:
"Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous.",
},
{ role: "user", content: "What's the weather like today" },
];
let response = await callAssistant(messages);
messages.push({ role: "assistant", content: response });
messages.push({ role: "user", content: "I'm in Glasgow, Scotland." });
response = await callAssistant(messages);
messages.length = 1;
messages.push({
role: "user",
content:
"what is the weather going to be like in Glasgow, Scotland over the next x days",
});
response = await callAssistant(messages);
messages.push({ role: "assistant", content: response });
messages.push({ role: "user", content: "5 days" });
response = await callAssistant(messages);
})();