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
Given an `assistant_id` you can `retrieve` the current field values:
477
477
478
-
```
478
+
```ruby
479
479
client.assistants.retrieve(id: assistant_id)
480
480
```
481
481
482
482
You can get a `list` of all assistants currently available under the organization:
483
483
484
-
```
484
+
```ruby
485
485
client.assistants.list
486
486
```
487
487
488
488
You can modify an existing assistant using the assistant's id (see [API documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)):
Once you have created an assistant as described above, you need to prepare a `Thread` of `Messages` for the assistant to work on (see [introduction on Assistants](https://platform.openai.com/docs/assistants/how-it-works)). For example, as an initial setup you could do:
508
508
509
-
```
509
+
```ruby
510
510
# Create thread
511
511
response = client.threads.create # Note: Once you create a thread, there is no way to list it
512
512
# or recover it currently (as of 2023-12-10). So hold onto the `id`
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
543
544
-
```
544
+
```ruby
545
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:
If the `status` response indicates that the `run` is `completed`, the associated `thread` will have one or more new `messages` attached:
583
583
584
-
```
584
+
```ruby
585
585
# Either retrieve all messages in bulk again, or...
586
586
messages = client.messages.list(thread_id: thread_id) # Note: as of 2023-12-11 adding limit or order options isn't working, yet
587
587
@@ -615,15 +615,15 @@ new_messages.each { |msg|
615
615
616
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):
617
617
618
-
```
618
+
```ruby
619
619
client.runs.list(thread_id: thread_id)
620
620
```
621
621
622
622
#### Runs involving function tools
623
623
624
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:
0 commit comments