https://retellai.com/?utm_source=discord&utm_medium=seo logo
Passing data from client to custom LLM
# ❓・bug-report
c
Is there any way to pass data from the client to a custom LLM? There's a
metadata
event that lets you post data from the LLM to the client, but is there anything that goes the other way? (Even just one time, when the call is being set up?)
m
You already need to message a backend server to start a conversation, might as well do the same for sending data to the LLM, no?
Getting data from it to the client needs that metadata event because the client can’t act as a HTTP server, but the server you use to start the call is already available to the client
Or if the LLM is on a different server you can message it directly or have the backend server relay a request to it
Though I can totally see why’d you want to send it over the websocket
Saves a lot of time over starting a new TLS connection
You could propose that in #📒・feature-requests
c
Right, for proper messaging, you could open a new WebSocket to the agent server, and match the call ID. I was hoping there was an easier way, like there is with the metadata from server to client 😅
m
None that I personally know of
c
Yeah, I've ended up writing the message to a shared database, along with the call ID. Then I just look it up when Retell connects to the server. It's not ideal, but it works well enough for a single message!
m
Wait
Your frontend writes to a database?
c
My Next.js app writes to the database, (on the server-side). And then I have a second server app for the Retell Custom LLM.
m
Oh, server side
Never mind then
w
Do you use a web call? You can pass information in metadata or dynamic variables: https://docs.retellai.com/api-references/create-web-call
c
Thanks! I saw that, (and I am actually using that to log some other details about the call). Is there an easy way to access that data on the custom LLM server when the session starts? It looks like it’s really designed for logging.
n
@chris.nolet so if you are using the metadata field in the create web call API, then you can access that when the websocket session starts by using the `call_details`event https://docs.retellai.com/api-references/llm-websocket#call-details-event That way you have a one-off way of accessing the data in your LLM websocket logic. Otherwise I dont think the client and LLM websocket are directly connected, since the LLM is to be connected only to the Retell conversation flow