Skip to content

Commit 75bdd44

Browse files
committed
fix merge conflict with tsconfig
2 parents e4eb7f1 + 61cc988 commit 75bdd44

File tree

16 files changed

+413
-201
lines changed

16 files changed

+413
-201
lines changed

packages/adapter-postgres/seed.sql

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
INSERT INTO public.accounts (id, name, email, avatarUrl, details) VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', 'default@agent.com', '', '{}');
2-
INSERT INTO public.rooms (id) VALUES ('00000000-0000-0000-0000-000000000000');
3-
INSERT INTO public.participants (userId, roomId) VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000');
1+
2+
INSERT INTO public.accounts (id, name, email, "avatarUrl", details)
3+
VALUES ('00000000-0000-0000-0000-000000000000', 'Default Agent', 'default@agent.com', '', '{}'::jsonb);
4+
5+
INSERT INTO public.rooms (id)
6+
VALUES ('00000000-0000-0000-0000-000000000000');
7+
8+
INSERT INTO public.participants (id, "userId", "roomId")
9+
VALUES ('00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000');

packages/adapter-sqlite/src/index.ts

+20-25
Original file line numberDiff line numberDiff line change
@@ -336,34 +336,29 @@ export class SqliteDatabaseAdapter extends DatabaseAdapter {
336336
query_field_name: string;
337337
query_field_sub_name: string;
338338
query_match_count: number;
339-
}): Promise<
340-
{
341-
embedding: number[];
342-
levenshtein_score: number;
343-
}[]
344-
> {
339+
}): Promise<{ embedding: number[]; levenshtein_score: number }[]> {
345340
const sql = `
346-
SELECT *
347-
FROM memories
348-
WHERE type = ?
349-
AND vec_distance_L2(${opts.query_field_name}, ?) <= ?
350-
ORDER BY vec_distance_L2(${opts.query_field_name}, ?) ASC
351-
LIMIT ?
352-
`;
353-
console.log("sql", sql)
354-
console.log("opts.query_input", opts.query_input)
355-
const memories = this.db.prepare(sql).all(
341+
SELECT
342+
embedding,
343+
0 as levenshtein_score -- Using 0 as placeholder score
344+
FROM memories
345+
WHERE type = ?
346+
AND json_extract(content, '$.' || ? || '.' || ?) IS NOT NULL
347+
LIMIT ?
348+
`;
349+
350+
const params = [
356351
opts.query_table_name,
357-
new Float32Array(opts.query_input.split(",").map(Number)), // Convert string to Float32Array
358-
opts.query_input,
359-
new Float32Array(opts.query_input.split(",").map(Number))
360-
) as Memory[];
352+
opts.query_field_name,
353+
opts.query_field_sub_name,
354+
opts.query_match_count
355+
];
361356

362-
return memories.map((memory) => ({
363-
embedding: Array.from(
364-
new Float32Array(memory.embedding as unknown as Buffer)
365-
), // Convert Buffer to number[]
366-
levenshtein_score: 0,
357+
const rows = this.db.prepare(sql).all(...params);
358+
359+
return rows.map((row) => ({
360+
embedding: row.embedding,
361+
levenshtein_score: 0
367362
}));
368363
}
369364

packages/agent/src/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,12 @@ const startAgents = async () => {
280280

281281
function chat() {
282282
const agentId = characters[0].name ?? "Agent";
283-
rl.question("You: ", (input) => handleUserInput(input, agentId));
283+
rl.question("You: ", async (input) => {
284+
await handleUserInput(input, agentId);
285+
if (input.toLowerCase() !== "exit") {
286+
chat(); // Loop back to ask another question
287+
}
288+
});
284289
}
285290

286291
console.log("Chat started. Type 'exit' to quit.");
@@ -298,6 +303,7 @@ const rl = readline.createInterface({
298303
});
299304

300305
async function handleUserInput(input, agentId) {
306+
console.log("handleUserInput", input, agentId);
301307
if (input.toLowerCase() === "exit") {
302308
rl.close();
303309
return;

packages/client-auto/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"dependencies": {
88
"@ai16z/eliza": "workspace:*",
99
"@ai16z/plugin-image-generation": "workspace:*",
10+
"@ai16z/plugin-solana": "workspace:*",
1011
"@types/body-parser": "1.19.5",
1112
"@types/cors": "2.8.17",
1213
"@types/express": "5.0.0",

packages/client-auto/src/index.ts

+46-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,65 @@
1-
import {
2-
Client,
3-
IAgentRuntime
4-
} from "@ai16z/eliza/src/types.ts";
5-
1+
import { Client, IAgentRuntime } from "@ai16z/eliza/src/types.ts";
2+
import { TrustScoreManager } from "@ai16z/plugin-solana/src/providers/trustScoreProvider.ts";
3+
import { TokenProvider } from "@ai16z/plugin-solana/src/providers/token.ts";
4+
import { WalletProvider } from "@ai16z/plugin-solana/src/providers/wallet.ts";
5+
import { TrustScoreDatabase } from "@ai16z/plugin-solana/src/adapters/trustScoreDatabase.ts";
6+
import { Connection, PublicKey } from "@solana/web3.js";
67

78
export class AutoClient {
89
interval: NodeJS.Timeout;
910
runtime: IAgentRuntime;
11+
trustScoreProvider: TrustScoreManager;
12+
walletProvider: WalletProvider;
1013

1114
constructor(runtime: IAgentRuntime) {
1215
this.runtime = runtime;
13-
// start a loop that runs every x seconds
14-
this.interval = setInterval(() => {
15-
this.makeTrades();
16-
}, 60 * 60 * 1000); // 1 hour in milliseconds
1716

17+
const trustScoreDb = new TrustScoreDatabase(runtime.databaseAdapter.db);
18+
this.trustScoreProvider = new TrustScoreManager(null, trustScoreDb);
19+
this.walletProvider = new WalletProvider(
20+
new Connection(runtime.getSetting("RPC_URL")),
21+
new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY"))
22+
);
23+
24+
// start a loop that runs every x seconds
25+
this.interval = setInterval(
26+
async () => {
27+
await this.makeTrades();
28+
},
29+
60 * 60 * 1000
30+
); // 1 hour in milliseconds
1831
}
1932

20-
makeTrades() {
33+
async makeTrades() {
2134
console.log("Running auto loop");
2235

2336
// malibu todos
37+
const startDate = new Date(new Date().getTime() - 60 * 60 * 1000);
38+
const endDate = new Date();
39+
// get recommendations from the last hour (or whatever time period we want) in order desc by trust score
40+
const recommendations =
41+
await this.trustScoreProvider.getRecommendations(
42+
startDate,
43+
endDate
44+
);
2445
// get high trust recommendations
46+
const highTrustRecommendations = recommendations.filter(
47+
(r) => r.averageTrustScore > 0.7
48+
);
2549

2650
// get information for all tokens which were recommended
51+
const tokenInfos = highTrustRecommendations.map(
52+
async (highTrustRecommendation) => {
53+
const tokenProvider = new TokenProvider(
54+
highTrustRecommendation.tokenAddress,
55+
this.walletProvider
56+
);
57+
const tokenInfo = await tokenProvider.getProcessedTokenData();
58+
const shouldTrade = await tokenProvider.shouldTradeToken();
59+
return { tokenInfo, shouldTrade };
60+
}
61+
);
62+
2763
// get any additional information we might need
2864
// make sure we're looking at the right tokens and data
2965

packages/client-twitter/src/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ class TwitterAllClient {
99
interaction: TwitterInteractionClient;
1010
constructor(runtime: IAgentRuntime) {
1111
this.post = new TwitterPostClient(runtime);
12-
this.search = new TwitterSearchClient(runtime);
12+
// this.search = new TwitterSearchClient(runtime); // don't start the search client by default
13+
// this searches topics from character file, but kind of violates consent of random users
14+
// burns your rate limit and can get your account banned
15+
// use at your own risk
1316
this.interaction = new TwitterInteractionClient(runtime);
1417
}
1518
}

packages/core/src/defaultCharacter.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ export const defaultCharacter: Character = {
44
name: "Eliza",
55
plugins: [],
66
clients: [],
7-
modelProvider: ModelProviderName.LLAMALOCAL,
7+
modelProvider: ModelProviderName.OPENAI,
88
settings: {
9-
secrets: {},
9+
secrets: {
10+
},
1011
voice: {
1112
model: "en_US-hfc_female-medium",
1213
},

0 commit comments

Comments
 (0)