Create a vector store file by attaching a [File](https://platform.openai.com/docs/api-reference/files) to a [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object). Args: file_id: A [File](https://platform.openai.com/docs/api-re
(
self,
vector_store_id: str,
*,
file_id: str,
attributes: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
chunking_strategy: FileChunkingStrategyParam | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
)
| 46 | return FilesWithStreamingResponse(self) |
| 47 | |
| 48 | def create( |
| 49 | self, |
| 50 | vector_store_id: str, |
| 51 | *, |
| 52 | file_id: str, |
| 53 | attributes: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit, |
| 54 | chunking_strategy: FileChunkingStrategyParam | Omit = omit, |
| 55 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 56 | # The extra values given here take precedence over values defined on the client or passed to this method. |
| 57 | extra_headers: Headers | None = None, |
| 58 | extra_query: Query | None = None, |
| 59 | extra_body: Body | None = None, |
| 60 | timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 61 | ) -> VectorStoreFile: |
| 62 | """ |
| 63 | Create a vector store file by attaching a |
| 64 | [File](https://platform.openai.com/docs/api-reference/files) to a |
| 65 | [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object). |
| 66 | |
| 67 | Args: |
| 68 | file_id: A [File](https://platform.openai.com/docs/api-reference/files) ID that the |
| 69 | vector store should use. Useful for tools like `file_search` that can access |
| 70 | files. For multi-file ingestion, we recommend |
| 71 | [`file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch) |
| 72 | to minimize per-vector-store write requests. |
| 73 | |
| 74 | attributes: Set of 16 key-value pairs that can be attached to an object. This can be useful |
| 75 | for storing additional information about the object in a structured format, and |
| 76 | querying for objects via API or the dashboard. Keys are strings with a maximum |
| 77 | length of 64 characters. Values are strings with a maximum length of 512 |
| 78 | characters, booleans, or numbers. |
| 79 | |
| 80 | chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto` |
| 81 | strategy. Only applicable if `file_ids` is non-empty. |
| 82 | |
| 83 | extra_headers: Send extra headers |
| 84 | |
| 85 | extra_query: Add additional query parameters to the request |
| 86 | |
| 87 | extra_body: Add additional JSON properties to the request |
| 88 | |
| 89 | timeout: Override the client-level default timeout for this request, in seconds |
| 90 | """ |
| 91 | if not vector_store_id: |
| 92 | raise ValueError(f"Expected a non-empty value for `vector_store_id` but received {vector_store_id!r}") |
| 93 | extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})} |
| 94 | return self._post( |
| 95 | path_template("/vector_stores/{vector_store_id}/files", vector_store_id=vector_store_id), |
| 96 | body=maybe_transform( |
| 97 | { |
| 98 | "file_id": file_id, |
| 99 | "attributes": attributes, |
| 100 | "chunking_strategy": chunking_strategy, |
| 101 | }, |
| 102 | file_create_params.FileCreateParams, |
| 103 | ), |
| 104 | options=make_request_options( |
| 105 | extra_headers=extra_headers, |
no test coverage detected