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

Azure OpenAI: KeyError: 'function_call' #980

Closed
2 tasks
ArneJanning opened this issue Feb 9, 2024 · 2 comments · Fixed by #982
Closed
2 tasks

Azure OpenAI: KeyError: 'function_call' #980

ArneJanning opened this issue Feb 9, 2024 · 2 comments · Fixed by #982
Assignees

Comments

@ArneJanning
Copy link

ArneJanning commented Feb 9, 2024

Describe the bug

At the first call to the LLM using Azure OpenAI/GPT-4 right after starting MemGPT I get this error:

An exception occurred when running agent.step(): 
Traceback (most recent call last):
  File "box/box.py", line 592, in box.box.Box.__getitem__
KeyError: 'function_call'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "box/box.py", line 631, in box.box.Box.__getattr__
  File "box/box.py", line 619, in box.box.Box.__getitem__
box.exceptions.BoxKeyError: "'function_call'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "box/box.py", line 633, in box.box.Box.__getattr__
AttributeError: 'Box' object has no attribute 'function_call'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/arne/src/MemGPT/memgpt/main.py", line 347, in run_agent_loop
    new_messages, user_message, skip_next_user_input = process_agent_step(user_message, no_verify)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arne/src/MemGPT/memgpt/main.py", line 323, in process_agent_step
    new_messages, heartbeat_request, function_failed, token_warning, tokens_accumulated = memgpt_agent.step(
                                                                                          ^^^^^^^^^^^^^^^^^^
  File "/home/arne/src/MemGPT/memgpt/agent.py", line 673, in step
    raise e
  File "/home/arne/src/MemGPT/memgpt/agent.py", line 597, in step
    if verify_first_message_correctness(response, require_monologue=self.first_message_verify_mono):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arne/src/MemGPT/memgpt/utils.py", line 671, in verify_first_message_correctness
    if require_send_message and not (response_message.function_call or response_message.tool_calls):
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "box/box.py", line 647, in box.box.Box.__getattr__
box.exceptions.BoxKeyError: "'Box' object has no attribute 'function_call'"

Please describe your setup

  • How did you install memgpt?
    • git clone, poetry install
  • Describe your setup
    • What's your OS: Linux/WSL2
    • How are you running memgpt? Terminal/ZSH

@cpacker cpacker self-assigned this Feb 9, 2024
@cpacker cpacker moved this from To triage to Ready in 🐛 MemGPT issue tracker Feb 9, 2024
@cpacker cpacker moved this from Ready to In progress in 🐛 MemGPT issue tracker Feb 9, 2024
@cpacker cpacker linked a pull request Feb 9, 2024 that will close this issue
2 tasks
@cpacker
Copy link
Collaborator

cpacker commented Feb 9, 2024

Hi @ArneJanning , thank you for the bug report!

This should be fixed in an incoming patch on #982 (specifically the key error you're seeing should be gone).

However, I'm noticing that the newer versions of gpt-4-turbo are frequently calling functions without any content field, even with in-context examples that demonstrate to the LLM otherwise. So if you're using gpt-4-turbo on Azure, you may need to run --no-verify with your memgpt run to actually get any output to get generated.

@github-project-automation github-project-automation bot moved this from In progress to Done in 🐛 MemGPT issue tracker Feb 9, 2024
@ArneJanning
Copy link
Author

ArneJanning commented Feb 9, 2024

Hi @cpacker , thank you for the quick fix!

I checked out #982 and re-ran memgpt configure.

Ran into an error right after the start before the first call to the LLM:

  File "/home/arne/src/MemGPT/memgpt/llm_api_tools.py", line 255, in azure_openai_chat_completions_request
    assert resource_name is not None, "Missing required field when calling Azure OpenAI"
           ^^^^^^^^^^^^^^^^^^^^^^^^^

Turns out that the embedding_deployment and endpoint values were missing from the [azure]-section in the credentials-file. After adding them manually, everything worked as expected.

And yes, we have to run --no-verify with memgpt run otherwise memgpt get's stuck in "thinking...".

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

Successfully merging a pull request may close this issue.

2 participants