servers.main
servers.main
This module provides functionality for creating a start a restAPI service which allows a user to call the search methods of different VectorStore objects, from an api-endpoint.
These functions interact with the ClassifAI PackageIndexer modules VectorStore objects, such that their embed and search methods are exposed on restAPI endpoints, in a FastAPI restAPI service started with these functions.
Functions
get_router
Create and return a FastAPI.APIRouter with search endpoints.
get_server
Create and return a FastAPI server with search endpoints.
make_endpoints
Create and register the different endpoints to your app.
run_server
Create and run a FastAPI server with search endpoints.
get_router
servers.main.get_router(vector_stores, endpoint_names)
Create and return a FastAPI.APIRouter with search endpoints.
Parameters
vector_stores
list[VectorStore]
A list of VectorStore objects, each responsible for handling embedding and search operations for a specific endpoint.
required
endpoint_names
list[str]
A list of endpoint names corresponding to the vector stores.
required
Returns
APIRouter
Router with intialized search endpoints
Raises
DataValidationError
Raised if the input parameters are invalid.
ConfigurationError
Raised if one or more of the vector_stores are invalid.
get_server
servers.main.get_server(vector_stores, endpoint_names)
Create and return a FastAPI server with search endpoints.
Parameters
vector_stores
list[VectorStore]
A list of VectorStore objects, each responsible for handling embedding and search operations for a specific endpoint.
required
endpoint_names
list[str]
A list of endpoint names corresponding to the VectorStores to be exposed.
required
Returns
FastAPI
Server with intialized search endpoints
make_endpoints
servers.main.make_endpoints(router, vector_stores_dict)
Create and register the different endpoints to your app.
Parameters
router
APIRouter | FastAPI
The FastAPI application instance.
required
vector_stores_dict
dict[str, VectorStore]
The name of the endpoint to be created.
required
run_server
servers.main.run_server(vector_stores, endpoint_names, port= 8000 )
Create and run a FastAPI server with search endpoints.
Parameters
vector_stores
list[VectorStore]
A list of VectorStore objects, each responsible for handling embedding and search operations for a specific endpoint.
required
endpoint_names
list[str]
A list of endpoint names corresponding to the VectorStores to be exposed.
required
port
int
[optional] The port on which the API server will run. Defaults to 8000.
8000
Raises
DataValidationError
Raised if the input parameters are invalid, e.g. port value is out of bounds.