oa.vector_stores¶
Vector stores and search
Functions
|
Convenience function that both binds arguments and modifies signature. |
Factory function that creates a search function via vector store. |
|
|
Create an OpenAI vector store from a mapping of documents. |
|
Create a search function for an OpenAI vector store using the Responses API. |
- oa.vector_stores.bind_and_modify(func, *bound_args, _param_changes=(), **bound_kwargs)[source]¶
Convenience function that both binds arguments and modifies signature.
This is perfect for your vector store search use case.
- Parameters:
func – The function to wrap
bound_args – Positional arguments to bind
bound_kwargs – Dict of argument names to values to bind
_param_changes (
dict) – Parameter modifications
- Returns:
Wrapped function with bound arguments and modified signature
Example for your vector store case:
>>> def search(vector_store_id, *, query, filters=None, max_results=10): ... return f"Searching {vector_store_id} for '{query}'" >>> >>> # Bind vector_store_id and make query positional >>> bound_search = bind_and_modify( ... search, ... vector_store_id='my_store', ... _param_changes=dict(query={'kind': Parameter.POSITIONAL_OR_KEYWORD}), ... ) >>> >>> bound_search('my query') "Searching my_store for 'my query'"
- oa.vector_stores.docs_to_search_func_factory_via_vector_store(docs)[source]¶
Factory function that creates a search function via vector store. This can be used with check_search_func_factory.
- oa.vector_stores.docs_to_vector_store(docs, vs_name=None, *, client=None)[source]¶
Create an OpenAI vector store from a mapping of documents.
- Parameters:
- Returns:
(vector_store_id, file_id_to_doc_key_mapping)
- Return type:
If anything fails after the vector store is created, the store and the files uploaded so far are deleted (best effort) before the error is re-raised.