Skip to content

Commit 5a04542

Browse files
authored
Add ruby annotation to markdown pre sections
1 parent f369df1 commit 5a04542

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ Assistants can call models to interact with threads and use tools to perform tas
456456

457457
To create a new assistant (see [API documentation](https://platform.openai.com/docs/api-reference/assistants/createAssistant)):
458458

459-
```
459+
```ruby
460460
response = client.assistants.create(
461461
parameters: {
462462
model: "gpt-3.5-turbo-1106", # Retrieve via client.models.list. Assistants need 'gpt-3.5-turbo-1106' or later.
@@ -475,19 +475,19 @@ assistant_id = response["id"]
475475

476476
Given an `assistant_id` you can `retrieve` the current field values:
477477

478-
```
478+
```ruby
479479
client.assistants.retrieve(id: assistant_id)
480480
```
481481

482482
You can get a `list` of all assistants currently available under the organization:
483483

484-
```
484+
```ruby
485485
client.assistants.list
486486
```
487487

488488
You can modify an existing assistant using the assistant's id (see [API documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)):
489489

490-
```
490+
```ruby
491491
response = client.assistants.modify(
492492
id: assistant_id,
493493
parameters: {
@@ -506,7 +506,7 @@ client.assistants.delete(id: assistant_id)
506506

507507
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:
508508

509-
```
509+
```ruby
510510
# Create thread
511511
response = client.threads.create # Note: Once you create a thread, there is no way to list it
512512
# or recover it currently (as of 2023-12-10). So hold onto the `id`
@@ -529,7 +529,7 @@ messages = client.messages.list(thread_id: thread_id)
529529

530530
To clean up after a thread is no longer needed:
531531

532-
```
532+
```ruby
533533
# To delete the thread (and all associated messages):
534534
client.threads.delete(id: thread_id)
535535

@@ -541,7 +541,7 @@ client.messages.retrieve(thread_id: thread_id, id: message_id) # -> Fails after
541541

542542
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):
543543

544-
```
544+
```ruby
545545
# Create run (will use instruction/model/tools from Assistant's definition)
546546
response = client.runs.create(thread_id: thread_id,
547547
parameters: {
@@ -556,7 +556,7 @@ status = response['status']
556556

557557
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:
558558

559-
```
559+
```ruby
560560
while true do
561561

562562
response = client.runs.retrieve(id: run_id, thread_id: thread_id)
@@ -581,7 +581,7 @@ end
581581

582582
If the `status` response indicates that the `run` is `completed`, the associated `thread` will have one or more new `messages` attached:
583583

584-
```
584+
```ruby
585585
# Either retrieve all messages in bulk again, or...
586586
messages = client.messages.list(thread_id: thread_id) # Note: as of 2023-12-11 adding limit or order options isn't working, yet
587587

@@ -615,15 +615,15 @@ new_messages.each { |msg|
615615

616616
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):
617617

618-
```
618+
```ruby
619619
client.runs.list(thread_id: thread_id)
620620
```
621621

622622
#### Runs involving function tools
623623

624624
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:
625625

626-
```
626+
```ruby
627627
def get_current_weather(location:, unit: "celsius")
628628
# Your function code goes here
629629
if location =~ /San Francisco/i

0 commit comments

Comments
 (0)