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

[Bug]: Error during parsing ollama return. #5090

Closed
1 task done
uzhao opened this issue Nov 17, 2024 · 6 comments · Fixed by #5026
Closed
1 task done

[Bug]: Error during parsing ollama return. #5090

uzhao opened this issue Nov 17, 2024 · 6 comments · Fixed by #5026
Labels
bug Something isn't working

Comments

@uzhao
Copy link

uzhao commented Nov 17, 2024

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Describe the bug and reproduction steps

I'm tring local ollama qwen2.5coder 32b model. Agent tried to get content field which doesn't exist. The command I used to start openhands is
docker run -it \ --rm \ --pull=always \ -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.14-nikolaik \ -e SANDBOX_USER_ID=$(id -u) \ -e WORKSPACE_MOUNT_PATH=/home/papillon/eden/apple \ -e LLM_MODEL=ollama/qwen \ -e LLM_OLLAMA_BASE_URL=http://host.docker.internal:11435 \ -e LLM_BASE_URL=http://host.docker.internal:11435 \ -v /home/papillon/eden/apple:/workspace \ -v /var/run/docker.sock:/var/run/docker.sock \ --add-host host.docker.internal:host-gateway \ --name openhands-app-apple \ docker.all-hands.dev/all-hands-ai/openhands:0.14 \ python -m openhands.core.cli

and error I got is

Traceback (most recent call last):
File "/app/openhands/controller/agent_controller.py", line 202, in start_step_loop
await self._step()
File "/app/openhands/controller/agent_controller.py", line 483, in _step
action = self.agent.step(self.state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 334, in step
response = self.llm.completion(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 336, in wrapped_f
return copy(f, *args, **kw)
^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 475, in call
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 376, in iter
result = action(retry_state)
^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 398, in
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/app/.venv/lib/python3.12/site-packages/tenacity/init.py", line 478, in call
result = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/app/openhands/llm/llm.py", line 196, in wrapper
messages = convert_fncall_messages_to_non_fncall_messages(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/openhands/llm/fn_call_converter.py", line 322, in convert_fncall_messages_to_non_fncall_messages
role, content = message['role'], message['content']
~~~~~~~^^^^^^^^^^^
KeyError: 'content'

I also have a proxy to log transcript between agent and ollama. Here is the chat log.

Time: 2024-11-17 05:53:16
Endpoint: /api/generate
Request:
{
"model": "qwen",
"prompt": "--------------------- NEW TASK DESCRIPTION ---------------------\n/workspace目录下有哪些文件?--------------------- END OF NEW TASK DESCRIPTION ---------------------\n\nPLEASE follow the format strictly! PLEASE EMIT ONE AND ONLY ONE FUNCTION CALL PER MESSAGE.\n\n\n",
"options": {
"temperature": 0.0,
"top_p": 1.0,
"stop": [
"</function"
]
},
"stream": false
}
Response:
{
"model": "qwen",
"created_at": "2024-11-17T10:53:28.121734314Z",
"response": "<function=execute_bash>\n<parameter=command>\nls /workspace\n\n",
"done": true,
"done_reason": "stop",
"context": [
151644,
8948,
198,
...
],
"total_duration": 11151593064,
"load_duration": 14279532,
"prompt_eval_count": 4042,
"prompt_eval_duration": 626000000,
"eval_count": 21,
"eval_duration": 10510000000
}

OpenHands Installation

Docker command in README

OpenHands Version

0.14

Operating System

Linux

Logs, Errors, Screenshots, and Additional Context

No response

@mamoodi
Copy link
Collaborator

mamoodi commented Nov 18, 2024

I'm unfortunately not familiar with ollama at all.
Just wondering if you run it the same way as this comment: #3960 (comment)

Does it work? Set the model and base url through the UI.

@enyst
Copy link
Collaborator

enyst commented Nov 18, 2024

convert_fncall_messages_to_non_fncall_messages
role, content = message['role'], message['content']
KeyError: 'content'

This is a bug, solved in this PR.

@AidyTheWeird
Copy link

convert_fncall_messages_to_non_fncall_messages
role, content = message['role'], message['content']
KeyError: 'content'

This is a bug, solved in this PR.

Worked yesterday but now it throws this:

Traceback (most recent call last):
  File "/app/openhands/controller/agent_controller.py", line 204, in start_step_loop
    await self._step()
  File "/app/openhands/controller/agent_controller.py", line 485, in _step
    action = self.agent.step(self.state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/agenthub/codeact_agent/codeact_agent.py", line 333, in step
    response = self.llm.completion(**params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 336, in wrapped_f
    return copy(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 475, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 376, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 398, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/app/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 478, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/llm/llm.py", line 187, in wrapper
    messages = Message.convert_messages_to_non_native(messages, kwargs['tools'])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/openhands/core/message.py", line 350, in convert_messages_to_non_native
    tool_call_id=message['tool_call_id'],
                 ~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'tool_call_id'

@enyst
Copy link
Collaborator

enyst commented Nov 20, 2024

@AidyTheWeird oh, on the PR branch? Sorry about that, yes, I thought it was working, but I needed to refactor the code and it might be broken right now.

Could you tell how you were running it? If via git, then git reset --hard 2d4f02cd56ca1a74f07930eb5e0ff3a0cf9a2ec6 should work.

@AidyTheWeird
Copy link

AidyTheWeird commented Nov 20, 2024

I run through docker

docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:07c3643-nikolaik --name openhands-app-07c3643 docker.all-hands.dev/all-hands-ai/openhands:07c3643

edit: trying docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:ffca2b4-nikolaik --name openhands-app-ffca2b4 docker.all-hands.dev/all-hands-ai/openhands:ffca2b4

@enyst
Copy link
Collaborator

enyst commented Nov 20, 2024

I think you're right, the second should work and/or it might take a bit to finish CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants