-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove collection centroids. * Remove unused code, add docstring and comments. * Update router prompt. * Remove router development notebook. * Add README for router. * Update router prompt. * Update router test. * Add global utils.
- Loading branch information
Showing
7 changed files
with
99 additions
and
8,264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Router Module | ||
|
||
This directory contains scripts and utilities for routing user queries to the appropriate legal documents. | ||
|
||
## Overview | ||
|
||
- `query_router.py`: Main script for routing semantic queries to the appropriate collections using OpenAI's API. | ||
- `router_prompt.py`: Contains the prompt template used to determine relevant laws based on user queries. | ||
|
||
## Setup | ||
|
||
Refer to the main README for details on setting up the environment and dependencies using Poetry. | ||
|
||
### Environment Configuration | ||
|
||
Before running the scripts, ensure you have set the necessary environment variables in your `.env` file: | ||
```yaml | ||
OPENAI_API_KEY= | ||
``` | ||
|
||
## Scripts | ||
|
||
- `query_router.py` - This script routes a semantic query to the appropriate collections using OpenAI's API. | ||
- `router_prompt.py` - This script contains the prompt template used to determine relevant laws based on user queries. | ||
|
||
## Usage | ||
|
||
To route a query and get the relevant laws, use the **semantic_query_router** function from `query_router.py`. Make sure to format your query and prompt correctly and provide the required API key in the .env file. | ||
|
||
```python | ||
from openai import OpenAI | ||
from router.query_router import semantic_query_router | ||
from router.router_prompt import ROUTER_PROMPT | ||
|
||
client = OpenAI(api_key='YOUR_OPENAI_API_KEY') | ||
|
||
query = "What are the conditions for terminating an employment contract?" | ||
response = semantic_query_router(client, query, ROUTER_PROMP) | ||
print(response) | ||
``` |
Oops, something went wrong.