langchain icon indicating copy to clipboard operation
langchain copied to clipboard

OpenAI Assistants v2 api support for OpenAIAssistantRunnable

Open codeonprod opened this issue 1 year ago • 11 comments

Title: "langchain: OpenAI Assistants v2 api support"

Descriptions

  • [x] As per latest OpenAI, "file_ids" are no supported and replaced with "attachments"

    • Issue: error_code: 400: invalid keyword file_ids
  • [x] "tool_resources" support added while creating new assistant

  • Dependencies: OpenAI v2 API (openai>=1.23.0)

  • Twitter handle: @skanta_rath

codeonprod avatar May 09 '24 14:05 codeonprod

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 10:26pm

vercel[bot] avatar May 09 '24 14:05 vercel[bot]

Hello! @eyurtsev @Anush008 @efriis @cbornet

Do you think you could help us here reviewing and approving? This is blocking the new OpenAI v2 Assistants and it's quite urgent :cry:

Thank you very much! :heart:

mbonet avatar May 14 '24 16:05 mbonet

Will older versions of openai <1.23.6 still work after this change ?

cbornet avatar May 14 '24 18:05 cbornet

mb unrelated question but OpenAI v2 Assistant now supports tool_choice parameter and streaming. Does it covered?

Enase avatar May 14 '24 18:05 Enase

Will older versions of openai <1.23.6 still work after this change ?

Yes. They will work as these changes are backward compatible

codeonprod avatar May 14 '24 18:05 codeonprod

@Surya-Kanta thanks for your fast iteration!

@Enase, Surya just added compatibility with tool_choice. As for streaming is not implemented yet. Please keep in mind that this PR is bugfixing not a new feature. Currently the assistants can't be migrated to v2 :cry:

mbonet avatar May 15 '24 05:05 mbonet

@mbonet I will then continue working on complete migration of Assistants v2 in this branch.

codeonprod avatar May 15 '24 05:05 codeonprod

@cbornet @Enase can we then merge? :pray:

mbonet avatar May 16 '24 05:05 mbonet

I have already finished upgrade for all breaking changes related to v2 migration apart from streaming related changes. But I don't think streaming is a part of the upgrade. So, that should be a separate PR.

Anyone want to contribute in this PR are welcome in advance.

codeonprod avatar May 16 '24 08:05 codeonprod

would be great to have this in the next release, as it's required to use the Assistants API v2 when you wanna use it in combination with GPT4o

dentroai avatar May 16 '24 16:05 dentroai

@Enase, Surya just added compatibility with tool_choice

It's not true even if you fix the obvious issues, thanks for your effort but I don't get the reason why you declare something that wasn't done.

Enase avatar May 17 '24 01:05 Enase

Hi all, thank you for this. To avoid breaking changes with earlier versions of the openai sdk I've moved this to a new class OpenAIAssistantV2Runnable. I've marked it as beta. Please post your feedback; PRs are also welcome.

ccurme avatar May 21 '24 22:05 ccurme

@ccurme thanks!

mbonet avatar May 22 '24 05:05 mbonet

Hello, has the update been released?

josantosc avatar May 23 '24 20:05 josantosc

Hello, has the update been released?

This was moved to langchain-community and released today. If you pip install langchain-community==0.2.1 you can import it with:

from langchain_community.agents.openai_assistant import OpenAIAssistantV2Runnable

API reference: https://api.python.langchain.com/en/latest/agents/langchain_community.agents.openai_assistant.base.OpenAIAssistantV2Runnable.html

Note that this class is marked as beta; we welcome issues / PRs if you run into anything.

ccurme avatar May 23 '24 22:05 ccurme

This is great. Does it support streaming yet?

dar747 avatar May 27 '24 17:05 dar747

@ccurme do you think we can improve the original docs?
https://api.python.langchain.com/en/latest/agents/langchain.agents.openai_assistant.base_v2.OpenAIAssistantV2Runnable.html

The suggested import is quite wrong langchain.agents no?

from langchain.agents.openai_assistant import OpenAIAssistantV2Runnable

As you pointed it should be from langchain_community namespace and it took me a good 2 hrs to notice this discrepancy :cry:

mbonet avatar May 29 '24 11:05 mbonet

Looks like the pipeline is failing for this merge? Any indication when this will be successfully merged?

@codeonprod thanks for doing this!

DLOVRIC2 avatar Sep 07 '24 18:09 DLOVRIC2