-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgithub_trending_vector.ts
73 lines (62 loc) · 2.01 KB
/
github_trending_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { createFireCrawlTool } from '@fabrice-ai/tools/firecrawl'
import { getApiKey } from '@fabrice-ai/tools/utils'
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 { askUser } from './tools/askUser.js'
const apiKey = await getApiKey('Firecrawl.dev API Key', 'FIRECRAWL_API_KEY')
const { saveDocumentInVectorStore, searchInVectorStore } = createVectorStoreTools()
const { firecrawl } = createFireCrawlTool({
apiKey,
})
const webCrawler = agent({
description: `
You are skilled at browsing Web pages.
You can save the documents to Vector store for later usage.
`,
tools: {
firecrawl,
saveDocumentInVectorStore,
},
})
const human = agent({
description: `
You can ask user and get their answer to questions that are needed by other agents.
`,
tools: {
askUser,
},
})
const reportCompiler = agent({
description: `
You can create a comprehensive report based on the information from Vector store.
You're famous for beautiful Markdown formatting.
`,
tools: {
searchInVectorStore,
},
})
const wrapUpTrending = workflow({
team: { webCrawler, human, reportCompiler },
description: `
Research the "https://github.com/trending/typescript" page.
Select 3 top projects.
For each project, browse details about it on their subpages.
Store each page in Vector store for later usage.
Ask user about which project he wants to learn more.
`,
knowledge: `
Each document in Vector store is a page from the website.
`,
output: `
Create a comprehensive markdown report:
- create a one, two sentences summary about every project.
- include detailed summary about the project selected by the user.
`,
snapshot: logger,
})
const result = await teamwork(wrapUpTrending)
console.log(solution(result))