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

Error when using Hugginface Inference API with Phidata tools #1618

Open
nagendragillalu opened this issue Dec 20, 2024 · 2 comments
Open

Error when using Hugginface Inference API with Phidata tools #1618

nagendragillalu opened this issue Dec 20, 2024 · 2 comments

Comments

@nagendragillalu
Copy link

I am trying to execute a demo example using Hugging face Inference API using phidata tools
though I change to any model I get following error

[/usr/local/lib/python3.10/dist-packages/phi/agent/agent.py](https://localhost:8080/#) in print_response(self, message, messages, stream, markdown, show_message, show_reasoning, show_full_reasoning, console, **kwargs)
   2810                     live_log.update(Group(*panels))
   2811 
-> 2812                 for resp in self.run(message=message, messages=messages, stream=True, **kwargs):
   2813                     if isinstance(resp, RunResponse) and isinstance(resp.content, str):
   2814                         if resp.event == RunEvent.run_response:

[/usr/local/lib/python3.10/dist-packages/phi/agent/agent.py](https://localhost:8080/#) in _run(self, message, stream, audio, images, videos, messages, stream_intermediate_steps, **kwargs)
   1804         if self.stream:
   1805             model_response = ModelResponse(content="")
-> 1806             for model_response_chunk in self.model.response_stream(messages=messages_for_model):
   1807                 if model_response_chunk.event == ModelResponseEvent.assistant_response.value:
   1808                     if model_response_chunk.content is not None and model_response.content is not None:

[/usr/local/lib/python3.10/dist-packages/phi/model/huggingface/hf.py](https://localhost:8080/#) in response_stream(self, messages)
    734 
    735         if stream_data.response_tool_calls is not None:
--> 736             _tool_calls = self._build_tool_calls(stream_data.response_tool_calls)
    737             if len(_tool_calls) > 0:
    738                 assistant_message.tool_calls = _tool_calls

[/usr/local/lib/python3.10/dist-packages/phi/model/huggingface/hf.py](https://localhost:8080/#) in _build_tool_calls(self, tool_calls_data)
    824         for _tool_call in tool_calls_data:
    825             _index = _tool_call.index
--> 826             _tool_call_id = _tool_call.id
    827             _tool_call_type = _tool_call.type
    828             _function_name = _tool_call.function.name if _tool_call.function else None

AttributeError: 'str' object has no attribute 'id'

This is my sample agent

from phi.agent import Agent
from phi.model.huggingface import HuggingFaceChat
from phi.tools.duckduckgo import DuckDuckGo
import os 

web_agent = Agent(
    name="Web Agent",
    model=HuggingFaceChat(
        id="meta-llama/Meta-Llama-3-8B-Instruct",
        max_tokens=4096,
    ),
    tools=[DuckDuckGo()],
    instructions=["Always include sources"],
    show_tool_calls=True,
    markdown=True,
)
web_agent.print_response("Whats happening in France?", stream=True)
@ysolanky
Copy link
Contributor

Hello @nagendragillalu I was able to replicate this issue with HuggingFaceChat. Our HuggingFaceChat model class requires an update and I am on it. Sharing updates soon!

@omkarjoshi
Copy link

@ysolanky : any timeline when this will be fixed ?

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

3 participants