-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c31561
commit ef08d19
Showing
13 changed files
with
277 additions
and
1,369 deletions.
There are no files selected for viewing
50 changes: 0 additions & 50 deletions
50
cdp-agentkit-core/cdp_agentkit_core/actions/allora/get_price_prediction.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions
50
cdp-agentkit-core/python/cdp_agentkit_core/actions/allora/get_price_inference.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from collections.abc import Callable | ||
|
||
from allora_sdk.v2.api_client import AlloraAPIClient | ||
from pydantic import BaseModel, Field | ||
|
||
from cdp_agentkit_core.actions.allora.action import AlloraAction | ||
|
||
GET_PRICE_INFERENCE_PROMPT = """ | ||
This tool will get the future price inference for a given crypto asset from Allora Network. | ||
It takes the crypto asset and timeframe as inputs. | ||
""" | ||
|
||
|
||
class GetPriceInferenceInput(BaseModel): | ||
"""Input argument schema for get price inference action.""" | ||
|
||
token: str = Field( | ||
..., description="The crypto asset to get the price inference for, e.g. `BTC`" | ||
) | ||
timeframe: str = Field( | ||
..., description="The timeframe to get the price inference for, e.g. `5m` or `8h`" | ||
) | ||
|
||
|
||
async def get_price_inference(client: AlloraAPIClient, token: str, timeframe: str) -> str: | ||
"""Get the future price inference for a given crypto asset from Allora Network. | ||
Args: | ||
client (AlloraAPIClient): The Allora API client. | ||
token (str): The crypto asset to get the price inference for, e.g. `BTC` | ||
timeframe (str): The timeframe to get the price inference for, e.g. `5m` or `8h` | ||
Returns: | ||
str: The future price inference for the given crypto asset | ||
""" | ||
try: | ||
price_inference = await client.get_price_prediction(token, timeframe) | ||
return f"The future price inference for {token} in {timeframe} is {price_inference.inference_data.network_inference_normalized}" | ||
except Exception as e: | ||
return f"Error getting price inference: {e}" | ||
|
||
|
||
class GetPriceInferenceAction(AlloraAction): | ||
"""Get price inference action.""" | ||
|
||
name: str = "get_price_inference" | ||
description: str = GET_PRICE_INFERENCE_PROMPT | ||
args_schema: type[BaseModel] | None = GetPriceInferenceInput | ||
func: Callable[..., str] = get_price_inference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.