View Source ExOpenAI.VectorStores (ex_openai.ex v1.8.0)

Modules for interacting with the vector_stores group of OpenAI APIs

API Reference: https://platform.openai.com/docs/api-reference/vector_stores

Summary

Functions

Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.

Create a vector store.

Create a vector store file by attaching a File to a vector store.

Delete a vector store file. 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.

Returns a list of vector store files in a batch.

Returns a list of vector store files.

Returns a list of vector stores.

Retrieve the parsed contents of a vector store file.

Search a vector store for relevant chunks based on a query and file attributes filter.

Functions

Link to this function

cancel_vector_store_file_batch(vector_store_id, batch_id, opts \\ [])

View Source
@spec cancel_vector_store_file_batch(String.t(), String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.VectorStoreFileBatchObject.t()} | {:error, any()}

Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel

Method: POST

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

  • batch_id

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

create_vector_store(opts \\ [])

View Source
@spec create_vector_store(
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.VectorStoreObject.t()} | {:error, any()}

Create a vector store.

Endpoint: https://api.openai.com/v1/vector_stores

Method: POST

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

create_vector_store_file(vector_store_id, file_id, opts \\ [])

View Source
@spec create_vector_store_file(String.t(), String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t(),
  chunking_strategy: ExOpenAI.Components.ChunkingStrategyRequestParam.t(),
  attributes: ExOpenAI.Components.VectorStoreFileAttributes.t(),
  stream_to: (... -> any()) | pid()
) :: {:ok, ExOpenAI.Components.VectorStoreFileObject.t()} | {:error, any()}

Create a vector store file by attaching a File to a vector store.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/files

Method: POST

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Example: vs_abc123

  • file_id: A File ID that the vector store should use. Useful for tools like file_search that can access files.

Optional Arguments:

  • stream_to: "PID or function of where to stream content to"

  • attributes: ""

  • chunking_strategy: ""

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

create_vector_store_file_batch(vector_store_id, file_ids, opts \\ [])

View Source
@spec create_vector_store_file_batch(
  String.t(),
  [String.t()],
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t(),
  chunking_strategy: ExOpenAI.Components.ChunkingStrategyRequestParam.t(),
  attributes: ExOpenAI.Components.VectorStoreFileAttributes.t(),
  stream_to: (... -> any()) | pid()
) :: {:ok, ExOpenAI.Components.VectorStoreFileBatchObject.t()} | {:error, any()}

Create a vector store file batch.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches

Method: POST

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Example: vs_abc123

  • file_ids: A list of File IDs that the vector store should use. Useful for tools like file_search that can access files.

Optional Arguments:

  • stream_to: "PID or function of where to stream content to"

  • attributes: ""

  • chunking_strategy: ""

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

delete_vector_store(vector_store_id, opts \\ [])

View Source
@spec delete_vector_store(String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.DeleteVectorStoreResponse.t()} | {:error, any()}

Delete a vector store.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}

Method: DELETE

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

delete_vector_store_file(vector_store_id, file_id, opts \\ [])

View Source
@spec delete_vector_store_file(String.t(), String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) ::
  {:ok, ExOpenAI.Components.DeleteVectorStoreFileResponse.t()} | {:error, any()}

Delete a vector store file. 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.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id}

Method: DELETE

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

  • file_id

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

get_vector_store(vector_store_id, opts \\ [])

View Source
@spec get_vector_store(String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.VectorStoreObject.t()} | {:error, any()}

Retrieves a vector store.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}

Method: GET

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

get_vector_store_file(vector_store_id, file_id, opts \\ [])

View Source
@spec get_vector_store_file(String.t(), String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.VectorStoreFileObject.t()} | {:error, any()}

Retrieves a vector store file.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id}

Method: GET

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Example: vs_abc123

  • file_id

Example: file-abc123

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

get_vector_store_file_batch(vector_store_id, batch_id, opts \\ [])

View Source
@spec get_vector_store_file_batch(String.t(), String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.VectorStoreFileBatchObject.t()} | {:error, any()}

Retrieves a vector store file batch.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}

Method: GET

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Example: vs_abc123

  • batch_id

Example: vsfb_abc123

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

list_files_in_vector_store_batch(vector_store_id, batch_id, opts \\ [])

