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

[Bug] Doubao LLM for running the agent team demo #1980

Open
JokerHB opened this issue Feb 2, 2025 · 2 comments
Open

[Bug] Doubao LLM for running the agent team demo #1980

JokerHB opened this issue Feb 2, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@JokerHB
Copy link

JokerHB commented Feb 2, 2025

Description

When replacing the LLM models with Doubao, an error occurs.
However, it runs well when using the Phidata.

Doubao llm is created by from agno.models.openai.like import OpenAILike.

Error

openai.BadRequestError: Error code: 400 - {'error': {'code': 'InvalidParameter', 'message': 'One or more parameters specified in the request are not valid. Request id: 02173850780234684bae976ab37fc49f95f8882bb751870475bb0', 'param': '', 'type': 'BadRequest'}}

Steps to Reproduce

code

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.hackernews import HackerNewsTools
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.newspaper4k import Newspaper4kTools
from LLMPool.LLMManager import LLMModelManager

hn_researcher = Agent(
    name="HackerNews Researcher",
    model=LLMModelManager().get_llm_model("doubao"),
    role="Gets top stories from hackernews.",
    tools=[HackerNewsTools()],
)

web_searcher = Agent(
    name="Web Searcher",
    model=LLMModelManager().get_llm_model("doubao"),
    role="Searches the web for information on a topic",
    tools=[DuckDuckGoTools()],
    add_datetime_to_instructions=True,
)

article_reader = Agent(
    name="Article Reader",
    model=LLMModelManager().get_llm_model("doubao"),
    role="Reads articles from URLs.",
    tools=[Newspaper4kTools()],
)

hn_team = Agent(
    name="Hackernews Team",
    model=LLMModelManager().get_llm_model("doubao"),
    team=[hn_researcher, web_searcher, article_reader],
    instructions=[
        "First, search hackernews for what the user is asking about.",
        "Then, ask the article reader to read the links for the stories to get more information.",
        "Important: you must provide the article reader with the links to read.",
        "Then, ask the web searcher to search for each story to get more information.",
        "Finally, provide a thoughtful and engaging summary.",
    ],
    show_tool_calls=True,
    markdown=True,
)
hn_team.print_response("Write an article about the top 2 stories on hackernews", stream=False)
@JokerHB JokerHB added the bug Something isn't working label Feb 2, 2025
@manthanguptaa
Copy link
Contributor

Hey @JokerHB! Can you help with the steps on how you configured Doubao?

@JokerHB
Copy link
Author

JokerHB commented Feb 3, 2025

Hey @JokerHB! Can you help with the steps on how you configured Doubao?

Thanks a lot.

Here is the code for using Doubao to run the demo. Additionally, I added "introduce yourself" instructions for all agents and the agent team. For individual agents, it works well, but it fails for the agent team. The error message is:

openai.BadRequestError: Error code: 400 - {'error': {'code': 'InvalidParameter', 'message': 'One or more parameters specified in the request are not valid. Request id: 021738556852298066e25a9d76d456a17836e5a68876f93efddaa', 'param': '', 'type': 'BadRequest'}}

Code

# -*- coding: utf-8 -*-

import os

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.hackernews import HackerNewsTools
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.newspaper4k import Newspaper4kTools
from agno.models.openai.like import OpenAILike

hn_researcher = Agent(
    name="HackerNews Researcher",
    model=OpenAILike(id=os.getenv("DOUBAO_MODEL_ID"), base_url=os.getenv("DOUBAO_BASE_URL"), api_key=os.getenv("DOUBAO_API_KEY")),
    role="Gets top stories from hackernews.",
    tools=[HackerNewsTools()],
)

web_searcher = Agent(
    name="Web Searcher",
    model=OpenAILike(id=os.getenv("DOUBAO_MODEL_ID"), base_url=os.getenv("DOUBAO_BASE_URL"), api_key=os.getenv("DOUBAO_API_KEY")),
    role="Searches the web for information on a topic",
    tools=[DuckDuckGoTools()],
    add_datetime_to_instructions=True,
)

article_reader = Agent(
    name="Article Reader",
    model=OpenAILike(id=os.getenv("DOUBAO_MODEL_ID"), base_url=os.getenv("DOUBAO_BASE_URL"), api_key=os.getenv("DOUBAO_API_KEY")),
    role="Reads articles from URLs.",
    tools=[Newspaper4kTools()],
)

hn_team = Agent(
    name="Hackernews Team",
    model=OpenAILike(id=os.getenv("DOUBAO_MODEL_ID"), base_url=os.getenv("DOUBAO_BASE_URL"), api_key=os.getenv("DOUBAO_API_KEY")),
    team=[hn_researcher, web_searcher, article_reader],
    instructions=[
        "First, search hackernews for what the user is asking about.",
        "Then, ask the article reader to read the links for the stories to get more information.",
        "Important: you must provide the article reader with the links to read.",
        "Then, ask the web searcher to search for each story to get more information.",
        "Finally, provide a thoughtful and engaging summary.",
    ],
    show_tool_calls=True,
    markdown=True,
)


hn_researcher.print_response("Please introduce yourself", stream=False)
web_searcher.print_response("Please introduce yourself", stream=False)
article_reader.print_response("Please introduce yourself", stream=False)
hn_team.print_response("Please introduce yourself", stream=False)

Here is the request.content for all agents and the agent team.

hn_researcher

b'{"messages": [{"role": "system", "content": "<your_role>\\nGets top stories from hackernews.\\n</your_role>"}, {"role": "user", "content": "Please introduce yourself"}], "model": "ep-20250103180010-kv47b", "tool_choice": "auto", "tools": [{"type": "function", "function": {"name": "get_top_hackernews_stories",
"description": "Use this function to get top stories from Hacker News.", "parameters": {"type": "object", "properties": {"num_stories": {"type": "number", "description": "(int) Number of stories to return. Defaults to 10."}}, "required": []}}}, {"type": "function", "function": {"name": "get_user_details", 
"description": "Use this function to get the details of a Hacker News user using their username.", "parameters": {"type": "object", "properties": {"username": {"type": "string", "description": "(str) Username of the user to get details for."}}, "required": ["username"]}}}]}'

web_searcher

b'{"messages": [{"role": "system", "content": "<your_role>\\nSearches the web for information on a topic\\n</your_role>\\n\\n<additional_information>\\n- The current time is 2025-02-03 19:40:23.418357\\n</additional_information>"}, {"role": "user", "content": "Please introduce yourself"}], "model": 
"ep-20250103180010-kv47b", "tool_choice": "auto", "tools": [{"type": "function", "function": {"name": "duckduckgo_search", "description": "Use this function to search DuckDuckGo for a query.", "parameters": {"type": "object", "properties": {"query": {"type": "string", "description": "(str) The query to search 
for."}, "max_results": {"type": "number", "description": "(optional, default=5) The maximum number of results to return."}}, "required": ["query"]}}}, {"type": "function", "function": {"name": "duckduckgo_news", "description": "Use this function to get the latest news from DuckDuckGo.", "parameters": {"type": 
"object", "properties": {"query": {"type": "string", "description": "(str) The query to search for."}, "max_results": {"type": "number", "description": "(optional, default=5) The maximum number of results to return."}}, "required": ["query"]}}}]}'

article_reader

b'{"messages": [{"role": "system", "content": "<your_role>\\nReads articles from URLs.\\n</your_role>"}, {"role": "user", "content": "Please introduce yourself"}], "model": "ep-20250103180010-kv47b", "tool_choice": "auto", "tools": [{"type": "function", "function": {"name": "read_article", "description": "Use 
this function to read an article from a URL.", "parameters": {"type": "object", "properties": {"url": {"type": "string", "description": "(str) The URL of the article."}}, "required": ["url"]}}}]}'

hn_team

b'{"messages": [{"role": "system", "content": "<agent_team>\\nYou are the leader of a team of AI Agents:\\n- You can either respond directly or transfer tasks to other Agents in your team depending on the tools available to them.\\n- If you transfer a task to another Agent, make sure to include:\\n  - 
task_description (str): A clear description of the task.\\n  - expected_output (str): The expected output.\\n  - additional_information (str): Additional information that will help the Agent complete the task.\\n- You must always validate the output of the other Agents before responding to the user.\\n- You can
re-assign the task if you are not satisfied with the result.\\n</agent_team>\\n\\n<instructions>\\n- First, search hackernews for what the user is asking about.\\n- Then, ask the article reader to read the links for the stories to get more information.\\n- Important: you must provide the article reader with the
links to read.\\n- Then, ask the web searcher to search for each story to get more information.\\n- Finally, provide a thoughtful and engaging summary.\\n</instructions>\\n\\n<additional_information>\\n- Use markdown to format your answers.\\n</additional_information>\\n\\n<transfer_instructions>\\nYou can 
transfer tasks to the following Agents in your team:\\n\\nAgent 1:\\nName: HackerNews Researcher\\nRole: Gets top stories from hackernews.\\nAvailable tools: get_top_hackernews_stories, get_user_details\\n\\nAgent 2:\\nName: Web Searcher\\nRole: Searches the web for information on a topic\\nAvailable tools: 
duckduckgo_search, duckduckgo_news\\n\\nAgent 3:\\nName: Article Reader\\nRole: Reads articles from URLs.\\nAvailable tools: read_article\\n</transfer_instructions>"}, {"role": "user", "content": "Please introduce yourself"}], "model": "ep-20250103180010-kv47b", "tool_choice": "auto", "tools": [{"type": 
"function", "function": {"name": "transfer_task_to_hackernews_researcher", "description": "Use this function to transfer a task to hackernews_researcher\\nYou must provide a clear and concise description of the task the agent should achieve AND the expected output.\\nArgs:\\n    task_description (str): A clear 
and concise description of the task the agent should achieve.\\n    expected_output (str): The expected output from the agent.\\n    additional_information (Optional[str]): Additional information that will help the agent complete the task.\\nReturns:\\n    str: The result of the delegated task.\\n", 
"parameters": {"type": "object", "properties": {"task_description": {"type": "string"}, "expected_output": {"type": "string"}, "additional_information": {"type": ["string", "null"]}}, "required": ["task_description", "expected_output"]}}}, {"type": "function", "function": {"name": 
"transfer_task_to_web_searcher", "description": "Use this function to transfer a task to web_searcher\\nYou must provide a clear and concise description of the task the agent should achieve AND the expected output.\\nArgs:\\n    task_description (str): A clear and concise description of the task the agent 
should achieve.\\n    expected_output (str): The expected output from the agent.\\n    additional_information (Optional[str]): Additional information that will help the agent complete the task.\\nReturns:\\n    str: The result of the delegated task.\\n", "parameters": {"type": "object", "properties": 
{"task_description": {"type": "string"}, "expected_output": {"type": "string"}, "additional_information": {"type": ["string", "null"]}}, "required": ["task_description", "expected_output"]}}}, {"type": "function", "function": {"name": "transfer_task_to_article_reader", "description": "Use this function to 
transfer a task to article_reader\\nYou must provide a clear and concise description of the task the agent should achieve AND the expected output.\\nArgs:\\n    task_description (str): A clear and concise description of the task the agent should achieve.\\n    expected_output (str): The expected output from the
agent.\\n    additional_information (Optional[str]): Additional information that will help the agent complete the task.\\nReturns:\\n    str: The result of the delegated task.\\n", "parameters": {"type": "object", "properties": {"task_description": {"type": "string"}, "expected_output": {"type": "string"}, 
"additional_information": {"type": ["string", "null"]}}, "required": ["task_description", "expected_output"]}}}]}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants