-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathrss.ts
74 lines (72 loc) · 2.18 KB
/
rss.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
74
import "dotenv/config";
import { graphDataTestRunner } from "@receptron/test_utils";
import * as agents from "@graphai/agents";
export const graph_data = {
version: 0.5,
nodes: {
url: {
// Holds the RSS feed URL
value: "https://www.theverge.com/microsoft/rss/index.xml",
},
rssFeed: {
// Fetchs the RSS feed from the specified feed
agent: "fetchAgent",
params: {
type: "xml",
},
inputs: { url: ":url" },
},
entries: {
// Extracts necessary information from the feed
agent: "propertyFilterAgent",
params: {
include: ["title", "link", "content"],
},
inputs: { array: [":rssFeed.feed.entry"] },
},
map: {
// Processes each entry concurrently.
agent: "mapAgent",
inputs: { rows: ":entries" },
isResult: true,
params: {
limit: 4, // to avoid rate limit
},
graph: {
nodes: {
template: {
// Extracts title and content, then generate a single text
agent: "stringTemplateAgent",
params: {
template: "Title:${t}\n${c}",
},
inputs: { t: ":row.title", c: ":row.content._" },
},
query: {
// Asks the LLM to summarize it
agent: "groqAgent",
params: {
model: "Llama3-8b-8192", // "mixtral-8x7b-32768",
query: "次のHTMLからテキストだけを抜き出し、省略せずに、全文を日本語に翻訳して。余計なことは言わずに、翻訳した文章だけ答えて。",
},
inputs: { prompt: ":template" },
},
extractor: {
// Extract the content from the generated message
agent: "copyAgent",
isResult: true,
inputs: { result: ":query.choices.$0.message.content" },
},
},
},
},
},
};
export const main = async () => {
const result = (await graphDataTestRunner(__dirname + "/../", "sample_net.log", graph_data, agents)) as any;
// console.log(result.map.extractor.join("\n\n"));
console.log(result.map);
};
if (process.argv[1] === __filename) {
main();
}