NotImplementedError with Async Phidata Agents in Streamlit

Hi Phidata community!

I’m working on a Streamlit app that uses Phidata agents, and I’m running into a NotImplementedError when trying to use the async functionality. Here’s my current setup:

Agent Configuration:

from phi.agent import Agent
from phi.model.anthropic import Claude
from phi.tools.yfinance import YFinanceTools

finance_agent = Agent(
    name="Finance Agent",
    model=Claude(id=CLAUDE_MODEL_ID, api_key=ANTHROPIC_API_KEY, temperature=0.1),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True],
    instructions=["Use tables to display data."],
    show_tool_calls=True,
    markdown=True,
)

Streamlit Async Implementation:

async def main():
    if prompt := st.chat_input("Type your message here..."):
        st.session_state.messages.append({"role": "user", "content": prompt})
        display_message(st.session_state.messages[-1])
        
        response = await st.session_state.current_agent.arun(prompt)
        st.session_state.messages.append({"role": "assistant", "content": response})
        display_message(st.session_state.messages[-1])

When trying to run this, I get a NotImplementedError from the base model when calling arun(). Do I need to configure the Claude model differently for async operations?

Hi @Southern_Push2935
Thank you for reaching out and using Phidata! I’ve tagged the relevant engineers to assist you with your query. We aim to respond within 48 hours.
If this is urgent, please feel free to let us know, and we’ll do our best to prioritize it.
Thanks for your patience!

Hello @Southern_Push2935 !

Currently we support Async for OpenAIChat, Groq and Ollama. We are working on adding async support for more models. I just checked and Anthropic does support an AsyncAnthropic client. I am adding this to our feature requests and will get to it ASAP.

Anthropic is one of our most used providers and we will be treating this request with priority

1 Like