From d62fbb2bed99e58bd9a4e73a8cd94029397c724e Mon Sep 17 00:00:00 2001 From: kaarthik108 Date: Fri, 18 Oct 2024 19:38:34 +1300 Subject: [PATCH] add error messages --- .github/workflows/lint.yml | 42 -------------------------------------- README.md | 21 +++++++++---------- agent.py | 10 +++++---- utils/snowchat_ui.py | 1 - 4 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 6c7256e..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Lint - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - lint: - name: Lint and Format Code - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - - name: Cache pip dependencies - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install black ruff mypy codespell - - - name: Run Formatting and Linting - run: | - make format - make lint diff --git a/README.md b/README.md index afe0593..7590ad5 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ ## Supported LLM's -- GPT-3.5-turbo-0125 -- CodeLlama-70B -- Mistral Medium +- GPT-4o +- Gemini Flash 1.5 8B +- Claude 3 Haiku +- Llama 3.2 3B +- Llama 3.1 405B # @@ -27,11 +29,12 @@ https://github.com/kaarthik108/snowChat/assets/53030784/24105e23-69d3-4676-b6d6- ## 🌟 Features -- **Conversational AI**: Harnesses ChatGPT to translate natural language into precise SQL queries. +- **Conversational AI**: Use ChatGPT and other models to translate natural language into precise SQL queries. - **Conversational Memory**: Retains context for interactive, dynamic responses. - **Snowflake Integration**: Offers seamless, real-time data insights straight from your Snowflake database. - **Self-healing SQL**: Proactively suggests solutions for SQL errors, streamlining data access. - **Interactive User Interface**: Transforms data querying into an engaging conversation, complete with a chat reset option. +- **Agent-based Architecture**: Utilizes an agent to manage interactions and tool usage. ## 🛠️ Installation @@ -42,7 +45,9 @@ https://github.com/kaarthik108/snowChat/assets/53030784/24105e23-69d3-4676-b6d6- cd snowchat pip install -r requirements.txt -3. Set up your `OPENAI_API_KEY`, `ACCOUNT`, `USER_NAME`, `PASSWORD`, `ROLE`, `DATABASE`, `SCHEMA`, `WAREHOUSE`, `SUPABASE_URL` , `SUPABASE_SERVICE_KEY` and `REPLICATE_API_TOKEN` in project directory `secrets.toml`. +3. Set up your `OPENAI_API_KEY`, `ACCOUNT`, `USER_NAME`, `PASSWORD`, `ROLE`, `DATABASE`, `SCHEMA`, `WAREHOUSE`, `SUPABASE_URL` , `SUPABASE_SERVICE_KEY`, `SUPABASE_STORAGE_URL`,`CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_NAMESPACE_ID`, + `CLOUDFLARE_API_TOKEN` in project directory `secrets.toml`. + Cloudflare is used here for caching Snowflake responses in KV. 4. Make you're schemas and store them in docs folder that matches you're database. @@ -53,12 +58,6 @@ https://github.com/kaarthik108/snowChat/assets/53030784/24105e23-69d3-4676-b6d6- 7. Run the Streamlit app to start chatting: streamlit run main.py -## 🚀 Additional Enhancements - -1. **Platform Integration**: Connect snowChat with popular communication platforms like Slack or Discord for seamless interaction. -2. **Voice Integration**: Implement voice recognition and text-to-speech functionality to make the chatbot more interactive and user-friendly. -3. **Advanced Analytics**: Integrate with popular data visualization libraries like Plotly or Matplotlib to generate interactive visualizations based on the user's queries (AutoGPT). - ## Star History [![Star History Chart](https://api.star-history.com/svg?repos=kaarthik108/snowChat&type=Date)] diff --git a/agent.py b/agent.py index 2dc8ded..95a8c10 100644 --- a/agent.py +++ b/agent.py @@ -35,7 +35,7 @@ class ModelConfig: model_configurations = { "gpt-4o": ModelConfig( - model_name="gpt-4o", api_key=os.getenv("OPENAI_API_KEY") + model_name="gpt-4o", api_key=st.secrets["OPENAI_API_KEY"] ), "Gemini Flash 1.5 8B": ModelConfig( model_name="google/gemini-flash-1.5-8b", @@ -43,16 +43,16 @@ class ModelConfig: base_url="https://openrouter.ai/api/v1", ), "claude3-haiku": ModelConfig( - model_name="claude-3-haiku-20240307", api_key=os.getenv("ANTHROPIC_API_KEY") + model_name="claude-3-haiku-20240307", api_key=st.secrets["ANTHROPIC_API_KEY"] ), "llama-3.2-3b": ModelConfig( model_name="accounts/fireworks/models/llama-v3p2-3b-instruct", - api_key=os.getenv("FIREWORKS_API_KEY"), + api_key=st.secrets["FIREWORKS_API_KEY"], base_url="https://api.fireworks.ai/inference/v1", ), "llama-3.1-405b": ModelConfig( model_name="accounts/fireworks/models/llama-v3p1-405b-instruct", - api_key=os.getenv("FIREWORKS_API_KEY"), + api_key=st.secrets["FIREWORKS_API_KEY"], base_url="https://api.fireworks.ai/inference/v1", ), } @@ -70,6 +70,8 @@ def create_agent(callback_handler: BaseCallbackHandler, model_name: str) -> Stat if not config: raise ValueError(f"Unsupported model name: {model_name}") + if not config.api_key: + raise ValueError(f"API key for model '{model_name}' is not set. Please check your environment variables or secrets configuration.") llm = ( ChatOpenAI( diff --git a/utils/snowchat_ui.py b/utils/snowchat_ui.py index 2fe60d0..05db4b1 100644 --- a/utils/snowchat_ui.py +++ b/utils/snowchat_ui.py @@ -1,6 +1,5 @@ import html import re -import textwrap import streamlit as st from langchain.callbacks.base import BaseCallbackHandler