Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: Add CoinGecko plugin #1382

Closed
wants to merge 42 commits into from

Conversation

0xCardinalError
Copy link
Contributor

@0xCardinalError 0xCardinalError commented Dec 22, 2024

Adding a new plugin, where with free API from coingecko we can get price of a currency and its marketcap.
There are 2 actions, so we can fetch by name/ticker but also with address of token.

Added, Readme, .env config and integration to default agent if key is set.

Image attached for example how it makes output.
image

@proteanx
Copy link
Contributor

Seems unnecessary to change the character files (provider switched for whatever reason), also the entire package.json instead of just adding the plugin. I know that's just a formatting thing but makes it more tedious to review.

@proteanx
Copy link
Contributor

Seems unnecessary to change the character files (provider switched for whatever reason), also the entire package.json instead of just adding the plugin. I know that's just a formatting thing but makes it more tedious to review.

Ahh nm I see you added those characters originally. Just seemed unrelated to the PR.

@0xCardinalError
Copy link
Contributor Author

Seems unnecessary to change the character files (provider switched for whatever reason), also the entire package.json instead of just adding the plugin. I know that's just a formatting thing but makes it more tedious to review.

Ahh nm I see you added those characters originally. Just seemed unrelated to the PR.

had some problems on DEV branch with antropic so I did change model to openai, but reverted now on this PR, as this is unrelated.

@0xCardinalError
Copy link
Contributor Author

Seems unnecessary to change the character files (provider switched for whatever reason), also the entire package.json instead of just adding the plugin. I know that's just a formatting thing but makes it more tedious to review.

about formating, isnt the setting for prettier set to 4 in all places, so seems to me this should be right formating of .json file?

@proteanx
Copy link
Contributor

proteanx commented Dec 23, 2024

