I currently have a chat feature in a NestJS application that uses the openai createChatCompletion API to generate a message based on user input and stream the response back to the client. With the addition of function calls to the openai API functionality, I want to optionally execute function calls that will save records in my DB, and after saving I want to generate another message and stream the response to the client. When no function call is generated I just want to standardly stream the generated message as I currently do.
The problem is that I have to specify in the API call for the chat completion whether the response should be streamed or not, but I only want it to be streamed when it's not going to return a function call.
Appreciate any advice on how I can potentially determine whether a function call or message will be generated before sending out the response.
from Determine whether OpenAI chat completion will execute function call or generate message
No comments:
Post a Comment