Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
58bbf56
Add plugin-data-enrich
BitPodAI Dec 5, 2024
558eee3
Update the DataEnrich & Add API
BitPodAI Dec 6, 2024
911fed1
Update the prompt for token chat
BitPodAI Dec 6, 2024
92bba14
Add post function & fix bugs.
BitPodAI Dec 10, 2024
9b91b86
feat: init project
anthhub Dec 16, 2024
3757ad0
feat: create AgentConfig
anthhub Dec 16, 2024
b648e18
feat: twitter login
anthhub Dec 16, 2024
d4fd038
Remove unused file
BitPodAI Dec 18, 2024
d1db1e0
Feature AgentNetwork: add libp2p
BitPodAI Dec 18, 2024
95c3069
Update the InferMsg Interface
BitPodAI Dec 20, 2024
8acdadf
Add style/kol/watch interface
BitPodAI Dec 20, 2024
0d0a0b5
createSolTransferTransaction
anthhub Dec 20, 2024
d3f23bf
Routes
anthhub Dec 21, 2024
68e093c
create_agent
anthhub Dec 21, 2024
f7bd699
Add more functions
BitPodAI Dec 21, 2024
6a576d9
add status
anthhub Dec 22, 2024
7c9bd1a
userId
anthhub Dec 22, 2024
ff00f23
handleConfigQuery
anthhub Dec 22, 2024
8ab1f06
handleWatchText
anthhub Dec 22, 2024
7658abf
handleConfigQuery
anthhub Dec 22, 2024
776435c
handleChat
anthhub Dec 22, 2024
33163c0
handleChat
anthhub Dec 22, 2024
d59c24b
handleChat
anthhub Dec 22, 2024
a5ee9a7
Issue investment
BitPodAI Dec 23, 2024
bd3c864
Fix the watch list issue.
BitPodAI Dec 23, 2024
80a598b
agentConfig
anthhub Dec 23, 2024
bc10f21
handleSolTransfer
anthhub Dec 23, 2024
5ad0e55
POST_IMMEDIATELY
anthhub Dec 23, 2024
6634242
Add SolanaAgentKit API
BitPodAI Dec 24, 2024
1182bfe
sendTweet
anthhub Dec 24, 2024
20fdb7b
tweetData text
anthhub Dec 24, 2024
7d1be72
handleSolTransfer
anthhub Dec 24, 2024
d8f22ae
Update the watch instruction
BitPodAI Dec 25, 2024
42e56cc
Update watch list text
BitPodAI Dec 25, 2024
caac991
Refine Watcher
BitPodAI Dec 25, 2024
d3ddc55
Add Qwen Model
BitPodAI Dec 25, 2024
df44200
Revert "Add Qwen Model"
BitPodAI Dec 26, 2024
05f5451
Refine Watcher
BitPodAI Dec 26, 2024
227cc78
Add Twitter OAuth2.0
BitPodAI Jan 4, 2025
45b6e30
Update the keyword
BitPodAI Jan 6, 2025
35e552b
Update the agent name
BitPodAI Jan 7, 2025
3bdd703
Update Watch List
BitPodAI Jan 10, 2025
ab7e177
Add twitter search
BitPodAI Jan 11, 2025
f46f1af
Create userprofile
BitPodAI Jan 11, 2025
c2ad4e9
Add token enrich
BitPodAI Jan 12, 2025
32b90f0
fix: Fix build error
waite1x Jan 12, 2025
5fd41a9
Merge branch 'dev' of https://github.com/BitPodAI/FungIPle into dev
waite1x Jan 12, 2025
5f027b9
Add UserManager
BitPodAI Jan 12, 2025
1bc14d0
Update build depend
BitPodAI Jan 12, 2025
2dafd5e
Add verify privy token
waite1x Jan 12, 2025
c84252a
Merge branch 'dev' of https://github.com/BitPodAI/FungIPle into dev
waite1x Jan 12, 2025
16e70c3
Add isWatched field
BitPodAI Jan 12, 2025
d9cbc5d
Update isWatched
BitPodAI Jan 13, 2025
bd8c4b2
Add watch list config function
BitPodAI Jan 13, 2025
96fc3f3
Add guest support.
ykai2 Jan 13, 2025
37892f7
Bug Fix
BitPodAI Jan 13, 2025
d29e349
Add personalized Twitter style.
ykai2 Jan 13, 2025
2ce3fb5
Merge branch 'dev' of https://github.com/BitPodAI/FungIPle into local…
ykai2 Jan 13, 2025
3f4bf3c
Add watchlist per user
BitPodAI Jan 14, 2025
2faa679
Bug Fix
BitPodAI Jan 14, 2025
24d3fb9
Fix watch list bug.
ykai2 Jan 14, 2025
922d112
Refine
BitPodAI Jan 14, 2025
c7b4733
Forward the shared content to Twitter.
ykai2 Jan 15, 2025
570d3d7
Merge branch 'dev' of https://github.com/BitPodAI/FungIPle into local…
ykai2 Jan 15, 2025
6713510
Share msg content to Twitter.
Jan 15, 2025
e7a72b5
Add TwOAuth Revoke
BitPodAI Jan 15, 2025
6dda3b4
Hide some style
BitPodAI Jan 16, 2025
41c24a2
Adjust the data structure of sending Twitter data.
Jan 16, 2025
dfa24fb
Merge branch 'dev' of https://github.com/BitPodAI/FungIPle into dev
Jan 16, 2025
d3b6904
Increase the user experience.
Jan 16, 2025
a4e862d
Add translate api.
Jan 17, 2025
b9fab2f
Bug fix
BitPodAI Jan 17, 2025
8a121dd
Update the watch date format
BitPodAI Jan 18, 2025
39ab833
Add more fetchTweet methods.
BitPodAI Jan 18, 2025
7e013bf
Add debug info.
Jan 18, 2025
c9edfb9
Merge branch 'dev' of https://github.com/BitPodAI/FungIPle into dev
Jan 18, 2025
4d17ab8
Add debug info for Sending Twitter.
Jan 18, 2025
4c13cd3
Disable debug flag
BitPodAI Jan 18, 2025
557534c
feat: Add memo api
waite1x Jan 18, 2025
bb4d601
fix : Update memo.http
waite1x Jan 18, 2025
fb41597
fix: Add parseToken middleware
waite1x Jan 18, 2025
b33cb2a
fix: Fix parse token
waite1x Jan 18, 2025
858effe
Fix bugs for watchlist empty
BitPodAI Jan 18, 2025
4fdfe3a
Delete un-used
BitPodAI Jan 18, 2025
ecd68c3
Bug Fix for createAgent Issue
BitPodAI Jan 19, 2025
c174347
Update the watch interval to 15mins
BitPodAI Jan 20, 2025
b581375
Remove un-used
BitPodAI Jan 20, 2025
04a0c0c
Add the following change feature
BitPodAI Jan 22, 2025
1de017d
Fix bugs
BitPodAI Jan 22, 2025
bf968a2
Bug fixs for following change
BitPodAI Jan 22, 2025
8996cf2
Issue fix: remove '@'
BitPodAI Jan 23, 2025
d0b44da
Bug fix
BitPodAI Jan 23, 2025
64440e1
Gain reward.
ykai2 Jan 24, 2025
054132d
Fix solana web3 issue.
BitPodAI Jan 24, 2025
0d76ce0
Add the sol token transfer
BitPodAI Jan 25, 2025
ad91334
Build error
BitPodAI Jan 25, 2025
277cb00
Fix bug fix
BitPodAI Jan 25, 2025
63d14db
Add solana agent kit
BitPodAI Jan 25, 2025
6360429
Update Sol Spl
BitPodAI Jan 25, 2025
12ef20d
Bug fix for solanaspl
BitPodAI Jan 26, 2025
ece3721
Update the watch
BitPodAI Jan 27, 2025
8e8284f
Add env to env.example
BitPodAI Jan 27, 2025
3b11158
Sol-SPL functions
BitPodAI Feb 5, 2025
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
50 changes: 50 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ TWITTER_EMAIL= # Account email
TWITTER_2FA_SECRET=
TWITTER_COOKIES= # Account cookies
TWITTER_POLL_INTERVAL=120 # How often (in seconds) the bot should check for interactions
POST_IMMEDIATELY=1 # Default: false

