*I’ve botched the logic and the retrieval when it comes to displaying the response. I’ve added a few print statements in the logic, when following the thread I am in fact getting the response properly, and it is building off each response (as far as I can tell). *
However the chat window itself shows something like:
```
User: Hi
Assistant: undefined
(in VSCode console) … content=[MessageContentText(text=Text(annotations=[], value=‘Hi! How may I assist you today’), type=‘text’)] …
User: I’m having trouble with my car window
Assistant: undefined
(in VSCode console) … content=[MessageContentText(text=Text(annotations=[], value='It could be your window regulator, etc, etc), type=‘text’)] …
```
I’ve put in demo responses, however from what I can gather, is that on the HTML side it either isn’t waiting long enough to get a response, or it’s an issue with grabbing the right element from the response. I mainly do UX design or light automation so all this is pretty new to me.
^^^ ignore ^^^
I’ve gone ahead and made some fixes to an earlier version that checks the run to fix the timing issue. The logic for looking for the Assistant response is:
fig 1
for msg in messages.data:
if msg.role == 'assistant':
for content in msg.content:
if content.type == 'text':
assistant_response = content.text.value
print('\nassistant output: ' + str(assistant_response) + '\n')
return jsonify({'response': assistant_response})
So it only ever outputs the first response, even though when looking at the readout from listing the Thread:
fig 2
messages = client.beta.threads.messages.list(
thread_id=thread.id
)
print('\nresponse message from threads: \n:' + str(messages))
Shows an updated response in the MessageContentText field.
So I’m assuming the logic is broken in fig 1 and that’s why it keeps returning the initial assistant response. There’s some other issues but this is the big boy one that I’m working on just to get it functional.