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

fix: improve handling of tool_call_delta #1325

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

neverbiasu
Copy link

Please describe the purpose of this pull request.
This pull request is aimed at improving the handling of tool_call_delta in the openai.py script. It ensures that existing data is not overwritten unintentionally and that new arguments are appended to existing ones, rather than replacing them.

How to test
To test this PR, you can run the script and observe the behavior of the tool_call_delta handling. You should see that existing data is not overwritten and that new arguments are appended to existing ones. You can also add unit tests to verify this behavior.

Have you tested this PR?
As an AI, I'm unable to run tests. However, I recommend running unit tests and manually testing the script to ensure the changes work as expected.

Related issues or PRs
This PR doesn't relate to any existing issues or PRs in the repository.

Is your PR over 500 lines of code?
No, this PR is not over 500 lines of code. It only modifies a few lines in the openai.py script.

Additional context
This PR improves the handling of tool_call_delta in the openai.py script, making it more robust and less prone to errors. It's a small but important improvement to the codebase.

@cpacker cpacker changed the title completed1TODO fix: improve handling of tool_call_delta May 3, 2024
@cpacker cpacker self-requested a review May 3, 2024 19:59
Copy link
Owner

@cpacker cpacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assert is triggering on my end - it looks like it may be expected to see an overwrite in the incoming stream? Or maybe we should just check that the id == new id? I haven't taken a close look at the SSE pieces yet so I'm not sure exactly.

Hit enter to begin (will request first MemGPT message)



💭 User initiated activity detected. First interaction with Chad. Open 
with a gentle inquiry. Make it engaging for prolonged interaction.
  File "/Users/loaner/dev/MemGPT-2/memgpt/llm_api/openai.py", line 196, in openai_chat_completions_process_stream
    assert accum_message.tool_calls[tool_call_delta.index].id is None, "Overwriting existing data"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Overwriting existing data
? Retry agent.step()? (Y/n)

@neverbiasu
Copy link
Author

This assert is triggering on my end - it looks like it may be expected to see an overwrite in the incoming stream? Or maybe we should just check that the id == new id? I haven't taken a close look at the SSE pieces yet so I'm not sure exactly.

Hit enter to begin (will request first MemGPT message)



💭 User initiated activity detected. First interaction with Chad. Open 
with a gentle inquiry. Make it engaging for prolonged interaction.
  File "/Users/loaner/dev/MemGPT-2/memgpt/llm_api/openai.py", line 196, in openai_chat_completions_process_stream
    assert accum_message.tool_calls[tool_call_delta.index].id is None, "Overwriting existing data"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Overwriting existing data
? Retry agent.step()? (Y/n)

I see, trying to figure out. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

None yet

5 participants