-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskills.ts
More file actions
95 lines (88 loc) · 3.4 KB
/
skills.ts
File metadata and controls
95 lines (88 loc) · 3.4 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import type { AISkill, AITool } from "../../src";
import type { SixtySecondsReportType } from "./types";
import { getSixtySecondsRuntimeState } from "./runtime";
const sixtySecondsSkills: AISkill[] = [
{
name: "sixty_seconds",
description:
"发送资讯与实用信息,包括 60s 新闻、AI 快报、货币汇率、历史上的今天、Epic免费游戏、IT资讯、金价、油价、天气、摸鱼日报、Whois查询、热搜榜单",
permission: "member",
tools: [
{
name: "send_report",
description:
"发送一个报告到当前聊天。油价需要 region,天气需要 query,其余参数按类型选填。热搜和Whois需要 query 参数。",
parameters: {
type: "object",
properties: {
report_type: {
type: "string",
description:
"报告类型,可选 world_news、ai_news、exchange_rate、history、epic_games、it_news、gold_price、fuel_price、weather、moyu_daily、hot_search、whois",
enum: [
"world_news",
"ai_news",
"exchange_rate",
"history",
"epic_games",
"it_news",
"gold_price",
"fuel_price",
"weather",
"moyu_daily",
"hot_search",
"whois",
],
},
currency: {
type: "string",
description: "汇率基准货币代码,例如 USD、CNY、EUR",
},
region: {
type: "string",
description: "油价查询地区,例如 杭州、成都郫县",
},
query: {
type: "string",
description: "天气查询地区/热搜/Whois查询域名,例如 杭州、北京海淀、example.com",
},
},
required: ["report_type"],
},
handler: async (args: any, runtimeCtx?: any) => {
const runtime = getSixtySecondsRuntimeState().runtime;
const ctx = runtimeCtx?.ctx;
const event = runtimeCtx?.event || runtimeCtx?.rawEvent;
if (!runtime) {
return "60s 插件尚未初始化";
}
const reportType = String(
args?.report_type || "",
).trim() as SixtySecondsReportType;
if (!reportType) {
return "缺少 report_type";
}
if (!ctx || !event) {
return "当前上下文不支持发送 60s 报告";
}
const result = await runtime.sendReport(ctx, event, {
type: reportType,
date: args?.date ? String(args.date) : undefined,
currency: args?.currency ? String(args.currency) : undefined,
region: args?.region ? String(args.region) : undefined,
query: args?.query ? String(args.query) : undefined,
limit:
args?.limit != null && Number.isFinite(Number(args.limit))
? Number(args.limit)
: undefined,
});
const content = result.markdown || result.text;
return result.ok
? `已发送${result.title}。以下是报告的主要内容,知晓即可,不需要再向用户重复:\n${content}`
: result.text;
},
} as AITool,
],
},
];
export default sixtySecondsSkills;