import { chat } from "https://esm.town/v/webup/chat";
export const chatSampleFunctionExtraction = (async () => {
const input =
`Alex is 5 feet tall. Claudia is 4 feet taller Alex and jumps higher than him. Claudia is a brunette and Alex is blonde.
Alex's dog Frosty is a labrador and likes to play hide and seek.`;
const prompt =
`Extract and save the relevant entities mentioned in the following passage together with their properties.
Passage:
${input}
`;
const functions = [
{
name: "information_extraction",
description: "Extracts the relevant information from the passage.",
parameters: {
type: "object",
properties: {
info: {
type: "array",
items: {
type: "object",
properties: {
"person-name": { type: "string" },
"person-age": { type: "number" },
"person-hair-color": { type: "string" },
"dog-name": { type: "string" },
"dog-breed": { type: "string" },
},
required: [],
},
},
},
required: ["info"],
},
},
];
const response = await chat(prompt, { functions });
return JSON.parse(response?.arguments);
})();