Skip to content

Commit 6c388cd

Browse files
authored
Merge pull request #1536 from swizzmagik/fix/disable-trust-provider-for-postgres
fix: disable trust provider for PostGres db
2 parents a5dc13c + a33a37a commit 6c388cd

File tree

3 files changed

+58
-37
lines changed

3 files changed

+58
-37
lines changed

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

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import {
2+
ActionExample,
3+
booleanFooter,
24
composeContext,
5+
Content,
6+
elizaLogger,
7+
Evaluator,
38
generateObjectArray,
49
generateTrueOrFalse,
5-
MemoryManager,
6-
booleanFooter,
7-
ActionExample,
8-
Content,
910
IAgentRuntime,
1011
Memory,
12+
MemoryManager,
1113
ModelClass,
12-
Evaluator,
1314
} from "@elizaos/core";
14-
import { TrustScoreManager } from "../providers/trustScoreProvider.ts";
15-
import { TokenProvider } from "../providers/token.ts";
16-
import { WalletProvider } from "../providers/wallet.ts";
1715
import { TrustScoreDatabase } from "@elizaos/plugin-trustdb";
1816
import { Connection } from "@solana/web3.js";
1917
import { getWalletKey } from "../keypairUtils.ts";
18+
import { TokenProvider } from "../providers/token.ts";
19+
import { TrustScoreManager } from "../providers/trustScoreProvider.ts";
20+
import { WalletProvider } from "../providers/wallet.ts";
2021

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

86+
// 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.
87+
if (runtime.getSetting("POSTGRES_URL")) {
88+
elizaLogger.warn("skipping trust evaluator because db is postgres");
89+
return [];
90+
}
91+
8592
const { agentId, roomId } = state;
8693

8794
// Check if we should process the messages

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

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
import {
2-
ProcessedTokenData,
3-
TokenSecurityData,
4-
// TokenTradeData,
5-
// DexScreenerData,
6-
// DexScreenerPair,
7-
// HolderData,
8-
} from "../types/token.ts";
9-
import { Connection, PublicKey } from "@solana/web3.js";
10-
import { getAssociatedTokenAddress } from "@solana/spl-token";
11-
import { TokenProvider } from "./token.ts";
12-
import { WalletProvider } from "./wallet.ts";
13-
import { SimulationSellingService } from "./simulationSellingService.ts";
2+
elizaLogger,
3+
IAgentRuntime,
4+
Memory,
5+
Provider,
6+
settings,
7+
State,
8+
} from "@elizaos/core";
149
import {
15-
TrustScoreDatabase,
1610
RecommenderMetrics,
1711
TokenPerformance,
18-
TradePerformance,
1912
TokenRecommendation,
13+
TradePerformance,
14+
TrustScoreDatabase,
2015
} from "@elizaos/plugin-trustdb";
21-
import { settings } from "@elizaos/core";
22-
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
16+
import { getAssociatedTokenAddress } from "@solana/spl-token";
17+
import { Connection, PublicKey } from "@solana/web3.js";
2318
import { v4 as uuidv4 } from "uuid";
19+
import { ProcessedTokenData, TokenSecurityData } from "../types/token.ts";
20+
import { SimulationSellingService } from "./simulationSellingService.ts";
21+
import { TokenProvider } from "./token.ts";
22+
import { WalletProvider } from "./wallet.ts";
2423

2524
const Wallet = settings.MAIN_WALLET_ADDRESS;
2625
interface TradeData {
@@ -702,6 +701,14 @@ export const trustScoreProvider: Provider = {
702701
_state?: State
703702
): Promise<string> {
704703
try {
704+
// 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.
705+
if (runtime.getSetting("POSTGRES_URL")) {
706+
elizaLogger.warn(
707+
"skipping trust evaluator because db is postgres"
708+
);
709+
return "";
710+
}
711+
705712
const trustScoreDb = new TrustScoreDatabase(
706713
runtime.databaseAdapter.db
707714
);

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

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import {
2-
ProcessedTokenData,
3-
TokenSecurityData,
4-
// TokenTradeData,
5-
// DexScreenerData,
6-
// DexScreenerPair,
7-
// HolderData,
8-
} from "../types/trustDB.ts";
1+
import { ProcessedTokenData, TokenSecurityData } from "../types/trustDB.ts";
92
// import { Connection, PublicKey } from "@solana/web3.js";
103
// import { getAssociatedTokenAddress } from "@solana/spl-token";
114
// import { TokenProvider } from "./token.ts";
12-
import { WalletProvider } from "./walletProvider.ts";
135
import {
14-
TrustScoreDatabase,
6+
elizaLogger,
7+
IAgentRuntime,
8+
Memory,
9+
Provider,
10+
settings,
11+
State,
12+
} from "@elizaos/core";
13+
import {
1514
RecommenderMetrics,
1615
TokenPerformance,
17-
TradePerformance,
1816
TokenRecommendation,
17+
TradePerformance,
18+
TrustScoreDatabase,
1919
} from "@elizaos/plugin-trustdb";
20-
import { settings } from "@elizaos/core";
21-
import { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
2220
import { getTokenBalance } from "../utils/index.ts";
2321
import { TokenProvider } from "./token.ts";
22+
import { WalletProvider } from "./walletProvider.ts";
2423

2524
const _Wallet = settings.MAIN_WALLET_ADDRESS;
2625
interface TradeData {
@@ -607,6 +606,14 @@ export const trustScoreProvider: Provider = {
607606
_state?: State
608607
): Promise<string> {
609608
try {
609+
// 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.
610+
if (runtime.getSetting("POSTGRES_URL")) {
611+
elizaLogger.warn(
612+
"skipping trust evaluator because db is postgres"
613+
);
614+
return "";
615+
}
616+
610617
const trustScoreDb = new TrustScoreDatabase(
611618
runtime.databaseAdapter.db
612619
);

0 commit comments

Comments
 (0)