X_SERVER_URL=
XAI_API_KEY=
XAI_MODEL=



# Post Interval Settings (in minutes)
POST_INTERVAL_MIN= # Default: 90
POST_INTERVAL_MAX= # Default: 180
Expand Down Expand Up @@ -189,3 +193,49 @@ INTERNET_COMPUTER_ADDRESS=
# Aptos
APTOS_PRIVATE_KEY= # Aptos private key
APTOS_NETWORK= # must be one of mainnet, testnet


MY_APP_URL=https://web3agent.site/dev

TAVILY_API_KEY=
PRIVY_APP_ID=
PRIVY_APP_SECRET=

# Web3Agent Watcher KOL
TW_KOL_LIST=`[
"elonmusk",
"cz_binance",
"aeyakovenko",
"jessepollak",
"shawmakesmagic",
"everythingempt0"
]`
TW_KOL_LIST_MORE=`[
"JoshRMeier",
"coinbureau"
]`

# Web3Agent Watcher
AGENT_WATCHER_INSTRUCTION='
Please find the following data according to the text provided in the following format:
(1) Token Symbol by json name "token";
(2) Token Interaction Information by json name "interact";
(3) Token Interaction Count by json name "count";
(4) Token Key Event Description by json name "event".
The detail information of each item as following:
The (1) item is the token/coin/meme name involved in the text provided.
The (2) item include the interactions(mention/like/comment/repost/post/reply) between each token/coin/meme and the twitter account, the output is "@somebody mention/like/comment/repost/post/reply @token, @someone post @token, etc."; providing at most 2 interactions is enough.
The (3) item is the data of the count of interactions between each token and the twitter account.
The (4) item is the about 30 words description of the key event for each token/coin/meme. If the description is too short, please attach the tweets.
Please skip the top token, such as btc, eth, sol, base, bnb.
Use the list format and only provide these 4 pieces of information.'

