diff --git a/ailab-llama-search/README.md b/ailab-llama-search/README.md index 24045f5..c0db6d7 100644 --- a/ailab-llama-search/README.md +++ b/ailab-llama-search/README.md @@ -2,24 +2,64 @@ ## Overview -TODO +The `ailab-llama-search` package facilitates querying our custom index built using LlamaIndex and PostgresSQL. ## Installation -TODO +```bash +pip install git+https://github.com/ai-cfia/llamaindex-db.git@main#subdirectory=ailab-llama-search +``` -## Configuration +## Usage -TODO +```python +from ailab_llama_search import create_index_object, search -## Usage +# adapt these parameters to your needs +embed_model_params = { + "azure_endpoint": "azure_openai_endpoint", + "api_key": "azure_openai_api_key", + "api_version": "2023-07-01-preview", + "model": "embed_model_name", + "deployment_name": "embed_model_deployment_name", +} +vector_store_params = { + "host": "postgres_host", + "user": "postgres_user", + "password": "postgres_password", + "database": "postgres_db_name", + "port": "5432", + "embed_dim": 1536, +} +trans_paths = { + "id": "node/metadata/id", + "chunk_id": "node/metadata/chunk_id", + "url": "node/metadata/url", + "title": "node/metadata/title", + "subtitle": "node/metadata/subtitle", + "tokens_count": "node/metadata/tokens_count", + "last_updated": "node/metadata/last_updated", + "score": "node/metadata/score", + "llama_id": "node/id_", + "llama_score": "score", + "content": "node/text", +} + +index = create_index_object(embed_model_params, vector_store_params) +search_results = search("your query", index, trans_paths=trans_paths) -TODO +for result in search_results: + print(result) +``` ## Exceptions -TODO +- `AilabLlamaSearchError`: Triggered if the search query string is empty or + `None`. ## Functions -TODO +- `search`: Executes search queries against a LlamaIndex `VectorStoreIndex`. +- `create_index_object`: Generates a `VectorStoreIndex` object needed to use the + `search` function. +- `transform`: Modifies search result data based on predefined mappings. diff --git a/ailab-llama-search/ailab_llama_search/__init__.py b/ailab-llama-search/ailab_llama_search/__init__.py index d7e0659..e68d070 100644 --- a/ailab-llama-search/ailab_llama_search/__init__.py +++ b/ailab-llama-search/ailab_llama_search/__init__.py @@ -25,7 +25,7 @@ def search( ): if not query: logging.error("Empty search query received") - raise AilabLlamaSearchError("Search query cannot be empty") + raise AilabLlamaSearchError("search query cannot be empty.") retriever = index.as_retriever(**search_params) nodes = retriever.retrieve(query)