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: update OpenAIAssistantAgent to use attachments rather than file_ids #13341

Merged
merged 5 commits into from
May 13, 2024

Conversation

naingthet
Copy link
Contributor

@naingthet naingthet commented May 7, 2024

Description

This PR addresses a bug with OpenAIAssistantAgent resulting from the transition from the file_ids kwarg to attachments kwarg when creating assistants. The present solution formats the existing file_ids into attachments objects, without specifying tools within each attachment, as this is optional (see here).

Another solution could be to add an attachments argument to OpenAIAssistantAgent methods. However, the present solution would be more seamless with any existing uses (i.e. it would not require any changes to any existing uses of this agent).

Fixes #12968

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@naingthet naingthet marked this pull request as ready for review May 7, 2024 20:24
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 7, 2024
@naingthet
Copy link
Contributor Author

After further inspection--I think this PR will work as a temporary fix, but the agent probably needs some refactoring to adopt the significant changes to how tools and files are passed in. The new Assistants API now has a tool_resources argument that divides file IDs (for code interpreter) and vector store IDs (for the new integrated vector stores). https://platform.openai.com/docs/api-reference/assistants/createAssistant

@logan-markewich
Copy link
Collaborator

Hmm, I tried running this but got TypeError: Assistants.create() got an unexpected keyword argument 'attachments'

I have openai==1.26.0 installed. Looking at the type hints, I don't think attachments is a valid kwarg here 🤔

@naingthet
Copy link
Contributor Author

Thanks for checking it out, will take another look. I don't think I set up my dev environment correctly...

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 8, 2024
@naingthet
Copy link
Contributor Author

naingthet commented May 8, 2024

With the latest change, the minimal functionality should be restored. But to get the full functionality of the Assistants API, I believe breaking changes will be required to use the new tool_resources (docs). I think that would be better as a separate PR?

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 13, 2024
@logan-markewich
Copy link
Collaborator

@naingthet I tried running a few of our openai assistant notebooks, and ran into this:

Error code: 400 - {'error': {'message': "Invalid value: 'retrieval'. Supported values are: 'code_interpreter', 'function', and 'file_search'.", 'type': 'invalid_request_error', 'param': 'tools[0].type', 'code': 'invalid_value'}}

Or

AttributeError: 'Task' object has no attribute 'strip'

Seems like its still pretty unstable 😅 But lets merge this for now, and in another PR you or me or someone can make a complete revamp here

@logan-markewich logan-markewich merged commit b7180c5 into run-llama:main May 13, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: OpenAIAssistantAgent now breaks because of OpenAI api changes
2 participants