AGENT_WATCHER_INSTRUCTION_0='
Please find the token/project involved according to the text provided, and obtain the data of the number of interactions between each token and the three category of accounts (mentions/likes/comments/reposts/posts) in the tweets related to these tokens; mark the tokens as category 1, category 2 or category 3; if there are both category 1 and category 2, choose category 1, which has a higher priority.
And provide the brief introduction of the key event for each token. And also skip the top/famous tokens.
Please reply in English and in the following format:
- Token Symbol by json name "token";
- Token Interaction Category by json name "category";
- Token Interaction Count by json name "count";
- Token Key Event Introduction by json name "event";
Use the list format and only provide these 4 pieces of information.'
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@ai16z/plugin-solana": "workspace:*",
"@ai16z/plugin-starknet": "workspace:*",
"@ai16z/plugin-tee": "workspace:*",
"@ai16z/plugin-data-enrich": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
Expand Down
126 changes: 122 additions & 4 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ICacheManager,
IDatabaseAdapter,
IDatabaseCacheAdapter,
Memory,
ModelProviderName,
defaultCharacter,
elizaLogger,
Expand All @@ -26,6 +27,7 @@ import {
import { zgPlugin } from "@ai16z/plugin-0g";
import { goatPlugin } from "@ai16z/plugin-goat";
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
import { dataEnrichPlugin } from "@ai16z/plugin-data-enrich";
// import { buttplugPlugin } from "@ai16z/plugin-buttplug";
import {
coinbaseCommercePlugin,
Expand All @@ -47,6 +49,28 @@ import readline from "readline";
import { fileURLToPath } from "url";
import yargs from "yargs";

export interface AgentConfig {
prompt: string;
name: string;
clients: string[];
modelProvider: string;
bio: string[];
lore?: string[];
knowledge?: string[];
topics?: string[];
style?: {
all: string[];
chat: string[];
post: string[];
};
adjectives?: string[];
x: {
username: string;
email: string;
password: string;
};
}

const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory

Expand Down Expand Up @@ -365,7 +389,8 @@ export function createAgent(
evaluators: [],
character,
plugins: [
bootstrapPlugin,
//bootstrapPlugin,
dataEnrichPlugin,
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
? confluxPlugin
: null,
Expand Down Expand Up @@ -417,7 +442,12 @@ function intializeDbCache(character: Character, db: IDatabaseCacheAdapter) {
return cache;
}

async function startAgent(character: Character, directClient) {
async function startAgent(
character: Character,
directClient,
config?: AgentConfig,
memory?: Memory
) {
let db: IDatabaseAdapter & IDatabaseCacheAdapter;
try {
character.id ??= stringToUuid(character.name);
Expand All @@ -434,16 +464,22 @@ async function startAgent(character: Character, directClient) {
IDatabaseCacheAdapter;

await db.init();
db.setCache({
agentId: character.id,
key: "agentConfig",
value: JSON.stringify(config),
});

const cache = intializeDbCache(character, db);
const runtime = createAgent(character, db, cache, token);

await runtime.initialize();

const clients = await initializeClients(character, runtime);

directClient.registerAgent(runtime);

// 初始化 agent client
const clients = await initializeClients(character, runtime);

return clients;
} catch (error) {
elizaLogger.error(
Expand All @@ -470,6 +506,88 @@ const startAgents = async () => {
characters = await loadCharacters(charactersArg);
}

// @ts-ignore
directClient.registerCallback(
async (config: AgentConfig, memory: Memory) => {
// 动态启动 Agent
const characters0 = { ...characters?.[0] };

// 需要处理的字段列表
const arrayFields = [
"bio",
"lore",
"style",
"knowledge",
"adjectives",
] as const;

// 统一处理数组字段
arrayFields.forEach((field) => {
const value = config?.[field];
if (field === "style") {
// 特殊处理 style 字段
let styles: string[] = [];
if (typeof value === "string") {
styles = value
// @ts-ignore
?.split(",")
.map((s) => s.trim())
.filter(Boolean);
} else if (Array.isArray(value)) {
styles = value.filter(Boolean);
}
if (styles.length > 0) {
characters0[field] = {
all: styles,
chat: styles,
post: styles,
};
}
} else {
// 处理其他数组字段
if (value && typeof value === "string") {
// 处理非空字符串
// @ts-ignore
const trimmed = value?.trim();
if (trimmed) {
characters0[field] = trimmed
.split(",")
.map((str) => str.trim())
.filter(Boolean);
}
} else if (Array.isArray(value)) {
// 处理数组,过滤掉空值
characters0[field] = value.filter(Boolean);
}
}
});

// 处理普通字段
if (config?.name) {
characters0.name = config.name || config.x.username;
}

const character = {
...characters?.[0],
// 排除 Twitter 凭证
x: undefined,
};

character.settings.secrets = {
...character.settings.secrets,
TWITTER_USERNAME: config?.x?.username,
TWITTER_PASSWORD: config?.x?.password,
TWITTER_EMAIL: config?.x?.email,
POST_IMMEDIATELY: "1",
AGENT_PROMPT: config?.prompt,
};

await startAgent(character, directClient, config, memory);

console.log("req.params registerCallbackFn character:", character);
}
);

try {
for (const character of characters) {
await startAgent(character, directClient);
Expand Down
Loading
Loading