Termify is an AI-powered chatbot designed to help users easily understand the terms and conditions, privacy policies, and related documents of various companies. By providing concise and accurate explanations, Termify simplifies complex legal jargon, making it accessible for everyone.
- Set Up the Python Environment
- Manage Packages
- Environment Variables
- Running the Application
- Evaluating your model
- Alternative to
.env
Files
Create a new Python virtual environment:
python3.10 -m venv <env_name>
Replace <env_name>
with the name of your environment (e.g., myenv
).
Activate the virtual environment:
source <env_name>/bin/activate
Replace <env_name>
with your environment name.
After activating your environment, install all required packages:
pip install -r requirements.txt
Before pushing changes, synchronize your environment packages to the requirements.txt
file for other developers:
pip freeze > requirements.txt
Create a .env
file in the root directory and add the required environment variables:
SNOWFLAKE_ACCOUNT=accountname.region
SNOWFLAKE_USER=username
SNOWFLAKE_PASSWORD=********
SNOWFLAKE_DATABASE=databasename
SNOWFLAKE_SCHEMA=schemaname
SNOWFLAKE_ROLE=role
CORTEX_SEARCH_TABLE_NAME=table
SNOWFLAKE_WAREHOUSE=warehousename
SNOWFLAKE_CORTEX_SEARCH_SERVICE=yourCortexserviceName
USER_DATABASE=USER_DATA
# for developers
USER_DATASET_FOLDER=folder_Path_which_contains_all_data
USER_DATASET_FOLDER_OUTPUT=snowflake_data.csv
python run.py app:streamlit
Run the following command to execute the Snowflake script:
python run.py app:main
-
Install Docker Ensure Docker is installed on your machine.
-
Build and Start the App in Docker
- Build and start the app:
docker compose up --build
- To run in detached mode:
docker compose up -d --build
- Build and start the app:
-
Start the App Without Rebuilding
docker compose up
- To run in detached mode:
docker compose up -d
- To run in detached mode:
-
Stop the Docker Containers
docker compose down
To evaluate your model, run the following command:
python run.py app:trulens
This command will run trulens which helps in evaluating the model. just write your question on which you want your model to be evaluated and it will start an streamlit app where you can see the results and evaluation graph of your model respective to the answer, context and other parameters.
Instead of using a .env
file, you can use secrets.toml
for managing environment variables. Create a .streamlit
folder in the root directory and add a secrets.toml
file:
Directory Structure:
.project-root/
|-- .streamlit/
|-- secrets.toml
Contents of secrets.toml
:
SNOWFLAKE_ACCOUNT = "accountname.region"
SNOWFLAKE_USER = "username"
SNOWFLAKE_PASSWORD = "********"
SNOWFLAKE_DATABASE = "databasename"
SNOWFLAKE_SCHEMA = "schemaname"
SNOWFLAKE_ROLE = "role"
SNOWFLAKE_WAREHOUSE = "warehousename"
SNOWFLAKE_CORTEX_SEARCH_SERVICE = "yourCortexserviceName"
USER_DATABASE="USER_DATA"
# for developers
USER_DATASET_FOLDER="folder_Path_which_contains_all_data"
USER_DATASET_FOLDER_OUTPUT="snowflake_data.csv"
This approach is especially useful for securely managing secrets in Streamlit applications.