You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# To delete the thread (and all associated messages):
534
+
client.threads.delete(id: thread_id)
535
+
536
+
client.messages.retrieve(thread_id: thread_id, id: message_id) # -> Fails after thread is deleted
537
+
```
538
+
539
+
540
+
### Runs
541
+
542
+
To submit a thread to be evaluated with the model of an assistant, create a `Run` as follows (Note: This is one place where OpenAI will take your money):
543
+
544
+
```
545
+
# Create run (will use instruction/model/tools from Assistant's definition)
The `status` response can include the following strings `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, or `expired` which you can handle as follows:
# Find the actual response text in the content array of the messages
602
+
new_messages.each { |msg|
603
+
msg['content'].each { |content_item|
604
+
case content_item['type']
605
+
when 'text'
606
+
puts content_item.dig('text', 'value')
607
+
# Also handle annotations
608
+
when 'image_file'
609
+
# Use File endpoint to retrieve file contents via id
610
+
id = content_item.dig('image_file', 'file_id')
611
+
end
612
+
}
613
+
}
614
+
```
615
+
529
616
At any time you can list all runs which have been performed on a particular thread or are currently running (in descending/newest first order):
530
617
531
618
```
532
619
client.runs.list(thread_id: thread_id)
533
620
```
534
621
535
-
To clean up after a thread is no longer needed:
622
+
#### Runs involving function tools
623
+
624
+
In case you are allowing the assistant to access `function` tools (they are defined in the same way as functions during chat completion), you might get a status code of `requires_action` when the assistant wants you to evaluate one or more function tools:
536
625
537
626
```
538
-
# To delete the thread (and all associated messages):
0 commit comments