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

Mypy Agent class error #1674

Open
lucas-stellet opened this issue Jan 1, 2025 · 4 comments
Open

Mypy Agent class error #1674

lucas-stellet opened this issue Jan 1, 2025 · 4 comments

Comments

@lucas-stellet
Copy link

lucas-stellet commented Jan 1, 2025

Title: Mypy type checking error: Unexpected keyword argument "model" for "Agent"

Description:

When running Mypy for type checking, the following error is reported:

Unexpected keyword argument "model" for "Agent" Mypy (call-arg)

Code Example

from phi.agent import Agent
from phi.model.openai import OpenAIChat
from phi.tools.yfinance import YFinanceTools
from dotenv import load_dotenv

load_dotenv()

finance_agent = Agent(
    name="Finance Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[
        YFinanceTools(
            stock_price=True,
            analyst_recommendations=True,
            company_info=True,
            company_news=True,
            historical_prices=True,
        )
    ],
    instructions=["Use tables to display data"],
    show_tool_calls=True,
    markdown=True,
)

Expected Behavior

The type hints in the Agent class should properly define all accepted parameters in its constructor, including the model parameter.

Current Behavior

Mypy is reporting that the model parameter is not defined in the type hints for the Agent class constructor, even though the code works at runtime.

Environment

•	Python version: 3.13.1
•	phi-agent version: [Your phi-agent version]
•	mypy version: [Your mypy version]

Additional Notes

This appears to be a type hinting issue rather than a functional one, as the code executes correctly but fails Mypy's static type checking.

@dirkbrnd
Copy link
Contributor

dirkbrnd commented Jan 7, 2025

Hi @lucas-stellet
I ran mypy on that code snippet and didn't get any issues. Did you see the warning when running the validate.sh script?

@lucas-stellet
Copy link
Author

Hi @dirkbrnd

I see this warning in my vscode using an Mypy extension.

image

image

The command being executed by extension was:

mypy --no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-error-end /Users/lucas/dev/learn/ai/hands-on/agents-with-phidata/web_search_agent.py

/Users/lucas/dev/learn/ai/hands-on/agents-with-phidata/web_search_agent.py:9:20:18:1: error: Unexpected keyword argument "model" for "Agent"  [call-arg]

/Users/lucas/dev/learn/ai/hands-on/agents-with-phidata/web_search_agent.py:12:11:12:11: error: Name "Groq" is not defined  [name-defined]

@lucas-stellet
Copy link
Author

I published the code in a repository:

https://github.com/lucas-stellet/agents-with-phidata

@dirkbrnd
Copy link
Contributor

dirkbrnd commented Jan 8, 2025

@lucas-stellet it could be the mypy settings in your repo or something with your plugin?
I'm running this on the latest version of phidata, mypy 1.14.1 and the pyproject.toml mypy config in the phidata repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants