https://retellai.com/?utm_source=discord&utm_medium=seo logo
Using OpenAI Assistant for custom LLM?
# ❓・bug-report
j
New to using a custom LLM, so please bear with me. I'm prototyping an agent for a client that requires more resources than will fit in a prompt, so I attached them in a VS to an OpenAI Assistant. I'm working with a custom LLM agent tied to a Twilio number via websocket. Using this repo: https://github.com/RetellAI/retell-custom-llm-python-demo) I want to modify it to switch from
gpt-4-turbo
to an OpenAI Assistant. The current code in
llm_with_func_calling.py
uses
client.chat.completions.create():
Copy code
async def draft_response(self, request: ResponseRequiredRequest):
    prompt = self.prepare_prompt(request)
    stream = await self.client.chat.completions.create(
        model="gpt-4-turbo-preview",
        messages=prompt,
        stream=True,
        tools=self.prepare_functions(),
    )
Since Assistants use
threads/runs/messages
instead of
chat.completions
, do I just replace the completions code with the Assistant invocation? Is there anything specific I need to tweak, or will it even work? Couldn't find any example repos for this setup so any help is appreciated! Or if anyone could share an example? Or ... if RAG is going to be out Monday or something lol , I won't even bother with this 🥴 Thanks!
w
RAG will be available soon!
n
Hey @jessicaj_30604 I have built an end 2 end working custom LLM with OpenAI Assistants API. You can DM me and we can talk about it But I will give you a heads up: 1.) Its latency is quite high because of the entire mechanism of threads + messages which it uses. Also handling interruptions by user is quite painful since Assistants API is not made for realtime voice interactions 2.) To answer your question, you basically have to write some methods to create a thread and add messages to it everytime a new message comes and then re-run the thread to get the response. But here you have to handle interruptions where if a new message comes while the previous thread is running, then you have to first cancel the running thread and then re-run the thread
And I would second @Weijia - Support@Retell and tell you to wait for the RAG feature support
j
Thanks for input @NJ ! I'm leaning towards waiting for RAG too so I don't do a bunch of work in vain (and now I remember seeing some of your comments about the latency issues) but I have someone impatient for me to build this thing. @Weijia - Support@Retell I won't hold you to anything but is soon like a couple weeks or month+?
u
@Weijia - Support@Retell we also have customers waiting on RAG so if there's an ETA it'll help us plan ahead 🙂 Thanks so much!