#How to stream only the response of an assistant

1 messages · Page 1 of 1 (latest)

brittle mason
#

I have the following code to submit a tool response:

                    let id;
                    for (let tool of toolCall) {
                        id = tool.id;
                    }
                    run = openai.beta.threads.runs.submitToolOutputsStream(thread.id, run.id, {
                        tool_outputs: [{ output: JSON.stringify(results), tool_call_id: id}],
                    });

                    return new Response(stream);
                }

However this stream returns every single thing about the run. Is there some cleaner way to submit to the tool and then stream the response that the AI gives?

gloomy plankBOT
#

Hi @brittle mason. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

I'm sorry, but the knowledge sources provided do not contain information on how to stream only the response of an assistant using the OpenAI API. The sources do not provide any details on the submitToolOutputsStream method or how to filter the stream to only include the AI's response.

For more detailed information, I would recommend checking the official OpenAI API documentation or reaching out to OpenAI support.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@brittle mason kapa.ai is still learning and improving, please let us know how it did by reacting below

brittle mason
#

@gloomy plank How about streaming the response of an open ai assistant in general?

gloomy plankBOT
#

Let me check the knowledge base for you. One moment! :books:

#

Based on the provided knowledge sources, there isn't specific information on how to stream the response of an OpenAI assistant. The sources do not provide any details on streaming responses using the OpenAI API.

However, OpenAI does provide a method for creating an assistant and making requests to it, as shown in the following code snippet from the knowledge sources:

client = OpenAI(
    api_key=os.getenv("OPENAI_API_KEY_GPT_4"),
)

@retry_with_exponential_backoff
def completions_with_backoff(**kwargs):
    return client.chat.completions.create(**kwargs)

This code creates an OpenAI client with a specified API key and defines a function for making requests to the chat completion endpoint with exponential backoff for retries. The response from the assistant can be processed as needed.

For more detailed information on streaming responses, you may need to refer to the official OpenAI API documentation or OpenAI's community forums.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@brittle mason kapa.ai is still learning and improving, please let us know how it did by reacting below

brittle mason
#

@gloomy plank what does toolCallDelta do?

gloomy plankBOT
#

Let me check the knowledge base for you. One moment! :books:

#

I'm sorry, but the provided knowledge sources do not contain any information about toolCallDelta. For accurate information, please refer to the official OpenAI API documentation or the specific documentation related to the context where toolCallDelta is used.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: