Hello,
I’m trying to receive multiple responses on the request with multiple messages in single Run.
Particularly, I’m creating Run for Assistant using this call:
API Call: /threads/runs
and sending the following request body with 4 messages:
{
“assistant_id”: “asst_xxx”,
“thread”: {
“messages”: [
{
“role”: “user”,
“content”: “Generate first dialog between Tutor and Student studing ‘History of Rome’…”
},
{
“role”: “user”,
“content”: “Create second dialog between Tutor and Student for the same topic…”
},
{
“role”: “user”,
“content”: “Compare first and second dialogs.”
},
{
“role”: “user”,
“content”: “Provide feedback to the Student based on the dialogs with Tutor.”
}
]
},
“stream”: false
}
At this moment I assume that OpenAI engine is running my messages one-by-one and generating 4 messages in response…
While waiting - I continuously checking: API Call: /threads/{threadId}/runs/{runId}/steps
If I receive ‘response.has_more’ is false - I assume that response has been generated for all 4 messages.
But in fact, I only receive single Step with single Content item. It looks like it answers my first message, but not 2,3,4 messages.
What I’m doing wrong and how can I generate 4 response messages to my 4 original prompt messages?
Your assumption is wrong.
A thread is for passing conversations.
User turns before the current one will be seen as past questions (perhaps already answered without the answer being seen.
They might provide some context, but the earlier questions are unlikely to be acted on, and if so, only in one response.
It seems what you want can be produced by a single input, and it does not need the use of the assistants endpoint for maintaining a conversation. It just needs to have the understanding of what to do increased.
user message:
Here are the tasks you will perform, each having a standalone answer in your response, each reflecting on the previous part as a standalone message, where Student has learning difficulties:
- Generate a first dialog between Tutor and Student studying ‘History of Rome’, 2 exchanges;
- Create second dialog between Tutor and Student for the same topic;
- Provide a comparison of topical and stylistic differences between the first and second dialogs;
- Provide feedback to the Student based on the dialogs with Tutor.
assistant response:
Dialog 1:
Tutor: Hello, how are you finding your studies on the History of Rome?
Student: Hi, it’s quite challenging for me. I struggle to remember all the dates and names.
Dialog 2:
Tutor: Have you made any progress with the History of Rome since our last session?
Student: Not really, I still find it overwhelming. I don’t know where to start.
Comparison:
In the first dialog, the Student expresses difficulty in remembering dates and names, while in the second dialog, the Student mentions feeling overwhelmed and unsure of where to start. The first dialog focuses more on specific challenges with memorization, whereas the second dialog highlights a broader sense of being lost and unsure.
Feedback to the Student:
It’s clear from our conversations that you are facing challenges with the History of Rome. It’s important to break down the information into smaller, more manageable chunks. Consider creating study guides or flashcards to help with memorization. Additionally, don’t hesitate to ask for clarification or extra help when needed. Remember, learning is a process, and it’s okay to take it one step at a time.
1 Like
@_j , Thank you for fast reply!
If I’m understanding correctly, I need to send messages to the thread one by one? So each next message will be in context of the previous conversation.
Is that correct?
And if that is correct, then what should I do with Runs? Shall I create new run for every message I’m adding to the Thread?
So, my program should to the following steps:
- Create thread .
- For each message:
2.1 Add message to the Thread
2.2 Wait for Step status Complete
2.3 Add result of Step.Content to output collection
- Return output collection
Is it looking right?
Yes, you could also actually perform a conversation, where the AI responds like the user was asking a question each time.
The way assistants works is you place a user message, and then “run” to get an assistant response in the thread. Then you put another user message and get another response, where the AI can understand the past conversation you’ve been having. Like ChatGPT.
For a question like “Compare first and second dialogs”, it is going to be a lot better to give the two dialogs in one message, along with the instruction of what to perform on the two datas. A separate thread, or a single task to be sent to chat completions (the output I show was chat completions producing a single output for a single input).
A chat that tries to tell the AI to look at the past two turns and analyze and compare AI outputs within a conversation would be hard to instruct and have followed.
The actual objective of your task is unclear - what you will be providing, and what you actually want the AI to produce.
1 Like
The idea to put all my prompt in one combined prompt is actually a good one. My only concern that such large prompt will be confusing.
I’m using OpenAI for training data generation - building a set of dialogs between Tutor and Student with different variations of Tutor and Student properties. In reality, just my prompt to generate dialog is already quite large. So, building combined prompt will be a bigger problem. So, I’m trying to follow “The Best Practices” and split big prompt to smaller chunks, each one has clear meaning and is easier to consume. But I will try both approaches and see which one works better. Thank you for advise!