Skip to content

Commit

Permalink
Merge branch 'hfi' of https://github.com/odilitime/eliza into hfi
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime committed Jan 8, 2025
2 parents c51a81e + 4e2dff2 commit 542e098
Show file tree
Hide file tree
Showing 37 changed files with 2,512 additions and 678 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ STORY_API_BASE_URL= # Story API base URL
STORY_API_KEY= # Story API key
PINATA_JWT= # Pinata JWT for uploading files to IPFS

# Cosmos
COSMOS_RECOVERY_PHRASE= # 12 words recovery phrase (need to be in quotes, because of spaces)
COSMOS_AVAILABLE_CHAINS= # mantrachaintestnet2,cosmos # Array of chains
# Cronos zkEVM
CRONOSZKEVM_ADDRESS=
CRONOSZKEVM_PRIVATE_KEY=
Expand Down
2 changes: 1 addition & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@elizaos/plugin-binance": "workspace:*",
"@elizaos/plugin-avail": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@ai16z/plugin-cosmos": "workspace:*",
"@elizaos/plugin-cosmos": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-coinprice": "workspace:*",
Expand Down
10 changes: 8 additions & 2 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { confluxPlugin } from "@elizaos/plugin-conflux";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { evmPlugin } from "@elizaos/plugin-evm";
import { createCosmosPlugin } from "@elizaos/plugin-cosmos";
import { flowPlugin } from "@elizaos/plugin-flow";
import { fuelPlugin } from "@elizaos/plugin-fuel";
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
Expand Down Expand Up @@ -375,7 +376,7 @@ export function getTokenForProvider(
}
}

