-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
78 lines (66 loc) · 2.55 KB
/
Copy pathindex.ts
File metadata and controls
78 lines (66 loc) · 2.55 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import Instructor from "@instructor-ai/instructor"
import OpenAI from "openai"
import { z } from "zod"
const textBlock = `
In our recent online meeting, participants from various backgrounds joined to discuss the upcoming tech conference. The names and contact details of the participants were as follows:
- Name: John Doe, Email: johndoe@email.com, Twitter: @TechGuru44
- Name: Jane Smith, Email: janesmith@email.com, Twitter: @DigitalDiva88
- Name: Alex Johnson, Email: alexj@email.com, Twitter: @CodeMaster2023
- Name: Emily Clark, Email: emilyc@email.com, Twitter: @InnovateQueen
- Name: Ron Stewart, Email: ronstewart@email.com, Twitter: @RoboticsRon5
- Name: Sarah Lee, Email: sarahlee@email.com, Twitter: @AI_Aficionado
- Name: Mike Brown, Email: mikeb@email.com, Twitter: @FutureTechLeader
- Name: Lisa Green, Email: lisag@email.com, Twitter: @CyberSavvy101
- Name: David Wilson, Email: davidw@email.com, Twitter: @GadgetGeek77
- Name: Daniel Kim, Email: danielk@email.com, Twitter: @DataDrivenDude
During the meeting, we agreed on several key points. The conference will be held on March 15th, 2024, at the Grand Tech Arena located at 4521 Innovation Drive. Dr. Emily Johnson, a renowned AI researcher, will be our keynote speaker.
The budget for the event is set at $50,000, covering venue costs, speaker fees, and promotional activities. Each participant is expected to contribute an article to the conference blog by February 20th.
A follow-up meeting is scheduled for January 25th at 3 PM GMT to finalize the agenda and confirm the list of speakers.
`
const ExtractionValuesSchema = z.object({
users: z
.array(
z.object({
name: z.string(),
handle: z.string(),
twitter: z.string()
})
)
.min(5),
date: z.string(),
location: z.string(),
budget: z.number(),
deadline: z.string().min(1)
})
const oai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY ?? undefined,
organization: process.env.OPENAI_ORG_ID ?? undefined
})
const client = Instructor({
client: oai,
mode: "TOOLS"
})
let extraction = {}
const extractionStream = await client.chat.completions.create({
messages: [{ role: "user", content: textBlock }],
model: "gpt-4-1106-preview",
response_model: {
schema: ExtractionValuesSchema,
name: "value extraction"
},
stream: true,
seed: 1
})
for await (const result of extractionStream) {
try {
extraction = result
console.clear()
console.table(extraction)
} catch (e) {
console.log(e)
break
}
}
console.clear()
console.log("completed extraction:")
console.table(extraction)