-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature cookie api #22
Conversation
catch up with main
except Exception: | ||
logger.exception(f"Failed to find token address for {symbol}") | ||
return None, None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to raise the exception here, rather than return (None, None) to differentiate between actually no result and error in execution
except Exception: | |
logger.exception(f"Failed to find token address for {symbol}") | |
return None, None | |
except Exception: | |
logger.exception(f"Failed to find token address for {symbol}") | |
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
@dataclass | ||
class Tweet: | ||
tweetUrl: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
property name in python should be lower_snake_case
. To enable proper mapping with API schema, use tweet_url: str = Field(alias="tweet_url")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made changes
return PagedAgentsResponse( | ||
data=[AgentMetrics(**agent) for agent in data["data"]], | ||
currentPage=data["currentPage"], | ||
totalPages=data["totalPages"], | ||
totalCount=data["totalCount"], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pydantic dataclasses should already handling this for you. This might work
return PagedAgentsResponse( | |
data=[AgentMetrics(**agent) for agent in data["data"]], | |
currentPage=data["currentPage"], | |
totalPages=data["totalPages"], | |
totalCount=data["totalCount"], | |
) | |
return PagedAgentsResponse(**data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
def cookiefun_client(default_config: Config) -> CookieFunClient: | ||
"""Create CookieFun client for testing""" | ||
# Set test API key if not present | ||
return CookieFunClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would properly the API key to be set in CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see inline comments
agent_name: str = Field(alias="agentName") | ||
twitter_usernames: List[str] = Field(alias="twitterUsernames") | ||
mindshare_delta_percent: float = Field(alias="mindshareDeltaPercent") | ||
market_cap: float = Field(alias="marketCap") | ||
market_cap_delta_percent: float = Field(alias="marketCapDeltaPercent") | ||
price_delta_percent: float = Field(alias="priceDeltaPercent") | ||
volume_24_hours: float = Field(alias="volume24Hours") | ||
volume_24_hours_delta_percent: float = Field(alias="volume24HoursDeltaPercent") | ||
holders_count: int = Field(alias="holdersCount") | ||
holders_count_delta_percent: float = Field(alias="holdersCountDeltaPercent") | ||
average_impressions_count: float = Field(alias="averageImpressionsCount") | ||
average_impressions_count_delta_percent: float = Field(alias="averageImpressionsCountDeltaPercent") | ||
average_engagements_count: float = Field(alias="averageEngagementsCount") | ||
average_engagements_count_delta_percent: float = Field(alias="averageEngagementsCountDeltaPercent") | ||
followers_count: int = Field(alias="followersCount") | ||
smart_followers_count: int = Field(alias="smartFollowersCount") | ||
top_tweets: List[Tweet] = Field(alias="topTweets") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we group in a logical manner all those fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like
`
# Optional/fields with defaults after
# Basic agent info
agent_name: str = Field(alias="agentName")
twitter_usernames: List[str] = Field(alias="twitterUsernames")
# Market metrics
market_cap: float = Field(alias="marketCap")
market_cap_delta_percent: float = Field(alias="marketCapDeltaPercent")
price_delta_percent: float = Field(alias="priceDeltaPercent")
volume_24_hours: float = Field(alias="volume24Hours")
volume_24_hours_delta_percent: float = Field(alias="volume24HoursDeltaPercent")
# Mindshare metrics
mindshare_delta_percent: float = Field(alias="mindshareDeltaPercent")
# Holder metrics
holders_count: int = Field(alias="holdersCount")
holders_count_delta_percent: float = Field(alias="holdersCountDeltaPercent")
# Engagement metrics
average_impressions_count: float = Field(alias="averageImpressionsCount")
average_impressions_count_delta_percent: float = Field(alias="averageImpressionsCountDeltaPercent")
average_engagements_count: float = Field(alias="averageEngagementsCount")
average_engagements_count_delta_percent: float = Field(alias="averageEngagementsCountDeltaPercent")
# Social metrics
followers_count: int = Field(alias="followersCount")
smart_followers_count: int = Field(alias="smartFollowersCount")
top_tweets: List[Tweet] = Field(alias="topTweets")
`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but this is the order in api output schema. Wouldn't it be easier to reconcile dataclass with api for users if in same order?
logger.exception("Error fetching data from Cookie.fun") | ||
raise | ||
|
||
def _parse_agent_response(self, response_data: dict) -> AgentMetrics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _parse_agent_response(self, response_data: dict) -> AgentMetrics: | |
def _parse_agent_metrics_response(self, response_data: dict) -> AgentMetrics: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ApiException: If API request fails | ||
""" | ||
if not 1 <= page_size <= 25: | ||
raise ValueError("page_size must be between 1 and 25") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise ValueError("page_size must be between 1 and 25") | |
raise ValueError(f"page_size must be between 1 and 25, got {page_size}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😔
* feat cookiefun api * feat cookiefun api Get Agents Paged functionality * refactor cookiefun api * add cookie tools to examples/terminal * add integration test for cookie fun api * feat cookie fun api by token address * add cookie fun metrics by token symbol * add conftest to cookie integration test * reformat code to fix linting * reformat imports using poetry * fix property names to be lower_snake_case * fix linting * fix linting * refactor method naming * refactor method naming * add CookieMetricsBySymbol as tool * add cookie_metrics to examples/terminal * fix linting * resolve merge conflict in examples/terminal * add default values to cookiefun_client * fix linting * fix linting * add default values to dataclasses * fix linting * Decouple trading strategy from core AlphaSwarmAgent. (#32) * momentum strategy analysis as agent specilization instead of tool (#27) * inital work on research agent * rename to momentum strategy agent; added price chg calculator tool * lint * Remove lab directory from git tracking * Implement telegram image sending * Refactor evm client (#28) * extract erc20contract * WIP signing transaction * lint * clean up * clean up * use EMVClient in Uniswap * clean up * clean up * clean up * clean up * clean up * clean up * clean up ExactInputSingleParams * Create test_v3_router_contract.py * more clean up * more clean up * more clean up * fix test * Install matplotlib * Progress * Fix output formatting (#35) * Introduce hints file * Tune instructions in SendTelegramNotificationTool * Use claude-3-5-sonnet-20241022 as a model * Rename token_set to token_name_to_address * Fix comments * Add manual test for swap (#40) * add a couple of integration test on swap to run manually * add ExecuteSwapTool in terminal * quick fix * Adding project README and basic examples (#26) * Update README * Introduce basic tutorial examples --------- Co-authored-by: Arnaud Flament <[email protected]> * Create image as part of forecasting tool * reorganize lab agent tools; cookie tool description update * fixed wrong substitution in system prompt * added trading to lab advisor agent * simplified momentum agent in lab * Feature uniswap more clean up (#42) * use TokenInfo to convert in uniswap v2 * clean up private key and wallet address in UniswapClientBase * clean up PoolContract * fix return type for ERC20Cotnract.get_balance * clean up * fix integration test * Fix Telegram RuntimeError('Event loop is closed') * simiplfy cookie page description * Fix Telegram RuntimeError('Event loop is closed') (#44) * Decouple Config from class constructors (#45) * Initial commit * Merge with main * Update * Code clean-up (#46) * Code clean-up * Update * Fix tests * fix tests * Feature more lint (#47) * lint * more lint * more lint * clean up * clean up * enable `warn_unused_ignores` (#48) * enable `warn_unused_ignores` * Update terminal.py * updated research system prompt * Feature introduce slippage class (#50) * Create Slippage class * Add Unit tests * Update * Feature improve CI (#49) * add test reports to CI * update test artifacts * Update python.yaml * Update python.yaml * lint * Update pyproject.toml * fix workflow * Feature fix decimal from float (#51) * Update sol.py * Update sol.py * Update sol.py * Feature cookie api (#22) * feat cookiefun api * feat cookiefun api Get Agents Paged functionality * refactor cookiefun api * add cookie tools to examples/terminal * add integration test for cookie fun api * feat cookie fun api by token address * add cookie fun metrics by token symbol * add conftest to cookie integration test * reformat code to fix linting * reformat imports using poetry * fix property names to be lower_snake_case * fix linting * fix linting * refactor method naming * refactor method naming * add CookieMetricsBySymbol as tool * add cookie_metrics to examples/terminal * fix linting * resolve merge conflict in examples/terminal * add default values to cookiefun_client * fix linting * fix linting * add default values to dataclasses * fix linting * add token details todefault * added cookie api key to github workflow * fix linting * fix linting * add typing * add cookiefun_client to conftest --------- Co-authored-by: AlexM369 <[email protected]> Co-authored-by: Ethan <[email protected]> * research agent system prompt tweaks * debugging * resolve merge errors --------- Co-authored-by: AlexM369 <[email protected]> Co-authored-by: Dmytro Nikolaiev <[email protected]> Co-authored-by: Guillaume Koch <[email protected]> Co-authored-by: david <[email protected]> Co-authored-by: Arnaud Flament <[email protected]> Co-authored-by: Arnaud Flament <[email protected]> Co-authored-by: AlexM369 <[email protected]>
This PR integrates three new API endpoints from cookie.fun into the repo, enabling retrieval of agent details via different identifiers. The changes include:
Get Agent by Twitter Username
• Retrieves agent details based on a given Twitter username at a specified interval.
• Example: "get agent metrics for twitter username 'griffaindotcom'"
Get Agent by Contract Address
• Retrieves agent details based on a supported token contract address.
• Also enables token symbol lookup using ChainConfig.get_token_info_or_none() from config.py.
• Example: "What are mindshare metrics for SEKOIA?" or "Mindshare change of 0xc0041ef357b183448b235a8ea73ce4e4ec8c265f"
Get Agents Paged
• Retrieves a paginated list of agents ordered by 7-day mindshare (descending).
• Example: "What are top 25 AI agents?"