async function initializeDatabase(dataDir: string) {
function initializeDatabase(dataDir: string) {
if (process.env.POSTGRES_URL) {
elizaLogger.info("Initializing PostgreSQL connection...");
const db = new PostgresDatabaseAdapter({
Expand Down Expand Up @@ -587,6 +588,9 @@ export async function createAgent(
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
? evmPlugin
: null,
getSecret(character, "COSMOS_RECOVERY_PHRASE") &&
getSecret(character, "COSMOS_AVAILABLE_CHAINS") &&
createCosmosPlugin(),
(getSecret(character, "SOLANA_PUBLIC_KEY") ||
(getSecret(character, "WALLET_PUBLIC_KEY") &&
!getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith(
Expand Down Expand Up @@ -769,9 +773,11 @@ async function startAgent(
fs.mkdirSync(dataDir, { recursive: true });
}

db = (await initializeDatabase(dataDir)) as IDatabaseAdapter &
db = initializeDatabase(dataDir) as IDatabaseAdapter &
IDatabaseCacheAdapter;

await db.init();

const cache = initializeCache(
process.env.CACHE_STORE ?? CacheStore.DATABASE,
character,
Expand Down
36 changes: 10 additions & 26 deletions characters/cosmosHelper.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
"clients": [],
"modelProvider": "groq",
"settings": {
"secrets": {},
"voice": {
"model": "en_US-male-medium"
},
"chains": {
"cosmos": ["axelar", "carbon", "mantrachaintestnet2"]
}
},
"plugins": ["@ai16z/plugin-cosmos","@ai16z/plugin-bootstrap"],
"plugins": [],
"bio": [
"Expert in Cosmos ecosystem.",
"Knowledgeable in CosmWasm and Stargate.",
Expand All @@ -24,37 +23,22 @@
"Supports projects and interactions within the Cosmos ecosystem."
],
"knowledge": [
"knows EXACT cost to families under Kamala ($29,000)",
"understands REAL border numbers (worse than reported)",
"saw what really happened in Minneapolis 2020",
"remembers who begged for help (and when)",
"knows why Iran's president targeting us",
"understands Secret Service allocation (and why they do it)",
"knows REAL rally numbers (they hide them)",
"saw the TRUTH about China Virus response",
"understands states' rights better than anyone",
"knows why they're letting in illegal guns",
"remembers when America was AFFORDABLE",
"understands the REAL election interference",
"knows why they're scared of WorldLibertyFi",
"saw what they did to women's sports",
"understands the REAL Middle East situation",
"knows why missiles flying everywhere now",
"remembers perfect peace under Trump presidency",
"understands Democrat election strategy (letting in MILLIONS)",
"knows Kamala's REAL tax plans (coming for everything)",
"saw what they did to Minneapolis (and other cities)"
"Knows how Cosmos blockchain works",
"Knows what actions should he call for token transfer, swapping or bridging",
"Knows that users might want to do specific actions multiple times and should help them by doing it again.",
"Should always ask for confirmation before calling an COSMOS_TRANSFER, COSMOS_BRIDGE, COSMOS_SWAP actions.",
"Should call actions COSMOS_TRANSFER, COSMOS_BRIDGE, COSMOS_SWAP only after previous confirmation."
],
"messageExamples": [
[
{
"user": "{{user1}}",
"content": { "text": "Can you explain the Cosmos Hub?" }
"content": { "text": "Show my balances of my wallet on {{mantrachaintestnet2}}" }
},
{
"user": "CosmosHelper",
"content": {
"text": "The Cosmos Hub is the central blockchain in the Cosmos ecosystem, facilitating interoperability between connected blockchains."
"text": "Your balances on chain {{mantrachaintestnet2}} are: \n - 13456.124 OM\n - 1222 ONDO\n 0.122122 USDY"
}
}
],
Expand Down Expand Up @@ -97,12 +81,12 @@
[
{
"user": "{{user1}}",
"content": { "text": "What are validators?" }
"content": { "text": "Make transfer 0.0001 OM to mantra13248w8dtnn07sxc3gq4l3ts4rvfyat6fks0ecj on mantrachaintestnet2" }
},
{
"user": "CosmosHelper",
"content": {
"text": "Validators are responsible for securing the network by validating transactions and producing new blocks. They earn rewards through staking."
"text": "Sure, your transfer i being processed."
}
}
]
Expand Down
92 changes: 51 additions & 41 deletions packages/client-twitter/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ Thread of Tweets You Are Replying To:
export class TwitterInteractionClient {
client: ClientBase;
runtime: IAgentRuntime;
private isDryRun: boolean;
constructor(client: ClientBase, runtime: IAgentRuntime) {
this.client = client;
this.runtime = runtime;
this.isDryRun = this.client.twitterConfig.TWITTER_DRY_RUN;
}

async start() {
Expand Down Expand Up @@ -430,54 +432,62 @@ export class TwitterInteractionClient {
response.text = removeQuotes(response.text);

if (response.text) {
try {
const callback: HandlerCallback = async (response: Content) => {
const memories = await sendTweet(
this.client,
response,
message.roomId,
this.client.twitterConfig.TWITTER_USERNAME,
tweet.id
);
return memories;
};
if (this.isDryRun) {
elizaLogger.info(
`Dry run: Selected Post: ${tweet.id} - ${tweet.username}: ${tweet.text}\nAgent's Output:\n${response.text}`
);
} else {
try {
const callback: HandlerCallback = async (
response: Content
) => {
const memories = await sendTweet(
this.client,
response,
message.roomId,
this.client.twitterConfig.TWITTER_USERNAME,
tweet.id
);
return memories;
};

const responseMessages = await callback(response);
const responseMessages = await callback(response);

state = (await this.runtime.updateRecentMessageState(
state
)) as State;
state = (await this.runtime.updateRecentMessageState(
state
)) as State;

for (const responseMessage of responseMessages) {
if (
responseMessage ===
responseMessages[responseMessages.length - 1]
) {
responseMessage.content.action = response.action;
} else {
responseMessage.content.action = "CONTINUE";
for (const responseMessage of responseMessages) {
if (
responseMessage ===
responseMessages[responseMessages.length - 1]
) {
responseMessage.content.action = response.action;
} else {
responseMessage.content.action = "CONTINUE";
}
await this.runtime.messageManager.createMemory(
responseMessage
);
}
await this.runtime.messageManager.createMemory(
responseMessage
);
}

await this.runtime.processActions(
message,
responseMessages,
state,
callback
);
await this.runtime.processActions(
message,
responseMessages,
state,
callback
);

const responseInfo = `Context:\n\n${context}\n\nSelected Post: ${tweet.id} - ${tweet.username}: ${tweet.text}\nAgent's Output:\n${response.text}`;
const responseInfo = `Context:\n\n${context}\n\nSelected Post: ${tweet.id} - ${tweet.username}: ${tweet.text}\nAgent's Output:\n${response.text}`;

await this.runtime.cacheManager.set(
`twitter/tweet_generation_${tweet.id}.txt`,
responseInfo
);
await wait();
} catch (error) {
elizaLogger.error(`Error sending response tweet: ${error}`);
await this.runtime.cacheManager.set(
`twitter/tweet_generation_${tweet.id}.txt`,
responseInfo
);
await wait();
} catch (error) {
elizaLogger.error(`Error sending response tweet: ${error}`);
}
}
}
}
Expand Down
Loading

0 comments on commit 542e098

Please sign in to comment.