Going to test this but there are merge conflicts that need to be fixed. Might need to rebase this onto current develop branch to fix. I'm seeing some stuff that doesn't exist in current develop i.e. agent/src/index.ts everything but the addition of the import and getSecret(character, "COINGECKO_API_KEY") ? coingeckoPlugin : null, should be reverted/removed (it's correct already in current develop so this is probably the merge conflict).

@0xCardinalError
Copy link
Contributor Author

Going to test this but there are merge conflicts that need to be fixed. Might need to rebase this onto current develop branch to fix. I'm seeing some stuff that doesn't exist in current develop i.e. agent/src/index.ts everything but the addition of the import and getSecret(character, "COINGECKO_API_KEY") ? coingeckoPlugin : null, should be reverted/removed (it's correct already in current develop so this is probably the merge conflict).

thanx for review, develop moves fast so I didn't update it for 2 days and lots has changed, I merged current develop into mine so now there shouldn't be any conflict.

@odilitime odilitime added the Plugin_new Mark PRs that are a new plugin label Dec 23, 2024
@proteanx
Copy link
Contributor

Going to test this but there are merge conflicts that need to be fixed. Might need to rebase this onto current develop branch to fix. I'm seeing some stuff that doesn't exist in current develop i.e. agent/src/index.ts everything but the addition of the import and getSecret(character, "COINGECKO_API_KEY") ? coingeckoPlugin : null, should be reverted/removed (it's correct already in current develop so this is probably the merge conflict).

thanx for review, develop moves fast so I didn't update it for 2 days and lots has changed, I merged current develop into mine so now there shouldn't be any conflict.

This looks really clean now. Unfortunately I encountered an error attempting to test price retrieval -

 ["✓ Normalized action: getcoin_price"] 

 ["ℹ Executing handler for action: GET_COIN_PRICE"] 

 ["◎ Starting GET_COIN_PRICE handler..."] 

 ◎ LOGS
   Fetched coin list, total coins: 
   16269 

Error in generateObject: Error: Unknown model
    at getEncodingNameForModel (file:///media/bsc/eliza/node_modules/js-tiktoken/dist/chunk-YVJR5WRT.js:242:13)
    at encodingForModel (file:///media/bsc/eliza/node_modules/js-tiktoken/dist/index.js:43:22)
    at trimTokens (file:///media/bsc/eliza/packages/core/dist/index.js:2191:22)
    at generateObject (file:///media/bsc/eliza/packages/core/dist/index.js:2607:19)
    at Object.handler (file:///media/bsc/eliza/packages/plugin-gecko/dist/index.js:4114:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async AgentRuntime.processActions (file:///media/bsc/eliza/packages/core/dist/index.js:3577:17)
    at async MessageManager.handleMessage (file:///media/bsc/eliza/packages/client-discord/dist/index.js:2132:17)
 ⛔ ERRORS
   Error during price lookup: 
   {} 

@0xCardinalError
Copy link
Contributor Author

Going to test this but there are merge conflicts that need to be fixed. Might need to rebase this onto current develop branch to fix. I'm seeing some stuff that doesn't exist in current develop i.e. agent/src/index.ts everything but the addition of the import and getSecret(character, "COINGECKO_API_KEY") ? coingeckoPlugin : null, should be reverted/removed (it's correct already in current develop so this is probably the merge conflict).

thanx for review, develop moves fast so I didn't update it for 2 days and lots has changed, I merged current develop into mine so now there shouldn't be any conflict.

This looks really clean now. Unfortunately I encountered an error attempting to test price retrieval -

 ["✓ Normalized action: getcoin_price"] 

 ["ℹ Executing handler for action: GET_COIN_PRICE"] 

 ["◎ Starting GET_COIN_PRICE handler..."] 

 ◎ LOGS
   Fetched coin list, total coins: 
   16269 

Error in generateObject: Error: Unknown model
    at getEncodingNameForModel (file:///media/bsc/eliza/node_modules/js-tiktoken/dist/chunk-YVJR5WRT.js:242:13)
    at encodingForModel (file:///media/bsc/eliza/node_modules/js-tiktoken/dist/index.js:43:22)
    at trimTokens (file:///media/bsc/eliza/packages/core/dist/index.js:2191:22)
    at generateObject (file:///media/bsc/eliza/packages/core/dist/index.js:2607:19)
    at Object.handler (file:///media/bsc/eliza/packages/plugin-gecko/dist/index.js:4114:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async AgentRuntime.processActions (file:///media/bsc/eliza/packages/core/dist/index.js:3577:17)
    at async MessageManager.handleMessage (file:///media/bsc/eliza/packages/client-discord/dist/index.js:2132:17)
 ⛔ ERRORS
   Error during price lookup: 
   {} 

try with openai as modelProvider, IDK why when using anthropic it gets this error, doesnt seem like problem with this plugin as it just sets "ModelClass.SMALL" and then in tiktoken module

function getEncodingNameForModel(model) {
  switch (model) {

this part gets some model that is not in the list, but seems more like general codebase problem, as I dont set the actual model in plugin. Please trace it out yourself and let me know what you think?

@sachiew
Copy link

sachiew commented Dec 27, 2024

hey @0xCardinalError @odilitime , thanks for working on this!

I work on CoinGecko product, I can supply pro api key to ease your testing, and as token of appreciation for your contributions. Feel free to ping TG @soonegg91

There's more can be done here for eliza with the CG demo and pro api, happy to bounce ideas.

@0xCardinalError
Copy link
Contributor Author

hey @0xCardinalError @odilitime , thanks for working on this!

I work on CoinGecko product, I can supply pro api key to ease your testing, and as token of appreciation for your contributions. Feel free to ping TG @soonegg91

There's more can be done here for eliza with the CG demo and pro api, happy to bounce ideas.

hey, thnx. will contact him in pvt and see where we can take this to

@0xCardinalError
Copy link
Contributor Author

0xCardinalError commented Dec 30, 2024

@odilitime @proteanx is testing done, Is anything else needed for this PR?
(updated to latest dev branch)

@tripluca
Copy link

tripluca commented Jan 2, 2025

It correctly fetched the price but the first message was probably not meant to be printed?
image

@tripluca
Copy link

tripluca commented Jan 4, 2025

I installed and tested the plugin.
Here's some feedback:

Current Features

  1. Get current price and market cap for known coins (BTC, ETH).
    Question: I tested with ordinals tokens (BRC20 but it doesn't fetch them.
  2. Get price and market cap for tokens by address on specific chains
  3. Basic error handling for unknown tokens

Limitations Found Through Testing

  1. Cannot remember or reference previously mentioned prices
  2. No access to historical data or 24h changes
  3. No price comparison functionality
  4. No volume data
  5. No price alerts or threshold notifications
  6. No trend analysis
  7. Action indicators ((GET_COIN_PRICE), (GET_TOKEN_PRICE_BY_ADDRESS)) visible in responses

Questions

Is this the whole scope? Getting the price when explicitly requested? Or is there a way to extract more from the API?`
thanks!

@sachiew
Copy link

sachiew commented Jan 4, 2025

No access to historical data or 24h changes
No volume data

Thanks for testing it out. The current commits include these 2 endpoints that support 24hr price change and 24hr trading volume data, but don't think it's included in the code:

Question: I tested with ordinals tokens (BRC20 but it doesn't fetch them.

Able to replicate this issue. It works for 'bitcoin', but not the following (refer image below):

  • 64550b91e058ef71501f1f46d446f6dae16fa446321f9e02e3c89490220ef400i0 on ordinals (CG page)
  • price for Bitcoin Wizards (same token as above)
  • 0x1185cb5122edad199bdbc0cbd7a0457e448f23c7 on base (CG page)
Screenshot 2025-01-05 at 1 26 35 AM

In case this helps - for 'chainId', this is how CoinGecko API maps with 'asset_platform_id'

--

There's definitely a lot more data and functionalities can be added given the API has more than 70 endpoints. Perhaps, can let 0xCardinalError focus on shipping the initial scopes, and can continue to expand to support more use cases. Hoping to see more contributors collab too :)

@ag-wnl ag-wnl mentioned this pull request Jan 5, 2025
wtfsayo
wtfsayo previously approved these changes Jan 7, 2025
Copy link
Member

@wtfsayo wtfsayo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, resolve @sachiew 's comment and merge conflicts plz

testing more

@wtfsayo wtfsayo self-requested a review January 7, 2025 10:32
@wtfsayo
Copy link
Member

wtfsayo commented Jan 7, 2025

this works but not good all the time!

@0xCardinalError
Copy link
Contributor Author

2. No access to historical data or 24h changes

What kind of print out do you use, when using default browser I don't get extra messages.

image

@0xCardinalError
Copy link
Contributor Author

I installed and tested the plugin. Here's some feedback:

Current Features

  1. Get current price and market cap for known coins (BTC, ETH).
    Question: I tested with ordinals tokens (BRC20 but it doesn't fetch them.
  2. Get price and market cap for tokens by address on specific chains
  3. Basic error handling for unknown tokens

Limitations Found Through Testing

  1. Cannot remember or reference previously mentioned prices
  2. No access to historical data or 24h changes
  3. No price comparison functionality
  4. No volume data
  5. No price alerts or threshold notificationsh
  6. No trend analysis
  7. Action indicators ((GET_COIN_PRICE), (GET_TOKEN_PRICE_BY_ADDRESS)) visible in responses

Questions

Is this the whole scope? Getting the price when explicitly requested? Or is there a way to extract more from the API?` thanks!

as written in readme it was just 2 endpoints for fetching price as some V1 of this to have access to price. this made most sense to have for a BOT. should add it to memory/state for reuse.
will add others over time, which ones makes most sense.
I am thinking mostly in a way that AI would buy something or inform others about specific info about price/market situations. Please state some scenarios you think would be good to have?

@0xCardinalError
Copy link
Contributor Author

0xCardinalError commented Jan 8, 2025

No access to historical data or 24h changes
No volume data

Thanks for testing it out. The current commits include these 2 endpoints that support 24hr price change and 24hr trading volume data, but don't think it's included in the code:

Question: I tested with ordinals tokens (BRC20 but it doesn't fetch them.

Able to replicate this issue. It works for 'bitcoin', but not the following (refer image below):

  • 64550b91e058ef71501f1f46d446f6dae16fa446321f9e02e3c89490220ef400i0 on ordinals (CG page)
  • price for Bitcoin Wizards (same token as above)
  • 0x1185cb5122edad199bdbc0cbd7a0457e448f23c7 on base (CG page)
Screenshot 2025-01-05 at 1 26 35 AM In case this helps - for 'chainId', this is how CoinGecko API maps with 'asset_platform_id'

--

There's definitely a lot more data and functionalities can be added given the API has more than 70 endpoints. Perhaps, can let 0xCardinalError focus on shipping the initial scopes, and can continue to expand to support more use cases. Hoping to see more contributors collab too :)

yes, there are a lot of endpoints, started from the most logical one :)

about the base problem, hmm it could also be down to quirkiness of actual LLM/char you are using. I tried exact same many times and it does output correctly as seen below.

about ordinals, yeah, that is a problem, optimizing template for it and other to use ordinals word as platform/chain
_id

image

@0xCardinalError
Copy link
Contributor Author

this works but not good all the time!

please provide if you have different problems then the ones stated by others?

@0xCardinalError
Copy link
Contributor Author

Ordinals should be fetched now, also added memory part so agent can recall what he just found

image

@0xCardinalError
Copy link
Contributor Author

Added trending coins.

image

@0xCardinalError
Copy link
Contributor Author

was solved and merged in other PRs, so will close this one

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Needs Testing Plugin_new Mark PRs that are a new plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants