Fix Unit Test Failures in OpenAI, Anthropic, and Google Gemini Resolvers
Fixed all errors in #1536
This pull request addresses multiple failures in the unit tests for the libraries used in OpenAI Assistants, Anthropic, and Google. Here are the key changes made to resolve these issues:
Bug Description:
-
Anthropic Library:
- Issue: The type
ContentBlockhas been updated to a Union type which cannot be instantiated. It now represents bothTextBlockandToolUseBlock.ContentBlock = Annotated[Union[TextBlock, ToolUseBlock], PropertyInfo(discriminator="type")] - Fix: Replaced
ContentBlockwithTextBlockin the relevant sections of the code.
- Issue: The type
-
OpenAI Library:
- Issue: The assistant API has breaking changes:
-
retrievaltool renamed tofile_search -
assistant.file_idsparameter changed totool_resources -
message.file_idsparameter changed toattachments
-
- Fix: Updated the code to reflect these changes.
- Issue: The assistant API has breaking changes:
-
Gemini Library:
-
Issue: An error exists in the Gemini library where it incorrectly parses a protobuf object as a dictionary.
-
Fix: Implemented a workaround to avoid this parsing bug.
-
Reference:
- https://github.com/google-gemini/generative-ai-python/blob/419a7cef81188a2d715b3853113a3213516d6a4a/google/generativeai/types/generation_types.py#L416
- I believe it is this issue: https://github.com/google-gemini/generative-ai-python/issues/288
-
To Reproduce: Run the unit tests for version 3.0.1 to observe the failures.
Changes Made:
- Replaced
ContentBlockwithTextBlockin the Anthropic library code. - Updated the assistant API in the OpenAI library to use the new parameters and tool names.
- Added a workaround to handle the protobuf parsing issue in the Gemini library.
Environment:
- OS: macOS
- Python Version: 3.9.0
- Library Version: 3.0.1
This pull request ensures that all unit tests pass successfully, and the libraries are compatible with the latest updates and changes.
F
Hi @ikrnwath sorry but I am not sure what you mean. Please let me know if I need to make any changes .