Skip to content

Commit 3e9df5b

Browse files
committed
docs(README.md): add documentation for vector stores, vector store files, and vector store file batches to provide information on how to manage and interact with vector stores in the API
feat(README.md): add support for file search tool in the assistant by including it as a tool resource in the assistant creation request
1 parent 97c8508 commit 3e9df5b

File tree

1 file changed

+154
-3
lines changed

1 file changed

+154
-3
lines changed

README.md

Lines changed: 154 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ These files are in JSONL format, with each line representing the output or error
585585
If a request fails with a non-HTTP error, the error object will contain more information about the cause of the failure.
586586

587587
### Files
588-
588+
#### For fine-tunning purposes
589589
Put your data in a `.jsonl` file like this:
590590

591591
```json
@@ -603,6 +603,24 @@ client.files.content(id: "file-123")
603603
client.files.delete(id: "file-123")
604604
```
605605

606+
#### For assistant purposes
607+
608+
You can send a file path:
609+
610+
```ruby
611+
client.files.upload(parameters: { file: "path/to/file.pdf", purpose: "assistants" })
612+
```
613+
614+
or a File object
615+
616+
```ruby
617+
my_file = File.open("path/to/file.pdf", "rb")
618+
client.files.upload(parameters: { file: my_file, purpose: "assistants" })
619+
```
620+
621+
622+
See supported file types on [API documentation](https://platform.openai.com/docs/assistants/tools/file-search/supported-files).
623+
606624
### Finetunes
607625

608626
Upload your fine-tuning data in a `.jsonl` file as above and get its ID:
@@ -655,6 +673,135 @@ You can also capture the events for a job:
655673
client.finetunes.list_events(id: fine_tune_id)
656674
```
657675
676+
### Vector Stores
677+
Vector Store objects give the File Search tool the ability to search your files.
678+
679+
You can create a new vector store:
680+
681+
```ruby
682+
response = client.vector_stores.create(
683+
parameters: {
684+
name: "my vector store",
685+
file_ids: ["file-abc123", "file-def456"]
686+
}
687+
)
688+
689+
vector_store_id = response["id"]
690+
```
691+
692+
Given a `vector_store_id` you can `retrieve` the current field values:
693+
694+
```ruby
695+
client.vector_stores.retrieve(id: vector_store_id)
696+
```
697+
698+
You can get a `list` of all vector stores currently available under the organization:
699+
700+
```ruby
701+
client.vector_stores.list
702+
```
703+
704+
You can modify an existing vector store, except for the `file_ids`:
705+
706+
```ruby
707+
response = client.vector_stores.modify(
708+
id: vector_store_id,
709+
parameters: {
710+
name: "Modified Test Vector Store",
711+
}
712+
)
713+
```
714+
715+
You can delete vector stores:
716+
717+
```ruby
718+
client.vector_stores.delete(id: vector_store_id)
719+
```
720+
721+
### Vector Store Files
722+
Vector store files represent files inside a vector store.
723+
724+
You can create a new vector store file by attaching a File to a vector store.
725+
726+
```ruby
727+
response = client.vector_store_files.create(
728+
vector_store_id: "vector-store-abc123",
729+
parameters: {
730+
file_id: "file-abc123"
731+
}
732+
)
733+
734+
vector_store_file_id = response["id"]
735+
```
736+
737+
Given a `vector_store_file_id` you can `retrieve` the current field values:
738+
739+
```ruby
740+
client.vector_store_files.retrieve(
741+
vector_store_id: "vector-store-abc123",
742+
id: vector_store_file_id
743+
)
744+
```
745+
746+
You can get a `list` of all vector store files currently available under the vector store:
747+
748+
```ruby
749+
client.vector_store_files.list(vector_store_id: "vector-store-abc123")
750+
```
751+
752+
You can delete a vector store file:
753+
754+
```ruby
755+
client.vector_store_files.delete(
756+
vector_store_id: "vector-store-abc123",
757+
id: vector_store_file_id
758+
)
759+
```
760+
Note: This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the delete file endpoint.
761+
762+
### Vector Store File Batches
763+
Vector store file batches represent operations to add multiple files to a vector store.
764+
765+
You can create a new vector store file batch by attaching multiple Files to a vector store.
766+
767+
```ruby
768+
response = client.vector_store_file_batches.create(
769+
vector_store_id: "vector-store-abc123",
770+
parameters: {
771+
file_ids: ["file-abc123", "file-def456"]
772+
}
773+
)
774+
775+
file_batch_id = response["id"]
776+
```
777+
778+
Given a `file_batch_id` you can `retrieve` the current field values:
779+
780+
```ruby
781+
client.vector_store_file_batches.retrieve(
782+
vector_store_id: "vector-store-abc123",
783+
id: file_batch_id
784+
)
785+
```
786+
787+
You can get a `list` of all vector store files in a batch currently available under the vector store:
788+
789+
```ruby
790+
client.vector_store_file_batches.list(
791+
vector_store_id: "vector-store-abc123",
792+
id: file_batch_id
793+
)
794+
```
795+
796+
You can cancel a vector store file batch (This attempts to cancel the processing of files in this batch as soon as possible):
797+
798+
```ruby
799+
client.vector_store_file_batches.cancel(
800+
vector_store_id: "vector-store-abc123",
801+
id: file_batch_id
802+
)
803+
```
804+
658805
### Assistants
659806

660807
Assistants are stateful actors that can have many conversations and use tools to perform tasks (see [Assistant Overview](https://platform.openai.com/docs/assistants/overview)).
@@ -670,10 +817,14 @@ response = client.assistants.create(
670817
instructions: "You are a Ruby dev bot. When asked a question, write and run Ruby code to answer the question",
671818
tools: [
672819
{ type: "code_interpreter" },
820+
{ type: "file_search" }
673821
],
674822
tool_resources: {
675-
"code_interpreter": {
676-
"file_ids": [] # See Files section above for how to upload files
823+
code_interpreter: {
824+
file_ids: [] # See Files section above for how to upload files
825+
},
826+
file_search: {
827+
vector_store_ids: [] # See Vector Stores section above for how to add vector stores
677828
}
678829
},
679830
"metadata": { my_internal_version_id: "1.0.0" }

0 commit comments

Comments
 (0)