View Source
@spec list_files_in_vector_store_batch(String.t(), String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t(),
  filter: String.t(),
  before: String.t(),
  after: String.t(),
  order: String.t(),
  limit: integer(),
  stream_to: (... -> any()) | pid()
) ::
  {:ok, ExOpenAI.Components.ListVectorStoreFilesResponse.t()} | {:error, any()}

Returns a list of vector store files in a batch.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files

Method: GET

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

  • batch_id

Optional Arguments:

  • stream_to: "PID or function of where to stream content to"

  • limit

  • order

  • after

  • before

  • filter

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

list_vector_store_files(vector_store_id, opts \\ [])

View Source
@spec list_vector_store_files(String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t(),
  filter: String.t(),
  before: String.t(),
  after: String.t(),
  order: String.t(),
  limit: integer(),
  stream_to: (... -> any()) | pid()
) ::
  {:ok, ExOpenAI.Components.ListVectorStoreFilesResponse.t()} | {:error, any()}

Returns a list of vector store files.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/files

Method: GET

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Optional Arguments:

  • stream_to: "PID or function of where to stream content to"

  • limit

  • order

  • after

  • before

  • filter

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

list_vector_stores(opts \\ [])

View Source
@spec list_vector_stores(
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t(),
  before: String.t(),
  after: String.t(),
  order: String.t(),
  limit: integer(),
  stream_to: (... -> any()) | pid()
) :: {:ok, ExOpenAI.Components.ListVectorStoresResponse.t()} | {:error, any()}

Returns a list of vector stores.

Endpoint: https://api.openai.com/v1/vector_stores

Method: GET

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

Optional Arguments:

  • stream_to: "PID or function of where to stream content to"

  • limit

  • order

  • after

  • before

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

modify_vector_store(vector_store_id, opts \\ [])

View Source
@spec modify_vector_store(String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.VectorStoreObject.t()} | {:error, any()}

Modifies a vector store.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}

Method: POST

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

retrieve_vector_store_file_content(vector_store_id, file_id, opts \\ [])

View Source
@spec retrieve_vector_store_file_content(String.t(), String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) ::
  {:ok, ExOpenAI.Components.VectorStoreFileContentResponse.t()}
  | {:error, any()}

Retrieve the parsed contents of a vector store file.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id}/content

Method: GET

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Example: vs_abc123

  • file_id

Example: file-abc123

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

search_vector_store(vector_store_id, query, opts \\ [])

View Source
@spec search_vector_store(String.t(), [String.t()] | String.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t(),
  rewrite_query: boolean(),
  ranking_options: %{
    ranker: :"default-2024-11-15" | :auto,
    score_threshold: float()
  },
  max_num_results: integer(),
  filters:
    ExOpenAI.Components.CompoundFilter.t()
    | ExOpenAI.Components.ComparisonFilter.t(),
  stream_to: (... -> any()) | pid()
) ::
  {:ok, ExOpenAI.Components.VectorStoreSearchResultsPage.t()} | {:error, any()}

Search a vector store for relevant chunks based on a query and file attributes filter.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/search

Method: POST

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Example: vs_abc123

  • query: A query string for a search

Optional Arguments:

  • stream_to: "PID or function of where to stream content to"

  • filters: "A filter to apply based on file attributes."

  • max_num_results: "The maximum number of results to return. This number should be between 1 and 50 inclusive."

  • ranking_options: "Ranking options for search."

  • rewrite_query: "Whether to rewrite the natural language query for vector search."

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"

Link to this function

update_vector_store_file_attributes(vector_store_id, file_id, attributes, opts \\ [])

View Source
@spec update_vector_store_file_attributes(
  String.t(),
  String.t(),
  ExOpenAI.Components.VectorStoreFileAttributes.t(),
  base_url: String.t(),
  openai_organization_key: String.t(),
  openai_api_key: String.t()
) :: {:ok, ExOpenAI.Components.VectorStoreFileObject.t()} | {:error, any()}

Update attributes on a vector store file.

Endpoint: https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id}

Method: POST

Docs: https://platform.openai.com/docs/api-reference/vector_stores


Required Arguments:

  • vector_store_id

Example: vs_abc123

  • file_id

Example: file-abc123

  • attributes:

Optional Arguments:

  • openai_api_key: "OpenAI API key to pass directly. If this is specified, it will override the api_key config value."

  • openai_organization_key: "OpenAI API key to pass directly. If this is specified, it will override the organization_key config value."

  • base_url: "Which API endpoint to use as base, defaults to https://api.openai.com/v1"