vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
9.83k stars 1.46k forks source link

Support for OpenAI Assistants #721

Closed edouard-blocktool closed 11 months ago

edouard-blocktool commented 11 months ago

Feature Description

The new Assistants API from OpenAI unlocks the following:

  1. Not having to manage the thread history busting the context window
  2. Access to Code Interpreter & document embedding

It'd be great for Vercel AI client to leverage this API through Vercel AI and still benefit from the React useChat, useCompletion constructs.

Use Case

No response

Additional context

See https://platform.openai.com/docs/assistants/overview

edouard-blocktool commented 11 months ago

It's worth noting that OpenAI Assitants API does not support streaming yet. But they're planning to add it.

dosstx commented 11 months ago

I saw on X that the CEO of Vercel mentioned they are working on this.

MaxLeiter commented 11 months ago

We'll likely formally request comments and feedback on our work soon, but for now you can follow @lgrammel's great work here: #728. If anything jumps out to you as a problem (or a great addition!) please reply there so we can track it.

MaxLeiter commented 11 months ago

We've just released 2.2.24 with the first release of our experimental assistant APIs. Please give it a try and provide feedback! Proper documentation will be coming soon, but in the meantime you can refer to this doc and the example in the repo: https://github.com/vercel/ai/blob/main/examples/next-openai/app/api/assistant/assistant-setup.md

taylor-lindores-reeves commented 10 months ago

@MaxLeiter this API does not seem to support the body property in the useAssistant hook. I can't seem to access the body of the request in the route handler. Any ideas?

Edit: I was incorrectly passing FormData into the body. If you have any suggestions for passing in files to the API endpoint, it would be greatly appreciated!

harrywang commented 7 months ago

@MaxLeiter any pointer on how to upload a file to the assistant?

taylor-lindores-reeves commented 7 months ago

@MaxLeiter any pointer on how to upload a file to the assistant?

I did it here; https://youtu.be/ATf2GmkMPLk?si=-rouWrn8sruC2W1v

Although this is somewhat outdated now, but the concept of file upload using this API applies.

harrywang commented 7 months ago

@MaxLeiter any pointer on how to upload a file to the assistant?

I did it here; https://youtu.be/ATf2GmkMPLk?si=-rouWrn8sruC2W1v

Although this is somewhat outdated now, but the concept of file upload using this API applies.

@taylor-lindores-reeves thanks a lot. This is great. We will try. Hope steaming can be supported soon.

ekimcem commented 1 month ago

Can we also get the images generated by code_int. tool ?