-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Always getting the error: "AssertionError exception: no description" #108
Comments
does it fix it? cg = CoinGeckoAPI(api_key=os.getenv('coingecko_api_key'))
class GetCoinsListTool(Tool):
name = "get_coins_list"
description = """
This tool makes a query to the CoinGecko API to get a response of ALL of the supported coins with their price, market cap, volume and related market data in USD.
"""
inputs = {
"currency": {
"type": "string",
"description": "The currency in which the coin data should be represented (e.g., 'usd', 'eur')."
}
}
output_type = "list"
def forward(self, currency: str) -> list:
return cg.get_coins_markets(vs_currency=currency) |
Got the same error. Exception has occurred: AssertionError
exception: no description
Exception has occurred: AssertionError
exception: no description
File "...\coingecko_agent\agent.py", line 7, in <module>
coin_list_tool = GetCoinsListTool()
^^^^^^^^^^^^^^^^^^
AssertionError: |
I don't know if this is suitable for you, but here's what I did: from smolagents import CodeAgent, HfApiModel, Tool
import os
from pycoingecko import CoinGeckoAPI
import json
# Initialize CoinGecko API client
cg = CoinGeckoAPI(api_key=os.getenv('coingecko_api_key'))
# Define the GetCoinsListTool class
class GetCoinsListTool(Tool):
name = "get_coins_list"
description = """
This tool makes a query to the CoinGecko API to get a response of ALL of the supported coins with their price, market cap, volume and related market data in USD.
You need to import json. The output is a JSON string. You should use the `json` module to parse this string into a Python list.
"""
inputs = {
"currency": {
"type": "string",
"description": "The currency in which the coin data should be represented (e.g., 'usd', 'eur')."
}
}
output_type = "string" # Change to 'string'
def forward(self, currency: str) -> str:
coins_data = cg.get_coins_markets(vs_currency=currency)
return json.dumps(coins_data) # Convert the list to a JSON string
# Initialize the model
model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")
# Initialize the agent with the tool
agent = CodeAgent(
tools=[GetCoinsListTool()],
model=model,
add_base_tools=True,
additional_authorized_imports=["json"] # Authorize the json module
)
# Run the agent with a task
task = "Get the list of coins in USD and print the first 5 entries. Then present it as usual text."
result = agent.run(task)
# Print the result
print("Agent Output:")
print(result) |
Works like a charm. Thanks! But why does the the @tool decorator not work? |
@jondoescoding could you provide your full error trace and package versions? I tried to reproduce but for me your code snippet works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No matter what I do to modify the docstring I always get the same error as mentioned in the title.
Here is a tool that I have created.
I would like to know what within my docstrings is causing this.
The text was updated successfully, but these errors were encountered: