adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Deepseek Model code 422

Open About-Gleaning opened this issue 1 year ago • 3 comments

this is my code:

import os
from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm


def get_weather(city: str) -> str:
    """Retrieves the current weather report for a specified city.

    Args:
        city (str): The name of the city for which to retrieve the weather report.

    Returns:
        str: result or error msg.
    """
    if city.lower() == "new york":
        return "The weather in New York is sunny with a temperature of 25 degrees"
    else:
        return f"Weather information for '{city}' is not available."


root_agent = Agent(
    name="weather_agent",
    model=LiteLlm(model="deepseek/deepseek-chat"), # Specifies the underlying LLM
    description="Provides weather information for specific cities.", # Crucial for delegation later
    instruction="You are a helpful agent who can answer user questions about the time and weather in a city.",
    tools=[get_weather] # Make the tool available to this agent
)

error msg:

INFO - _client.py:1740 - HTTP Request: POST https://api.deepseek.com/beta/chat/completions "HTTP/1.1 422 Unprocessable Entity"

ERROR - fast_api.py:616 - Error in event_generator: litellm.BadRequestError: DeepseekException - Failed to deserialize the JSON body into the target type: messages[2]: invalid type: sequence, expected a string at line 1 column 587

this is LLM request:

LLM Request:
-----------------------------------------------------------
System Instruction:
You are a helpful agent who can answer user questions about the time and weather in a city.

You are an agent. Your internal name is "weather_agent".

 The description about you is "Provides weather information for specific cities."
-----------------------------------------------------------
Contents:
{"parts":[{"text":"What is the weather in New York?"}],"role":"user"}
{"parts":[{"function_call":{"id":"call_0_c657e3f7-3809-4508-9f98-e03c4a5a14c8","args":{"city":"New York"},"name":"get_weather"}}],"role":"model"}
{"parts":[{"function_response":{"id":"call_0_c657e3f7-3809-4508-9f98-e03c4a5a14c8","name":"get_weather","response":{"result":"The weather in New York is sunny with a temperature of 25 degrees"}}}],"role":"user"}
-----------------------------------------------------------
Functions:
get_weather: {'city': {'type': <Type.STRING: 'STRING'>}} -> None
-----------------------------------------------------------

About-Gleaning avatar Apr 16 '25 14:04 About-Gleaning

Could you try to build a wheel from the source code to see if your issue is addressed?

hangfei avatar Apr 17 '25 00:04 hangfei

@hangfei I had similar issue can confirm:

pip uninstall -y google-adk
pip install --no-cache-dir git+https://github.com/google/adk-python@main

resolves the issue.

rosszhang1 avatar Apr 17 '25 00:04 rosszhang1

@hangfei yeah, it`s work! thank you

About-Gleaning avatar Apr 17 '25 01:04 About-Gleaning