From d6273ded000535ae04999bd7e5af7f02d5bba9ca Mon Sep 17 00:00:00 2001 From: BitPod Date: Sat, 15 Feb 2025 11:47:53 +0800 Subject: [PATCH 1/9] Add avoid list for Watcher --- packages/plugin-data-enrich/src/userprofile.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/plugin-data-enrich/src/userprofile.ts b/packages/plugin-data-enrich/src/userprofile.ts index bcd1ba506c82d..e81374bb7f16d 100644 --- a/packages/plugin-data-enrich/src/userprofile.ts +++ b/packages/plugin-data-enrich/src/userprofile.ts @@ -1,4 +1,4 @@ -import { ICacheManager } from "@elizaos/core"; +import { ICacheManager, settings } from "@elizaos/core"; import { TW_KOL_1 } from "./social"; interface WatchItem { @@ -147,6 +147,7 @@ export class UserManager implements UserManageInterface { for (const kol of TW_KOL_1) { watchList.add(kol); } + const avoidList = JSON.parse(settings.TW_WATCHER_AVOID_LIST) || []; // Get All ids let idsStr = (await this.getCachedData( UserManager.ALL_USER_IDS @@ -158,6 +159,9 @@ export class UserManager implements UserManageInterface { ); if (userProfile && userProfile.twitterWatchList) { for (const watchItem of userProfile.twitterWatchList) { + if (avoidList.includes(watchItem.username)) { + continue; // skip avoid + } watchList.add(watchItem.username); } } From 9d285c5fb820da0d87323220d9e0c8a7023c2fa7 Mon Sep 17 00:00:00 2001 From: BitPod Date: Sat, 15 Feb 2025 15:19:46 +0800 Subject: [PATCH 2/9] Update watchlist count --- packages/client-direct/src/routes.ts | 5 ++++- packages/plugin-data-enrich/src/infermessage.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/client-direct/src/routes.ts b/packages/client-direct/src/routes.ts index 235bf5e8a30ee..aa353805804e6 100644 --- a/packages/client-direct/src/routes.ts +++ b/packages/client-direct/src/routes.ts @@ -1061,7 +1061,10 @@ export class Routes { userManager.saveUserData(profile); try { - const { cursor, watchlist } = req.body; + //const { cursor, watchlist } = req.body; + const { userId } = req.body; + const cursor = ""; + const watchlist = userManager.getWatchList(userId); let report; if (watchlist && watchlist.length > 0) { report = diff --git a/packages/plugin-data-enrich/src/infermessage.ts b/packages/plugin-data-enrich/src/infermessage.ts index 661d439f8c4f0..a5633a70cd009 100644 --- a/packages/plugin-data-enrich/src/infermessage.ts +++ b/packages/plugin-data-enrich/src/infermessage.ts @@ -327,7 +327,7 @@ export class InferMessageProvider { }; } - const PAGE_SIZE = 5; + const PAGE_SIZE = 30; // Initialize with first KOL's items let currentItemIndex = 0; From 2f5e756b53cd7e560b9dc522915f3c08462d475f Mon Sep 17 00:00:00 2001 From: BitPod Date: Sat, 15 Feb 2025 18:48:47 +0800 Subject: [PATCH 3/9] Expand the watchlist result --- packages/client-direct/src/routes.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/client-direct/src/routes.ts b/packages/client-direct/src/routes.ts index aa353805804e6..7cf725ea16a15 100644 --- a/packages/client-direct/src/routes.ts +++ b/packages/client-direct/src/routes.ts @@ -1064,7 +1064,8 @@ export class Routes { //const { cursor, watchlist } = req.body; const { userId } = req.body; const cursor = ""; - const watchlist = userManager.getWatchList(userId); + const watchItemList = await userManager.getWatchList(userId); + const watchlist: string[] = watchItemList.map(user => user.username); let report; if (watchlist && watchlist.length > 0) { report = @@ -1080,6 +1081,14 @@ export class Routes { cursor ); } + else if (report && report.items?.length < 10) { + let newReport = + await InferMessageProvider.getAllWatchItemsPaginated( + runtime.cacheManager, + cursor + ); + report.push(...newReport); + } } else { report = await InferMessageProvider.getAllWatchItemsPaginated( From fb73b2bf5c41f242b78b95baf6eb650a21c1e5cd Mon Sep 17 00:00:00 2001 From: BitPod Date: Sun, 16 Feb 2025 07:57:24 +0800 Subject: [PATCH 4/9] Update the tw oauth response --- packages/client-direct/src/routes.ts | 40 ++----------------- .../plugin-data-enrich/src/userprofile.ts | 3 +- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/packages/client-direct/src/routes.ts b/packages/client-direct/src/routes.ts index 7cf725ea16a15..6ae7d47336808 100644 --- a/packages/client-direct/src/routes.ts +++ b/packages/client-direct/src/routes.ts @@ -471,39 +471,12 @@ export class Routes { - FungIPle - - + Auth
-

FungIPle Agent

-
Login Success!
+
Auth Success! Redirecting...

-
- -
- -
-
-
- `); } catch (error) { diff --git a/packages/plugin-data-enrich/src/userprofile.ts b/packages/plugin-data-enrich/src/userprofile.ts index e81374bb7f16d..283a3c7c20100 100644 --- a/packages/plugin-data-enrich/src/userprofile.ts +++ b/packages/plugin-data-enrich/src/userprofile.ts @@ -144,7 +144,8 @@ export class UserManager implements UserManageInterface { async getAllWatchList(): Promise { let watchList = new Set(); - for (const kol of TW_KOL_1) { + const defaultList = JSON.parse(settings.TW_KOL_LIST) || TW_KOL_1; + for (const kol of defaultList) { watchList.add(kol); } const avoidList = JSON.parse(settings.TW_WATCHER_AVOID_LIST) || []; From 1c56e3eafc24610bfa01639ba45c1d83d780a0cc Mon Sep 17 00:00:00 2001 From: ykai2 Date: Sun, 16 Feb 2025 07:39:21 +0300 Subject: [PATCH 5/9] 1. Recommended KOLs 2. Translation upgrade 3. Watcher upgrade Signed-off-by: ykai2 --- packages/client-direct/src/routes.ts | 84 +++++++++-- packages/client-twitter/src/finder.ts | 204 ++++++++++++++++++++++++-- 2 files changed, 262 insertions(+), 26 deletions(-) diff --git a/packages/client-direct/src/routes.ts b/packages/client-direct/src/routes.ts index 6ae7d47336808..830335e52f6ef 100644 --- a/packages/client-direct/src/routes.ts +++ b/packages/client-direct/src/routes.ts @@ -219,6 +219,10 @@ export class Routes { "/:agentId/twitter_profile_search", this.handleTwitterProfileSearch.bind(this) ); + app.post( + "/:agentId/twitter_profile_kols", + this.handleTwitterProfileKols.bind(this) + ); app.post("/:agentId/re_twitter", this.handleReTwitter.bind(this)); app.post( "/:agentId/translate_text", @@ -283,6 +287,14 @@ export class Routes { ); const userManager = new UserManager(runtime.cacheManager); + + const cacheProfile = await userManager.verifyExistingUser(userId); + if(cacheProfile) { + return { + profile: cacheProfile, + }; + } + const userProfile = userManager.createDefaultProfile(userId, gmail); await userManager.saveUserData(userProfile); @@ -324,6 +336,12 @@ export class Routes { ); const userManager = new UserManager(runtime.cacheManager); + const cacheProfile = await userManager.verifyExistingUser(userId); + if(cacheProfile) { + return { + profile: cacheProfile, + }; + } const userProfile = userManager.createDefaultProfile(userId, email); await userManager.saveUserData(userProfile); @@ -601,7 +619,7 @@ export class Routes { }); } } - + async handleArenaQuery(req: express.Request, res: express.Response) { const kol = typeof req.query.username === 'string' ? req.query.username : ''; const kolname = kol.trim(); @@ -736,6 +754,43 @@ export class Routes { }); } + async handleTwitterProfileKols( + req: express.Request, + res: express.Response + ) { + return this.authUtils.withErrorHandling(req, res, async () => { + // const { username, count, userId } = req.body; + const {userId } = req.body; + //const fetchCount = Math.min(20, count); + const runtime = await this.authUtils.getRuntime(req.params.agentId); + console.log("kols handleTwitterProfileKols" + userId); + if (!userId) { + console.error("userId is empty."); + return []; + } + + try { + let profilesOutput = []; + const promise = new Promise((resolve, reject) => { + twEventCenter.on('MSG_KOLS_TWITTER_PROFILE_RESP', (data) => { + resolve(data); + }); + + // set request + twEventCenter.emit('MSG_KOLS_TWITTER_PROFILE', { }); + //console.log("Send search request"); + }); + + // wait for result + profilesOutput = await promise; + return profilesOutput; + } catch (error) { + console.error("Profile search error:", error); + return []; + } + }); + } + async handleReTwitter(req: express.Request, res: express.Response) { try { console.log("handleReTwitter"); @@ -757,22 +812,29 @@ export class Routes { async handleTranslateText(req: express.Request, res: express.Response) { try { - console.log("handleTranslateText 1"); - const { text } = req.body; - console.log("handleTranslateText 2" + text); + const {languagecode, text } = req.body; + console.log("handleTranslateText, code: " + languagecode); + console.log("handleTranslateText, text: " + text); + if(!languagecode || languagecode === "en" || languagecode.includes("en-")) { + return res.json({ + success: true, + data: {"result": text}, + }); + } + const runtime = await this.authUtils.getRuntime(req.params.agentId); const prompt = - 'You are a helpful translator. If the following text is in English, please translate it into Chinese. If it is in another language, translate it into English; The returned result only includes the translated result,The JSON structure of the returned result is: {"result":""}. The text that needs to be translated starts with [Text]. [TEXT]: ' + + 'You are a helpful translator. Please translate the following text into the language corresponding to this code: ' + languagecode + ', The returned result only includes the translated result,The JSON structure of the returned result is: {"result":""}, No need to use markdown syntax to modify JSON, just include JSON. The text that needs to be translated starts with [Text]. [TEXT]: ' + text; - //console.log("handleTranslateText 3" + prompt); + //console.log("handleTranslateText " + prompt); const response = await generateText({ runtime: runtime, context: prompt, modelClass: ModelClass.SMALL, }); - //console.log("handleTranslateText 4" + response); + //console.log("handleTranslateText " + response); if (!response) { throw new Error("No response from generateText"); @@ -1126,7 +1188,7 @@ export class Routes { const tokenAmount = 1; // tokenAmount Backend control switch (typestr) { case "sol-spl": - // Handle sol-spl transfer + // Handle sol-spl transfer try { const signature = await createSolSplTransferTransaction({ //fromTokenAccountPubkey: settings.SOL_SPL_FROM_PUBKEY, @@ -1139,7 +1201,7 @@ export class Routes { signature, data: "Sol-SPL reward processed", }); - + // Confirm the transction /*const connection = new Connection( clusterApiUrl("mainnet-beta"), @@ -1163,7 +1225,7 @@ export class Routes { } break; case "sol": - // Handle sol transfer + // Handle sol transfer try { const transaction = await createSolTransferTransaction({ fromPubkey: settings.SOL_FROM_PUBKEY, @@ -1193,7 +1255,7 @@ export class Routes { throw new ApiError(500, "Internal server error"); } case "sol-agent-kit": - // Handle sol-spl agent-kit transfer + // Handle sol-spl agent-kit transfer try { //return res.json({ // success: true, diff --git a/packages/client-twitter/src/finder.ts b/packages/client-twitter/src/finder.ts index b133bcd36cd62..bb5db62a27ab9 100644 --- a/packages/client-twitter/src/finder.ts +++ b/packages/client-twitter/src/finder.ts @@ -15,6 +15,129 @@ const TW_PROFILE_PREFIX: string = "FINDER_KEY_TW_PROFILE_PREFIX_"; export class TwitterFinderClient { client: ClientBase; runtime: IAgentRuntime; + twitterKolUsers: string[] = [ + '0xRodney', + 'Buddy', + 'DavidAirey', + 'alex_fazel', + 'JoshRMeier', + 'coinbureau', + 'lukebelmar', + 'IvanOnTech', + 'Ashcryptoreal', + 'VirtualBacon0x', + 'LadyofCrypto1', + 'milesdeutscher', + 'crypto_banter', + 'Pentosh1', + 'kyledoops', + 'MarioNawfal', + 'dingalingts', + 'rektfencer', + 'JoeParys', + 'LMECripto', + 'AltcoinDailyio', + 'ExitLiqCapital', + 'CryptoGodJohn', + 'CryptoZachLA', + 'BrianDEvans', + 'scottmelker', + 'DaanCrypto', + 'Axel_bitblaze69', + 'CryptoDaku_', + 'healthy_pockets', + 'StackerSatoshi', + 'TheCryptoLark', + 'CryptoTony__', + 'EricCryptoman', + 'noBScrypto', + 'TheDustyBC', + 'Defi_Shiller1', + 'KrugerSays', + 'Fabian', + 'boxmining', + 'Bayc364', + 'LouisCooper_', + 'AltcoinSherpa', + 'MasonVersluis', + 'megbzk', + 'AltCryptoGems', + 'resdegen', + 'docXBT', + 'cruzcontrol660', + 'BlocksNThoughts', + 'SecretoDefi', + 'PastanagaCrypto', + 'LexMorenoWeb3', + 'b_block_oficial', + 'lordjorx', + 'Haskell_Gz', + 'Overdose_AI', + 'KriptoErs', + 'thebrianjung', + 'LagoTasso', + 'MacnBTC', + 'eliz883', + '0xHustlepedia', + 'drakeondigital', + 'GarlamWON', + 'HouseOfCrypto3', + 'kyle_chasse', + 'MarioNawfal', + 'gafoorkhann', + 'senamakel', + 'Sarv_shaktiman', + 'bebetoo_cuk', + 'gametheorizing', + '0RYKER', + 'hebi555', + 'zyclw', + 'Phyrex_Ni', + 'hellosuoha', + 'Web3Nina', + '0xjuu_17', + 'visionofviii', + 'MetaHunter168', + 'vikingdao2022', + 'xiaoxin_bit', + '0xSunNFT', + '0xKillTheWolf', + 'Mumu_yay', + 'laoxue_eth', + 'jianshubiji', + 'cryp_orange', + 'zeroblocks', + 'luge517', + 'SEFATUBA3', + 'hhyjylabs', + '0xKevin00', + 'tyw1984', + '0xzhaozhao', + 'pipizhu_eth', + 'Elizabethofyou', + 'connectfarm1', + '0xcryptowizard', + 'CoinHuSays', + '0xmina_', + 'cherlyn0105', + 'Unipioneer', + 'kimyg002', + 'ROKMCFIREANT', + 'akiii345', + 'lucianlampdefi', + 'BigcoinVN', + 'SimonTran1111', + 'tuannguyenminh', + 'tobi_k300', + 'vanthucbk', + 'LisaFlorentina8', + 'danhtran68', + 'bachkhoabnb', + 'Kan_0xGemi', + 'XDeGods', + 'auksorn_' + ]; + constructor(client: ClientBase, runtime: IAgentRuntime) { this.client = client; @@ -55,6 +178,57 @@ export class TwitterFinderClient { // Send back twEventCenter.emit('MSG_SEARCH_TWITTER_PROFILE_RESP', profiles); }); + + twEventCenter.on('MSG_KOLS_TWITTER_PROFILE', async () => { + // console.log('Received message userkols:', JSON.stringify(data.kols)); + let searchResult = []; + const limitedKols = await this.getRandomUsers(this.twitterKolUsers, 16); + + // Iterate through each KOL + for (const kol of limitedKols) { + const profiles = await this.searchProfileKols(kol, 1); + if(profiles?.length > 0) { + // console.log('Received message kol: ' + kol +' profile:' + JSON.stringify(profiles[0])); + searchResult.push(profiles[0]); + } + } + // Send back + twEventCenter.emit('MSG_KOLS_TWITTER_PROFILE_RESP', searchResult); + }); + } + async getRandomUsers(users: string[], count: number): Promise { + const shuffled = [...users].sort(() => 0.5 - Math.random()); + return shuffled.slice(0, count); + } + async searchProfileKols(username: string, count: number) { + let searchResult = []; + try { + // Search from cache firstly + let cachedProfile = await this.getCachedData(username.toLowerCase()); + if (cachedProfile) { + searchResult.push(cachedProfile); + } + else { + try { + const response = await this.client.twitterClient.searchProfiles( + username, + count + ); + if (response) { + for await (const profile of response) { + // console.log('Received message searchProfile kol: ' + JSON.stringify(profile)); + searchResult.push(profile); + this.setCachedData(profile.username.toLowerCase(), profile); + } + } + } catch (error) { + console.error("Search from client error:", error); + } + } + } catch (error) { + console.error("searchProfile error:", error); + } + return searchResult; } async searchProfile(username: string, count: number, userId: string) { @@ -88,21 +262,21 @@ export class TwitterFinderClient { const alreadyWatchedList = await userManager.getWatchList(userId); const usernameSet = new Set(); - if (alreadyWatchedList) { - for (const item of alreadyWatchedList) { - const profile = { - isWatched: true, - username: item?.username, - name: item?.name, - avatar: item?.avatar, - }; - - if (item?.username) { - usernameSet.add(item.username); - } - profilesOutput.push(profile); - } - } + // if (alreadyWatchedList) { + // for (const item of alreadyWatchedList) { + // const profile = { + // isWatched: true, + // username: item?.username, + // name: item?.name, + // avatar: item?.avatar, + // }; + + // if (item?.username) { + // usernameSet.add(item.username); + // } + // profilesOutput.push(profile); + // } + // } for await (const profile of searchResult) { profile.isWatched = await userManager.isWatched( From e786f09deb696463905d76de25089c64cb4241af Mon Sep 17 00:00:00 2001 From: BitPodAI Date: Sun, 16 Feb 2025 17:58:33 +0800 Subject: [PATCH 6/9] Update the Sol function --- packages/client-direct/src/routes.ts | 24 ++++++++++------------- packages/plugin-data-enrich/src/social.ts | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/client-direct/src/routes.ts b/packages/client-direct/src/routes.ts index 830335e52f6ef..b734d9e5c06e0 100644 --- a/packages/client-direct/src/routes.ts +++ b/packages/client-direct/src/routes.ts @@ -1201,18 +1201,6 @@ export class Routes { signature, data: "Sol-SPL reward processed", }); - - // Confirm the transction - /*const connection = new Connection( - clusterApiUrl("mainnet-beta"), - "confirmed" - ); - const signature = await sendAndConfirmTransaction( - connection, - transaction, - [settings.SOL_SPL_OWNER_PUBKEY] - ); - return { signature };*/ } catch (error) { if (error instanceof SplInvalidPublicKeyError) { throw new ApiError(400, error.message); @@ -1243,7 +1231,11 @@ export class Routes { transaction, [settings.SOL_OWNER_PUBKEY] ); - return { signature }; + return res.json({ + success: true, + signature, + data: "Sol reward processed", + }); } catch (error) { if (error instanceof InvalidPublicKeyError) { throw new ApiError(400, error.message); @@ -1266,7 +1258,11 @@ export class Routes { mintPubkey: settings.SOL_SPL_OWNER_PUBKEY, tokenAmount, }); - return { transaction }; + return res.json({ + success: true, + transaction, + data: "Sol-Agent-Kit reward processed", + }); } catch (error) { if (error instanceof SplInvalidPublicKeyError) { throw new ApiError(400, error.message); diff --git a/packages/plugin-data-enrich/src/social.ts b/packages/plugin-data-enrich/src/social.ts index 086e1af5bd5a5..9bd92e57ffdcd 100644 --- a/packages/plugin-data-enrich/src/social.ts +++ b/packages/plugin-data-enrich/src/social.ts @@ -139,7 +139,7 @@ export class twitterDataProvider { for await (const tweet of tweets) { posts.push(tweet); } - + const prompt =` The biography of ${username} is ${userBio}.\n Here are some posts of ${username}: From 8e9346afed1b8edd2b78393cf9f739815c811a7f Mon Sep 17 00:00:00 2001 From: ykai2 Date: Tue, 18 Feb 2025 05:45:33 +0300 Subject: [PATCH 7/9] Add kol labels. Signed-off-by: ykai2 --- packages/client-direct/src/routes.ts | 43 ++++++++++++++++++++++ packages/client-twitter/src/finder.ts | 51 ++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/packages/client-direct/src/routes.ts b/packages/client-direct/src/routes.ts index 830335e52f6ef..d4b1942f1980f 100644 --- a/packages/client-direct/src/routes.ts +++ b/packages/client-direct/src/routes.ts @@ -219,6 +219,10 @@ export class Routes { "/:agentId/twitter_profile_search", this.handleTwitterProfileSearch.bind(this) ); + app.post( + "/:agentId/twitter_labels", + this.handleTwitterLabels.bind(this) + ); app.post( "/:agentId/twitter_profile_kols", this.handleTwitterProfileKols.bind(this) @@ -754,6 +758,45 @@ export class Routes { }); } + async handleTwitterLabels( + req: express.Request, + res: express.Response + ) { + return this.authUtils.withErrorHandling(req, res, async () => { + console.log("handleTwitterLabels"); + if (!Array.isArray(req.body.xnamelist)) { + return res.status(400).json({ error: 'param not a array' }); + } + const receivedStrings = req.body.xnamelist; + + // receivedStrings.forEach((str, index) => { + // console.log(`getlabels string: ${index + 1}: ${str}`); + // }); + + // const runtime = await this.authUtils.getRuntime(req.params.agentId); + + try { + let profilesOutput = []; + const promise = new Promise((resolve, reject) => { + // Listen + twEventCenter.on('MSG_TWITTER_LABELS_RESP', (data) => { + //console.log('Received Resp message:', data); + resolve(data); + }); + + twEventCenter.emit('MSG_TWITTER_LABELS', { xuserlist: receivedStrings }); + }); + + // wait for result + profilesOutput = await promise; + return profilesOutput; + } catch (error) { + console.error("handleTwitterLabels error:", error); + return []; + } + }); + } + async handleTwitterProfileKols( req: express.Request, res: express.Response diff --git a/packages/client-twitter/src/finder.ts b/packages/client-twitter/src/finder.ts index bb5db62a27ab9..9412d2554515f 100644 --- a/packages/client-twitter/src/finder.ts +++ b/packages/client-twitter/src/finder.ts @@ -8,13 +8,20 @@ import { } from "@elizaos/plugin-data-enrich"; import { ClientBase } from "./base"; import { twEventCenter } from "./index"; - +import fs from 'fs'; +import path from 'path'; const TW_PROFILE_PREFIX: string = "FINDER_KEY_TW_PROFILE_PREFIX_"; +interface KolItem { + kolname: string; + kollabel: string; + kollabel_en: string; +}; export class TwitterFinderClient { client: ClientBase; runtime: IAgentRuntime; + kolList: KolItem[]; twitterKolUsers: string[] = [ '0xRodney', 'Buddy', @@ -179,6 +186,13 @@ export class TwitterFinderClient { twEventCenter.emit('MSG_SEARCH_TWITTER_PROFILE_RESP', profiles); }); + twEventCenter.on('MSG_TWITTER_LABELS', async (data) => { + // console.log('Received message:', data); + const xuserlables = await this.getlabels(data?.xuserlist); + // Send back + twEventCenter.emit('MSG_TWITTER_LABELS_RESP', xuserlables); + }); + twEventCenter.on('MSG_KOLS_TWITTER_PROFILE', async () => { // console.log('Received message userkols:', JSON.stringify(data.kols)); let searchResult = []; @@ -200,6 +214,41 @@ export class TwitterFinderClient { const shuffled = [...users].sort(() => 0.5 - Math.random()); return shuffled.slice(0, count); } + + async getlabels(xnamelist: string[]) { + try { + if (!this.kolList) { + const rawData = fs.readFileSync(path.join('xuserlabels.json'), 'utf8'); + this.kolList = JSON.parse(rawData); + } + + // this.kolList.forEach((kol, index) => { + // console.log(`KOL ${index + 1}:`); + // console.log(`Name: ${kol.kolname}`); + // console.log(`Label (CN): ${kol.kollabel}`); + // console.log(`Label (EN): ${kol.kollabel_en}\n`); + // }); + + const kolDict = this.kolList.reduce((acc, kol) => { + acc[kol.kolname] = kol; + return acc; + }, {}); + + const result = {}; + + for (const name of xnamelist) { + if (Object.prototype.hasOwnProperty.call(kolDict, name)) { + result[name] = kolDict[name]; + } else { + result[name] = {"kolname": name, "kollabel": name, "kollabel_en": name}; + } + } + return result; + } catch (err) { + console.error('getlabels:', err.message); + } + return null; + } async searchProfileKols(username: string, count: number) { let searchResult = []; try { From 1d8d79726631f2cb548f8ecb1a7f66616c358c93 Mon Sep 17 00:00:00 2001 From: ykai2 Date: Wed, 19 Feb 2025 12:33:40 +0300 Subject: [PATCH 8/9] add kol labels data. Signed-off-by: ykai2 --- agent/xuserlabels.json | 10 ++++++++++ packages/client-twitter/src/finder.ts | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 agent/xuserlabels.json diff --git a/agent/xuserlabels.json b/agent/xuserlabels.json new file mode 100644 index 0000000000000..47f1bdc4f47e2 --- /dev/null +++ b/agent/xuserlabels.json @@ -0,0 +1,10 @@ +[ + { + "kolname": "abc", + "kollabel": "abc CEO" + }, + { + "kolname": "abc2", + "kollabel": "abc2 CEO" + } +] diff --git a/packages/client-twitter/src/finder.ts b/packages/client-twitter/src/finder.ts index 9412d2554515f..79c9be7bb8e8e 100644 --- a/packages/client-twitter/src/finder.ts +++ b/packages/client-twitter/src/finder.ts @@ -226,7 +226,6 @@ export class TwitterFinderClient { // console.log(`KOL ${index + 1}:`); // console.log(`Name: ${kol.kolname}`); // console.log(`Label (CN): ${kol.kollabel}`); - // console.log(`Label (EN): ${kol.kollabel_en}\n`); // }); const kolDict = this.kolList.reduce((acc, kol) => { @@ -240,7 +239,7 @@ export class TwitterFinderClient { if (Object.prototype.hasOwnProperty.call(kolDict, name)) { result[name] = kolDict[name]; } else { - result[name] = {"kolname": name, "kollabel": name, "kollabel_en": name}; + result[name] = {"kolname": name, "kollabel": name}; } } return result; From 211a434b273efa1b14e41a0a3f99befadcfca149 Mon Sep 17 00:00:00 2001 From: BitPod Date: Sat, 22 Feb 2025 06:07:07 +0800 Subject: [PATCH 9/9] Update the twitter summary --- .gitignore | 2 ++ packages/plugin-data-enrich/src/social.ts | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2746205bef8e5..c788dec65e509 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,8 @@ coverage .eslintcache agent/content +agent/xuserlabels.json +packages/plugin-data-enrich/data eliza.manifest eliza.manifest.sgx diff --git a/packages/plugin-data-enrich/src/social.ts b/packages/plugin-data-enrich/src/social.ts index 9bd92e57ffdcd..d6d56c2d5b274 100644 --- a/packages/plugin-data-enrich/src/social.ts +++ b/packages/plugin-data-enrich/src/social.ts @@ -89,9 +89,10 @@ export const socialProvider: Provider = { } const ABSTRACTOR_INSTRUCTION = ` - Please summary the user information by the provided biography and post tweets. + Please summary the twitter account information by the provided biography and post tweets. The total words count should be between 20 and 30. - If the user is not related to web3 or crypto, just return "The user is not related to Web3".`; + The summary result should not contain the words 'user'/'account', use their original names instead. + If the account is not related to web3 or crypto, just return "The item is not related to Web3".`; const TW_ABSTRACTOR_PREFIX: string = "ABSTRACTOR_KEY_TW_PROFILE_PREFIX_"; const TW_ABSTRACTOR_POST_COUNT = 20; @@ -159,7 +160,7 @@ export class twitterDataProvider { }); //console.log(response); summary = response; - if (response && response.includes("The user is not related to Web3")) { + if (response && response.includes("The item is not related to Web3")) { summary = ""; } } catch (error) {