1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);
})();
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023