ai-chatbot icon indicating copy to clipboard operation
ai-chatbot copied to clipboard

Support OpenAI Assistants + Threads

Open burn2delete opened this issue 10 months ago • 11 comments

Hello,

I wanted to update the template to use OpenAI Assistants + Threads. In the comments it says it's supported but I can't seem to figure out where I can update this.

burn2delete avatar Apr 24 '24 18:04 burn2delete

There isn't really any implementation of Assistants in the template, so you'd have to implement it from scratch. There's a lot of reusable code though, and tools/GenUI work well with Assistants too, So You can draw inspiration from that.

athrael-soju avatar Apr 24 '24 20:04 athrael-soju

... but I can't seem to figure out where I can update this

submitUserMessage() function in lib/chat/actions.tsx is probably a good start

kevb10 avatar May 09 '24 13:05 kevb10

@athrael-soju How does genUI work with assistants?

GoodestUsername avatar May 14 '24 15:05 GoodestUsername

Same question here

smuk3c avatar May 15 '24 10:05 smuk3c

@burn2delete did you manage to replace completion with assistant?

smuk3c avatar May 18 '24 13:05 smuk3c

I spent quite a bit of time yesterday trying to get this template to work with OpenAI Assistants ... did not have any luck tbh

Kept running into one issue after another.

It's not just the lib/chat/actions.tsx file that needs to be updated ... all of the logic that currently stores messages and maps the messages to threads and threads to users in Vercel KV also needs to be updated to instead store thread IDs of the Assistant threads in OpenAI. Vercel KV can be used to keep track of which threads belong to which user, but there's no need to store all messages in KV anymore.

It would be really great if the maintainers of this template created a version that worked out of the box with OAI Assistants. Would be much more powerful.

Some of the stock UI streaming stuff is overkill and takes a long time to remove from the template. Very cool demo though.

BaileySimrell avatar May 26 '24 16:05 BaileySimrell

@athrael-soju How does genUI work with assistants?

Sorry for the late reply. Just saw this.

Assistants can also use function calls, but this template is too embedded with Completions API via Vercel AI and also has several unresolved issues. I really wouldn't suggest you integrate assistants here and instead use this: https://github.com/openai/openai-assistants-quickstart

You can then integrate genUI on top of that template instead.

Either that, or wait for the next Vercel genUI template, which will likely be based on next.js 15 and hopefully less buggy.

I hope that helps.

athrael-soju avatar May 26 '24 18:05 athrael-soju

@athrael-soju How does genUI work with assistants?

Sorry for the late reply. Just saw this.

Assistants can also use function calls, but this template is too embedded with Completions API via Vercel AI and also has several unresolved issues. I really wouldn't suggest you integrate assistants here and instead use this: https://github.com/openai/openai-assistants-quickstart

You can then integrate genUI on top of that template instead.

Either that, or wait for the next Vercel genUI template, which will likely be based on next.js 15 and hopefully less buggy.

I hope that helps.

I agree with this ... the OpenAI template is very good, though the UI is bare bones (https://github.com/openai/openai-assistants-quickstart)[https://github.com/openai/openai-assistants-quickstart]

BaileySimrell avatar May 26 '24 18:05 BaileySimrell

Is there an update on getting an OpenAI Assistant to work with vercel ai-chatbot?

tradiecart avatar Aug 24 '24 00:08 tradiecart

Hi @tradiecart! I found a cool example that shows how to stream responses, make tool calls, and create interactive UI components using OpenAI's Assistant API with ai/rsc. Check it out!

👉 Stream Assistant Responses with Tools using ai/rsc

agustints avatar Aug 28 '24 22:08 agustints

thank you @agustints

tradiecart avatar Aug 29 '24 00:08 tradiecart