Skip to content

Commit

Permalink
Merge branch 'develop' into zksync-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
9547 authored Jan 3, 2025
2 parents eefe2b8 + 6c388cd commit 6ff76f1
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 52 deletions.
20 changes: 5 additions & 15 deletions packages/adapter-postgres/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,11 @@ export class PostgresDatabaseAdapter
await client.query("SET app.use_gaianet_embedding = 'false'");
}

// Check if schema already exists (check for a core table)
const { rows } = await client.query(`
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_name = 'rooms'
);
`);

if (!rows[0].exists) {
const schema = fs.readFileSync(
path.resolve(__dirname, "../schema.sql"),
"utf8"
);
await client.query(schema);
}
const schema = fs.readFileSync(
path.resolve(__dirname, "../schema.sql"),
"utf8"
);
await client.query(schema);

await client.query("COMMIT");
} catch (error) {
Expand Down
23 changes: 15 additions & 8 deletions packages/plugin-solana/src/evaluators/trust.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import {
ActionExample,
booleanFooter,
composeContext,
Content,
elizaLogger,
Evaluator,
generateObjectArray,
generateTrueOrFalse,
MemoryManager,
booleanFooter,
ActionExample,
Content,
IAgentRuntime,
Memory,
MemoryManager,
ModelClass,
Evaluator,
} from "@elizaos/core";
import { TrustScoreManager } from "../providers/trustScoreProvider.ts";
import { TokenProvider } from "../providers/token.ts";
import { WalletProvider } from "../providers/wallet.ts";
import { TrustScoreDatabase } from "@elizaos/plugin-trustdb";
import { Connection } from "@solana/web3.js";
import { getWalletKey } from "../keypairUtils.ts";
import { TokenProvider } from "../providers/token.ts";
import { TrustScoreManager } from "../providers/trustScoreProvider.ts";
import { WalletProvider } from "../providers/wallet.ts";

const shouldProcessTemplate =
`# Task: Decide if the recent messages should be processed for token recommendations.
Expand Down Expand Up @@ -82,6 +83,12 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
console.log("Evaluating for trust");
const state = await runtime.composeState(message);

// if the database type is postgres, we don't want to run this because it relies on sql queries that are currently specific to sqlite. This check can be removed once the trust score provider is updated to work with postgres.
if (runtime.getSetting("POSTGRES_URL")) {
elizaLogger.warn("skipping trust evaluator because db is postgres");
return [];
}

const { agentId, roomId } = state;

// Check if we should process the messages
Expand Down
39 changes: 23 additions & 16 deletions packages/plugin-solana/src/providers/trustScoreProvider.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import {
ProcessedTokenData,
TokenSecurityData,
// TokenTradeData,
// DexScreenerData,
// DexScreenerPair,
// HolderData,
} from "../types/token.ts";
import { Connection, PublicKey } from "@solana/web3.js";
import { getAssociatedTokenAddress } from "@solana/spl-token";
import { TokenProvider } from "./token.ts";
import { WalletProvider } from "./wallet.ts";
import { SimulationSellingService } from "./simulationSellingService.ts";
elizaLogger,
IAgentRuntime,
Memory,
Provider,
settings,
State,
} from "@elizaos/core";
import {
TrustScoreDatabase,
RecommenderMetrics,
TokenPerformance,
TradePerformance,
TokenRecommendation,
TradePerformance,
TrustScoreDatabase,
} from "@elizaos/plugin-trustdb";
import { settings } from "@elizaos/core";
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
import { getAssociatedTokenAddress } from "@solana/spl-token";
import { Connection, PublicKey } from "@solana/web3.js";
import { v4 as uuidv4 } from "uuid";
import { ProcessedTokenData, TokenSecurityData } from "../types/token.ts";
import { SimulationSellingService } from "./simulationSellingService.ts";
import { TokenProvider } from "./token.ts";
import { WalletProvider } from "./wallet.ts";

const Wallet = settings.MAIN_WALLET_ADDRESS;
interface TradeData {
Expand Down Expand Up @@ -702,6 +701,14 @@ export const trustScoreProvider: Provider = {
_state?: State
): Promise<string> {
try {
// if the database type is postgres, we don't want to run this evaluator because it relies on sql queries that are currently specific to sqlite. This check can be removed once the trust score provider is updated to work with postgres.
if (runtime.getSetting("POSTGRES_URL")) {
elizaLogger.warn(
"skipping trust evaluator because db is postgres"
);
return "";
}

const trustScoreDb = new TrustScoreDatabase(
runtime.databaseAdapter.db
);
Expand Down
33 changes: 20 additions & 13 deletions packages/plugin-starknet/src/providers/trustScoreProvider.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import {
ProcessedTokenData,
TokenSecurityData,
// TokenTradeData,
// DexScreenerData,
// DexScreenerPair,
// HolderData,
} from "../types/trustDB.ts";
import { ProcessedTokenData, TokenSecurityData } from "../types/trustDB.ts";
// import { Connection, PublicKey } from "@solana/web3.js";
// import { getAssociatedTokenAddress } from "@solana/spl-token";
// import { TokenProvider } from "./token.ts";
import { WalletProvider } from "./walletProvider.ts";
import {
TrustScoreDatabase,
elizaLogger,
IAgentRuntime,
Memory,
Provider,
settings,
State,
} from "@elizaos/core";
import {
RecommenderMetrics,
TokenPerformance,
TradePerformance,
TokenRecommendation,
TradePerformance,
TrustScoreDatabase,
} from "@elizaos/plugin-trustdb";
import { settings } from "@elizaos/core";
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
import { getTokenBalance } from "../utils/index.ts";
import { TokenProvider } from "./token.ts";
import { WalletProvider } from "./walletProvider.ts";

const _Wallet = settings.MAIN_WALLET_ADDRESS;
interface TradeData {
Expand Down Expand Up @@ -607,6 +606,14 @@ export const trustScoreProvider: Provider = {
_state?: State
): Promise<string> {
try {
// if the database type is postgres, we don't want to run this evaluator because it relies on sql queries that are currently specific to sqlite. This check can be removed once the trust score provider is updated to work with postgres.
if (runtime.getSetting("POSTGRES_URL")) {
elizaLogger.warn(
"skipping trust evaluator because db is postgres"
);
return "";
}

const trustScoreDb = new TrustScoreDatabase(
runtime.databaseAdapter.db
);
Expand Down

0 comments on commit 6ff76f1

Please sign in to comment.