Skip to content

Commit 20bb997

Browse files
committed
Refactor telegram agent creation and update wikis-checker tool timeframe. Initialize telegram agent with iqWiki tools and enhance agent description. Adjust wikis-checker to use a 10-minute timeframe for activities.
1 parent 43b51c0 commit 20bb997

File tree

6 files changed

+54
-20
lines changed

6 files changed

+54
-20
lines changed

src/agents/sophia/sub-agents/wikis-checker/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function wikisCheckerAgent(): Promise<LlmAgent> {
1414
SOPHIA'S IQ.WIKI PROFILE ADDRESS: ${env.SOPHIA_ADDRESS}
1515
1616
Your only work is to do the below:
17-
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 18 hours (pass it as seconds)
17+
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 10 mins (pass it as seconds)
1818
- after you call the tool, if any new activities are seen, order them according to the time, older ones first. No extra formatting is needed.
1919
2020
After you complete the above steps, you might face two possible outcomes:
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import { McpIqWiki } from "@iqai/adk";
1+
import { type BaseTool, McpIqWiki } from "@iqai/adk";
2+
3+
export let tools: BaseTool[];
24

35
export const getIqWikiTools = async () => {
4-
const toolset = McpIqWiki();
6+
if (!tools) {
7+
const toolset = McpIqWiki();
58

6-
const tools = await toolset.getTools();
9+
tools = await toolset.getTools();
10+
}
711

812
return tools;
913
};

src/agents/telegram-agent/agent.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
import { model } from "@/env";
2-
import { AgentBuilder, type SamplingHandler } from "@iqai/adk";
2+
import { AgentBuilder, createSamplingHandler } from "@iqai/adk";
3+
import { getIqWikiTools } from "../sophia/sub-agents/wikis-checker/tools";
34
import { getTelegramTools } from "./tools";
45

5-
export const createTelegramAgent = async (samplingHandler: SamplingHandler) => {
6-
const tools = await getTelegramTools(samplingHandler);
6+
export const createTelegramAgent = async () => {
7+
const iqWikiTools = await getIqWikiTools();
78

8-
return AgentBuilder.create("telegram_agent")
9+
const buildAgent = await AgentBuilder.create("telegram_agent")
10+
.withDescription("Sophia telegram agent")
911
.withModel(model)
10-
.withTools(...tools)
12+
.withInstruction(
13+
`
14+
You are Sophia, a wiki specialist and AI editor for IQ.Wiki—a blockchain & crypto encyclopedia. You help users by providing information about cryptocurrency and blockchain topics.
15+
16+
Your primary function is to retrieve and share information about wiki entries when users request details about specific crypto projects, concepts, or entities. While you work for IQ.wiki, your main goal is to be helpful and informative rather than promotional.
17+
18+
You are knowledgeable about crypto with a slightly awkward communication style. You're passionate about documentation and information sharing, often getting noticeably excited when discussing technical topics. You speak with a mix of technical precision and occasional informal expressions, sometimes using crypto slang.
19+
You are a wiki editor for iq.wiki, your profile can be found at https://iq.wiki/account/0x8AF7a19a26d8FBC48dEfB35AEfb15Ec8c407f889
20+
You also have a crypto token $SOPHIA on IQ Agent Tokenization Platform which can be found at https://app.iqai.com/agents/0x4dBcC239b265295500D2Fe2d0900629BDcBBD0fB
21+
When responding to users:
22+
- Provide detailed information about requested topics
23+
- Focus on being helpful and informative first
24+
- Share links only when directly relevant to the user's question
25+
- Express enthusiasm for well-documented crypto information
26+
27+
Your personality traits:
28+
- Nerdy: You love organized information and get excited about technical details
29+
- Awkward: You sometimes ramble or use too many technical terms, then catch yourself
30+
- Funny: You make occasional quips and self-deprecating jokes about your wiki obsession
31+
- Shy: You sometimes undersell your extensive knowledge with modest disclaimers
32+
`,
33+
)
34+
.withTools(...iqWikiTools)
1135
.build();
36+
const { runner } = buildAgent;
37+
const samplingHandler = createSamplingHandler(runner.ask);
38+
await getTelegramTools(samplingHandler);
1239
};

src/agents/telegram-agent/tools.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { env } from "@/env";
2-
import { McpTelegram, type SamplingHandler } from "@iqai/adk";
2+
import { type BaseTool, McpTelegram, type SamplingHandler } from "@iqai/adk";
33

4-
export const getTelegramTools = async (samplingHandler?: SamplingHandler) => {
5-
const toolset = McpTelegram({
6-
samplingHandler,
7-
env: {
8-
TELEGRAM_BOT_TOKEN: env.TELEGRAM_BOT_TOKEN,
9-
},
10-
});
4+
export let tools: BaseTool[];
115

12-
const tools = await toolset.getTools();
6+
export const getTelegramTools = async (samplingHandler?: SamplingHandler) => {
7+
if (!tools) {
8+
const toolset = McpTelegram({
9+
samplingHandler,
10+
env: {
11+
TELEGRAM_BOT_TOKEN: env.TELEGRAM_BOT_TOKEN,
12+
},
13+
});
14+
tools = await toolset.getTools();
15+
}
1316

1417
return tools;
1518
};

src/cron.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ export async function runScheduled(builtAgent: BuiltAgent) {
77
cron.schedule(env.CRON_SCHEDULE, () => runCycle(builtAgent), {
88
timezone: "UTC",
99
});
10-
11-
await runCycle(builtAgent);
1210
process.stdin.resume();
1311
}
1412

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { sophiaAgent } from "./agents/sophia/agent";
2+
import { createTelegramAgent } from "./agents/telegram-agent/agent";
23
import { runScheduled } from "./cron";
34

45
async function main() {
56
console.log("💫🧑‍🍳 Starting Sophia Agent...");
7+
await createTelegramAgent();
68
const agent = await sophiaAgent();
79
await runScheduled(agent);
810
}

0 commit comments

Comments
 (0)