Skip to content

Commit

Permalink
Issue #4: update package readme
Browse files Browse the repository at this point in the history
  • Loading branch information
k-allagbe committed Mar 26, 2024
1 parent 60c4b10 commit 44672ba
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
56 changes: 48 additions & 8 deletions ailab-llama-search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion ailab-llama-search/ailab_llama_search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 44672ba

Please sign in to comment.