huggingface / huggingface/smolagents
Expected tool format of LiteLLM for ollama is not followed by Smollagent example Tools
- Dominant language
- Python
- Stars
- 29.3k
- Forks
- 3k
- Avg merge
- 17m
- Merged PRs (30d)
- 2
Description
I tried to follow this tutorial with ollama models:
https://huggingface.co/docs/smolagents/tutorials/inspect_runs
This the error tracked by phoenix:
```
APIConnectionError: litellm.APIConnectionError: 'name' Traceback (most recent call last): File "C:\GIT\python\hello-smolagents\.venv\Lib\site-packages\litellm\main.py", line 2690, in completion response = base_llm_http_handler.completion( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\GIT\python\hello-smolagents\.venv\Lib\site-packages\litellm\llms\custom_httpx\llm_http_handler.py", line 334, in completion return provider_config.transform_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\GIT\python\hello-smolagents\.venv\Lib\site-packages\litellm\llms\ollama\completion\transformation.py", line 264, in transform_response "name": function_call["name"], ~~~~~~~~~~~~~^^^^^^^^ KeyError: 'name'
```
This is what is happening in transformation.py arround line 264:
```
function_call = json.loads(response_json["response"])
message = litellm.Message(
content=None,
tool_calls=[
{
"id": f"call_{str(uuid.uuid4())}",
"function": {
"name": function_call["name"],
"arguments": json.dumps(function_call["arguments"]),
},
"type": "function",
}
],
)
```
Lite LLM tries to use keys 'name' and 'argument' unfortunately 'function_call ' contains response:
```
{'tool_name': 'web_search', 'tool_arguments': {'query': 'projected GDP growth rate United States 2024'}}
```
Which does not match the keys. I had a look at smollagents prompts.py, which has examples like:
```
Task: "Which city has the highest population , Guangzhou or Shanghai?"
Action:
{
"tool_name": "search",
"tool_arguments": "Population Guangzhou"
}
```
So please fix the example tools, to match the LiteLLM 'litellm/llms/ollama/completion/transformation.py' implementation.
Contributor guide
Research direction
Start with the examples in prompts.py and the inspect_runs tutorial, then compare their tool format with LiteLLM's Ollama transformation.py implementation mentioned in the report. Update the example tools so their format matches the expected Ollama response, and verify that the tutorial no longer produces the reported KeyError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ollama, python
- Domain
- ai, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100