Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Add CoinGecko plugin #1382

Open
wants to merge 33 commits into
base: develop
Choose a base branch
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?

@0xCardinalError
Copy link
Contributor Author

image
was having problems with using "generateObject" somehow it got into tiktoken even when using anthropic, didn't really need to use it, just switched to "generateMessageResponse" and all is fine now and should work as expected, please try it out

odilitime
odilitime previously approved these changes Dec 25, 2024
@proteanx
Copy link
Contributor

proteanx commented Dec 26, 2024


@proteanx
Copy link
Contributor

Scratch what I said before, this is working now you just need to add the plugin to the pnpm-lock file. This is a lot of commits for a single PR but the eliza devs don't seem to mind so this should be good to go.

Tested with Venice

image

@0xCardinalError
Copy link
Contributor Author

Scratch what I said before, this is working now you just need to add the plugin to the pnpm-lock file. This is a lot of commits for a single PR but the eliza devs don't seem to mind so this should be good to go.

Tested with Venice

image

Added lock file.

yeah, sorry for too many fixes, was mostly because of the model issue and that the whole plugin namespace changed, so tracking this and updating to dev branch that is constantly moving was hard to catch, but in the end it all resulted in better code and better of understanding of the whole system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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.

3 participants