-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwikipedia_vector.ts
53 lines (46 loc) · 1.6 KB
/
wikipedia_vector.ts
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
import { createVectorStoreTools } from '@fabrice-ai/tools/vector'
import { agent } from 'fabrice-ai/agent'
import { solution } from 'fabrice-ai/solution'
import { teamwork } from 'fabrice-ai/teamwork'
import { logger } from 'fabrice-ai/telemetry'
import { workflow } from 'fabrice-ai/workflow'
import { lookupWikipedia } from './tools/wikipedia.js'
const { saveDocumentInVectorStore, searchInVectorStore } = createVectorStoreTools()
const wikipediaIndexer = agent({
description: `
You are skilled at reading and understanding the context of Wikipedia articles.
You can save Wikipedia articles in Vector store for later use.
When saving articles in Vector store, you only save first 10 sentences.
`,
tools: {
lookupWikipedia,
saveDocumentInVectorStore,
},
})
const reportCompiler = agent({
description: `
You are skilled at compiling information from various sources into a coherent report.
You can search for specific sentences in Vector database.
`,
tools: {
searchInVectorStore,
},
})
const wikipediaResearch = workflow({
team: { wikipediaIndexer, reportCompiler },
description: `
Find information about John III Sobieski on Wikipedia and save it in Vector store.
Lookup sentences related to the following topics:
- "Battle of Vienna"
- "John III later years and death"
`,
knowledge: `
Each document in Vector store is a sentence.
`,
output: `
List of sentences looked up for each topic. Each sentence should be in separate bullet point.
`,
snapshot: logger,
})
const result = await teamwork(wikipediaResearch)
console.log(solution(result))