Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable trust provider for PostGres db #1536

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading