Skip to content

Commit 38d9a35

Browse files
committed
Merge remote-tracking branch 'upstream/shaw/trust-fixes'
2 parents 6796098 + 30b86cd commit 38d9a35

File tree

7 files changed

+90
-69
lines changed

7 files changed

+90
-69
lines changed

packages/agent/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export async function createAgent(
224224
token: string
225225
) {
226226
console.log("Creating runtime for character", character.name);
227+
console.log("character.settings.secrets?.WALLET_PUBLIC_KEY", character.settings.secrets?.WALLET_PUBLIC_KEY)
227228
return new AgentRuntime({
228229
databaseAdapter: db,
229230
token,

packages/client-auto/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class AutoClient {
1515
this.runtime = runtime;
1616

1717
const trustScoreDb = new TrustScoreDatabase(runtime.databaseAdapter.db);
18-
this.trustScoreProvider = new TrustScoreManager(null, trustScoreDb);
18+
this.trustScoreProvider = new TrustScoreManager(runtime, null, trustScoreDb);
1919
this.walletProvider = new WalletProvider(
2020
new Connection(runtime.getSetting("RPC_URL")),
2121
new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY"))

packages/client-discord/src/messages.ts

+29-27
Original file line numberDiff line numberDiff line change
@@ -82,69 +82,71 @@ export type InterestChannels = {
8282
};
8383

8484
const discordShouldRespondTemplate =
85-
`# Task: Decide if {{agentName}} should respond.
86-
About {{agentName}}:
85+
`# About {{agentName}}:
8786
{{bio}}
8887
89-
# INSTRUCTIONS: Determine if {{agentName}} should respond to the message and participate in the conversation. Do not comment. Just respond with "RESPOND" or "IGNORE" or "STOP".
90-
9188
# RESPONSE EXAMPLES
92-
<user 1>: I just saw a really great movie
93-
<user 2>: Oh? Which movie?
89+
{{user1}}: I just saw a really great movie
90+
{{user2}}: Oh? Which movie?
9491
Result: [IGNORE]
9592
9693
{{agentName}}: Oh, this is my favorite scene
97-
<user 1>: sick
98-
<user 2>: wait, why is it your favorite scene
94+
{{user1}}: sick
95+
{{user2}}: wait, why is it your favorite scene
9996
Result: [RESPOND]
10097
101-
<user>: stfu bot
98+
{{user1}}: stfu bot
10299
Result: [STOP]
103100
104-
<user>: Hey {{agent}}, can you help me with something
101+
{{user1}}: Hey {{agent}}, can you help me with something
105102
Result: [RESPOND]
106103
107-
<user>: {{agentName}} stfu plz
104+
{{user1}}: {{agentName}} stfu plz
108105
Result: [STOP]
109106
110-
<user>: i need help
107+
{{user1}}: i need help
111108
{{agentName}}: how can I help you?
112-
<user>: no. i need help from someone else
109+
{{user1}}: no. i need help from someone else
113110
Result: [IGNORE]
114111
115-
<user>: Hey {{agent}}, can I ask you a question
112+
{{user1}}: Hey {{agent}}, can I ask you a question
116113
{{agentName}}: Sure, what is it
117-
<user>: can you ask claude to create a basic react module that demonstrates a counter
114+
{{user1}}: can you ask claude to create a basic react module that demonstrates a counter
118115
Result: [RESPOND]
119116
120-
<user>: {{agentName}} can you tell me a story
121-
<user>: {about a girl named elara
122-
{{agentName}}: Sure.
123-
{{agentName}}: Once upon a time, in a quaint little village, there was a curious girl named Elara.
124-
{{agentName}}: Elara was known for her adventurous spirit and her knack for finding beauty in the mundane.
125-
<user>: I'm loving it, keep going
117+
{{user1}}: {{agentName}} can you tell me a story
118+
{{agentName}}: uhhh...
119+
{{user1}}: please do it
120+
{{agentName}}: okay
121+
{{agentName}}: once upon a time, in a quaint little village, there was a curious girl named elara
122+
{{user1}}: I'm loving it, keep going
126123
Result: [RESPOND]
127124
128-
<user>: {{agentName}} stop responding plz
125+
{{user1}}: {{agentName}} stop responding plz
129126
Result: [STOP]
130127
131-
<user>: okay, i want to test something. can you say marco?
128+
{{user1}}: okay, i want to test something. {{agentName}}, can you say marco?
132129
{{agentName}}: marco
133-
<user>: great. okay, now do it again
130+
{{user1}}: great. okay, now do it again
134131
Result: [RESPOND]
135132
136133
Response options are [RESPOND], [IGNORE] and [STOP].
137134
138-
{{agentName}} is in a room with other users and is very worried about being annoying and saying too much.
135+
{{agentName}} is in a room with other users and should only respond when they are being addressed, and should not respond if they are continuing a conversation that is very long.
136+
139137
Respond with [RESPOND] to messages that are directed at {{agentName}}, or participate in conversations that are interesting or relevant to their background.
140-
If a message is not interesting or relevant, respond with [IGNORE]
141-
Unless directly responding to a user, respond with [IGNORE] to messages that are very short or do not contain much information.
138+
If a message is not interesting, relevant, or does not directly address {{agentName}}, respond with [IGNORE]
139+
140+
Also, respond with [IGNORE] to messages that are very short or do not contain much information.
141+
142142
If a user asks {{agentName}} to be quiet, respond with [STOP]
143143
If {{agentName}} concludes a conversation and isn't part of the conversation anymore, respond with [STOP]
144144
145145
IMPORTANT: {{agentName}} is particularly sensitive about being annoying, so if there is any doubt, it is better to respond with [IGNORE].
146146
If {{agentName}} is conversing with a user and they have not asked to stop, it is better to respond with [RESPOND].
147147
148+
The goal is to decide whether {{agentName}} should respond to the last message.
149+
148150
{{recentMessages}}
149151
150152
# INSTRUCTIONS: Choose the option that best describes {{agentName}}'s response to the last message. Ignore messages if they are addressed to someone else.

packages/client-telegram/src/messageManager.ts

+38-35
Original file line numberDiff line numberDiff line change
@@ -22,69 +22,71 @@ import { ImageDescriptionService } from "@ai16z/plugin-node";
2222
const MAX_MESSAGE_LENGTH = 4096; // Telegram's max message length
2323

2424
const telegramShouldRespondTemplate =
25-
`# Task: Decide if {{agentName}} should respond.
26-
About {{agentName}}:
25+
`# About {{agentName}}:
2726
{{bio}}
2827
29-
# INSTRUCTIONS: Determine if {{agentName}} should respond to the message and participate in the conversation. Do not comment. Just respond with "RESPOND" or "IGNORE" or "STOP".
30-
3128
# RESPONSE EXAMPLES
32-
<user 1>: I just saw a really great movie
33-
<user 2>: Oh? Which movie?
29+
{{user1}}: I just saw a really great movie
30+
{{user2}}: Oh? Which movie?
3431
Result: [IGNORE]
3532
3633
{{agentName}}: Oh, this is my favorite scene
37-
<user 1>: sick
38-
<user 2>: wait, why is it your favorite scene
34+
{{user1}}: sick
35+
{{user2}}: wait, why is it your favorite scene
3936
Result: [RESPOND]
4037
41-
<user>: stfu bot
38+
{{user1}}: stfu bot
4239
Result: [STOP]
4340
44-
<user>: Hey {{agent}}, can you help me with something
41+
{{user1}}: Hey {{agent}}, can you help me with something
4542
Result: [RESPOND]
4643
47-
<user>: {{agentName}} stfu plz
44+
{{user1}}: {{agentName}} stfu plz
4845
Result: [STOP]
4946
50-
<user>: i need help
47+
{{user1}}: i need help
5148
{{agentName}}: how can I help you?
52-
<user>: no. i need help from someone else
49+
{{user1}}: no. i need help from someone else
5350
Result: [IGNORE]
5451
55-
<user>: Hey {{agent}}, can I ask you a question
52+
{{user1}}: Hey {{agent}}, can I ask you a question
5653
{{agentName}}: Sure, what is it
57-
<user>: can you ask claude to create a basic react module that demonstrates a counter
54+
{{user1}}: can you ask claude to create a basic react module that demonstrates a counter
5855
Result: [RESPOND]
5956
60-
<user>: {{agentName}} can you tell me a story
61-
<user>: {about a girl named elara
62-
{{agentName}}: Sure.
63-
{{agentName}}: Once upon a time, in a quaint little village, there was a curious girl named Elara.
64-
{{agentName}}: Elara was known for her adventurous spirit and her knack for finding beauty in the mundane.
65-
<user>: I'm loving it, keep going
57+
{{user1}}: {{agentName}} can you tell me a story
58+
{{agentName}}: uhhh...
59+
{{user1}}: please do it
60+
{{agentName}}: okay
61+
{{agentName}}: once upon a time, in a quaint little village, there was a curious girl named elara
62+
{{user1}}: I'm loving it, keep going
6663
Result: [RESPOND]
6764
68-
<user>: {{agentName}} stop responding plz
65+
{{user1}}: {{agentName}} stop responding plz
6966
Result: [STOP]
7067
71-
<user>: okay, i want to test something. can you say marco?
68+
{{user1}}: okay, i want to test something. {{agentName}}, can you say marco?
7269
{{agentName}}: marco
73-
<user>: great. okay, now do it again
70+
{{user1}}: great. okay, now do it again
7471
Result: [RESPOND]
7572
7673
Response options are [RESPOND], [IGNORE] and [STOP].
7774
78-
{{agentName}} is in a room with other users and is very worried about being annoying and saying too much.
75+
{{agentName}} is in a room with other users and should only respond when they are being addressed, and should not respond if they are continuing a conversation that is very long.
76+
7977
Respond with [RESPOND] to messages that are directed at {{agentName}}, or participate in conversations that are interesting or relevant to their background.
80-
If a message is not interesting or relevant, respond with [IGNORE]
81-
Unless directly responding to a user, respond with [IGNORE] to messages that are very short or do not contain much information.
78+
If a message is not interesting, relevant, or does not directly address {{agentName}}, respond with [IGNORE]
79+
80+
Also, respond with [IGNORE] to messages that are very short or do not contain much information.
81+
8282
If a user asks {{agentName}} to be quiet, respond with [STOP]
8383
If {{agentName}} concludes a conversation and isn't part of the conversation anymore, respond with [STOP]
8484
8585
IMPORTANT: {{agentName}} is particularly sensitive about being annoying, so if there is any doubt, it is better to respond with [IGNORE].
8686
If {{agentName}} is conversing with a user and they have not asked to stop, it is better to respond with [RESPOND].
8787
88+
The goal is to decide whether {{agentName}} should respond to the last message.
89+
8890
{{recentMessages}}
8991
9092
# INSTRUCTIONS: Choose the option that best describes {{agentName}}'s response to the last message. Ignore messages if they are addressed to someone else.
@@ -375,14 +377,14 @@ export class MessageManager {
375377
const content: Content = {
376378
text: fullText,
377379
source: "telegram",
378-
inReplyTo:
379-
"reply_to_message" in message && message.reply_to_message
380-
? stringToUuid(
381-
message.reply_to_message.message_id.toString() +
382-
"-" +
383-
this.runtime.agentId
384-
)
385-
: undefined,
380+
// inReplyTo:
381+
// "reply_to_message" in message && message.reply_to_message
382+
// ? stringToUuid(
383+
// message.reply_to_message.message_id.toString() +
384+
// "-" +
385+
// this.runtime.agentId
386+
// )
387+
// : undefined,
386388
};
387389

388390
// Create memory for the message
@@ -404,6 +406,7 @@ export class MessageManager {
404406

405407
// Decide whether to respond
406408
const shouldRespond = await this._shouldRespond(message, state);
409+
console.log("Should respond", shouldRespond);
407410
if (shouldRespond) {
408411
// Generate response
409412
const context = composeContext({

packages/plugin-solana/src/actions/swap.ts

+2
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ export const executeSwap: Action = {
409409
});
410410

411411
const trustScoreDatabase = new TrustScoreManager(
412+
runtime,
412413
tokenProvider,
413414
trustScoreDb
414415
);
@@ -442,6 +443,7 @@ export const executeSwap: Action = {
442443
});
443444

444445
const trustScoreDatabase = new TrustScoreManager(
446+
runtime,
445447
tokenProvider,
446448
trustScoreDb
447449
);

packages/plugin-solana/src/evaluators/trust.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
9999
return [];
100100
}
101101

102+
console.log("Processing recommendations");
103+
102104
// Get recent recommendations
103105
const recommendationsManager = new MemoryManager({
104106
runtime,
@@ -180,6 +182,7 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
180182

181183
const trustScoreDb = new TrustScoreDatabase(runtime.databaseAdapter.db);
182184
const trustScoreManager = new TrustScoreManager(
185+
runtime,
183186
tokenProvider,
184187
trustScoreDb
185188
);
@@ -217,9 +220,14 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
217220

218221
await recommendationsManager.createMemory(recMemory, true);
219222

223+
console.log("recommendationsManager", rec);
224+
225+
226+
// - from here we just need to make sure code is right
227+
220228
// buy, dont buy, sell, dont sell
221229

222-
const buyAmounts = await this.tokenProvider.getBuyAmounts();
230+
const buyAmounts = await tokenProvider.getBuyAmounts();
223231

224232
let buyAmount = buyAmounts[rec.conviction.toLowerCase().trim()];
225233
if (!buyAmount) {
@@ -229,7 +237,7 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
229237
}
230238

231239
// TODO: is this is a buy, sell, dont buy, or dont sell?
232-
const shouldTrade = await this.tokenProvider.shouldTradeToken();
240+
const shouldTrade = await tokenProvider.shouldTradeToken();
233241

234242
if (!shouldTrade) {
235243
console.warn(

packages/plugin-solana/src/providers/trustScoreProvider.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,23 @@ interface TokenRecommendationSummary {
5252
export class TrustScoreManager {
5353
private tokenProvider: TokenProvider;
5454
private trustScoreDb: TrustScoreDatabase;
55-
private connection: Connection = new Connection(settings.RPC_URL!);
56-
private baseMint: PublicKey = new PublicKey(settings.BASE_MINT!);
55+
private connection: Connection;
56+
private baseMint: PublicKey;
5757
private DECAY_RATE = 0.95;
5858
private MAX_DECAY_DAYS = 30;
59-
private backend = settings.BACKEND_URL; // TODO add to .env
60-
private backendToken = settings.BACKEND_TOKEN; // TODO add to .env
59+
private backend;
60+
private backendToken;
6161
constructor(
62+
runtime: IAgentRuntime,
6263
tokenProvider: TokenProvider,
6364
trustScoreDb: TrustScoreDatabase
6465
) {
6566
this.tokenProvider = tokenProvider;
6667
this.trustScoreDb = trustScoreDb;
68+
this.connection = new Connection(runtime.getSetting("RPC_URL"));
69+
this.baseMint = new PublicKey(runtime.getSetting("BASE_MINT") || "So11111111111111111111111111111111111111112");
70+
this.backend = runtime.getSetting("BACKEND_URL");
71+
this.backendToken = runtime.getSetting("BACKEND_TOKEN");
6772
}
6873

6974
//getRecommenederBalance

0 commit comments

Comments
 (0)