Skip to content

Commit

Permalink
feat: refine report token detail format, prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
simpletrontdip committed Dec 25, 2024
1 parent efdb226 commit daed0e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
35 changes: 15 additions & 20 deletions packages/plugin-birdeye/src/actions/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Extract the 1 latest information about the requested token report:
- Input token symbol
- Extra about this symbol
When the symbol is specified in all lower case, such as btc, eth, sol..., we should convert it into wellknown symbol.
When the symbol is specified in all lowered case, such as btc, eth, sol..., we should convert it into wellknown symbol.
E.g. btc instead of BTC, sol instead of SOL.
But when we see them in mixed form, such as SOl, DOl, eTH we should keep the original and notice user instead.
When in doubt, specify the concern in the message field.
But when we see them in mixed form, such as SOl, DOl, eTH, except the case they're quoted (e.g. 'wEth', 'SOl',...)
When in doubt, specify the concern in the message field, include your suggested value with it.
Respond exactly a JSON object containing only the extracted values, no extra description or message needed.
Use null for any values that cannot be determined. The result should be a valid JSON object with the following schema:
Expand All @@ -33,27 +33,20 @@ Use null for any values that cannot be determined. The result should be a valid
}
Examples:
Message: "Tell me about BTC"
Response: {
"symbol": "BTC",
"message": null
}
Message: "Do you know about SOl."
Response:
{
"symbol": "SOl",
"message": "Please note that the symbol is not in the standard format."
}
Message: 'Tell me about BTC'
Response: '{ "symbol": "BTC", "message": null}'
Message: 'Do you know about SOl.'
Response: '{ "symbol": "SOl", "message": "We've found SOL seems match, is that what you want?"}'
`;


const formatTokenReport = (data) => {
let output = `**Token Security and Trade Report**\n`;
let output = `*Token Security and Trade Report*\n`;
output += `Token symbol: ${data.symbol}\n`
output += `Token Address: ${data.tokenAddress}\n\n`;

output += `**Ownership Distribution:**\n`;
output += `*Ownership Distribution:*\n`;
output += `- Owner Balance: ${data.security.ownerBalance}\n`;
output += `- Creator Balance: ${data.security.creatorBalance}\n`;
output += `- Owner Percentage: ${data.security.ownerPercentage}%\n`;
Expand All @@ -62,7 +55,7 @@ const formatTokenReport = (data) => {
output += `- Top 10 Holders Percentage: ${data.security.top10HolderPercent}%\n\n`;

// Trade Data
output += `**Trade Data:**\n`;
output += `*Trade Data:*\n`;
output += `- Holders: ${data.volume.holder}\n`;
output += `- Unique Wallets (24h): ${data.volume.unique_wallet_24h}\n`;
output += `- Price Change (24h): ${data.volume.price_change_24h_percent}%\n`;
Expand Down Expand Up @@ -90,6 +83,8 @@ const extractTokenSymbol = async (
modelClass: ModelClass.LARGE,
})

elizaLogger.log('Response', response)

try {
const regex = new RegExp(/\{(.+)\}/gms);
const normalized = response && regex.exec(response)?.[0]
Expand Down Expand Up @@ -129,8 +124,8 @@ export const reportToken = {
}

if(params?.message) {
callback?.({text: `I need more clarification to continue, ${params.message}`})
return true
// show concern message
callback?.({text: `*Warning*: ${params.message}`})
}

const symbol = params?.symbol
Expand Down
7 changes: 4 additions & 3 deletions packages/plugin-birdeye/src/providers/birdeye.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,13 @@ export const birdeyeProvider: Provider = {
if (!walletAddr) {
console.warn("No Birdeye wallet was specified");

return `Birdeye provider initiated with no wallet found`;
return `Birdeye enabled, no wallet found`;
}

const portfolio = await provider.fetchWalletPortfolio(walletAddr);
const response = await provider.fetchWalletPortfolio(walletAddr);
const portfolio = response?.data.items.map(e => e.symbol).join(', ')

return `Birdeye wallet addr: ${walletAddr}, portfolio: ${portfolio}`;
return `Birdeye enabled, wallet addr: ${walletAddr}, portfolio: [${portfolio}]`;
} catch (error) {
console.error("Error fetching token data:", error);
return "Unable to fetch token information. Please try again later.";
Expand Down

0 comments on commit daed0e0

Please sign in to comment.