Spaces:
Running
Running
arithescientist
commited on
Commit
•
bcb1e04
1
Parent(s):
a1e4fe6
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,12 @@ import streamlit as st
|
|
3 |
import pandas as pd
|
4 |
import sqlite3
|
5 |
import logging
|
6 |
-
import textwrap # Added import for textwrap
|
7 |
from langchain.llms import OpenAI
|
8 |
from langchain.chat_models import ChatOpenAI
|
9 |
-
from langchain.chains import SQLDatabaseChain
|
10 |
from langchain.prompts import PromptTemplate
|
11 |
from langchain.chains import LLMChain
|
12 |
-
from langchain.sql_database
|
13 |
|
14 |
# Initialize logging
|
15 |
logging.basicConfig(level=logging.INFO)
|
@@ -72,7 +71,7 @@ def process_input():
|
|
72 |
st.session_state.history.append({"role": "assistant", "content": response})
|
73 |
|
74 |
# Generate insights based on the response
|
75 |
-
insights_template =
|
76 |
You are an expert data analyst. Based on the user's question and the response provided below, generate a concise analysis that includes key data insights and actionable recommendations. Limit the response to a maximum of 150 words.
|
77 |
|
78 |
User's Question: {question}
|
@@ -81,7 +80,7 @@ def process_input():
|
|
81 |
{response}
|
82 |
|
83 |
Concise Analysis:
|
84 |
-
"""
|
85 |
insights_prompt = PromptTemplate(template=insights_template, input_variables=['question', 'response'])
|
86 |
insights_chain = LLMChain(llm=llm, prompt=insights_prompt)
|
87 |
|
|
|
3 |
import pandas as pd
|
4 |
import sqlite3
|
5 |
import logging
|
|
|
6 |
from langchain.llms import OpenAI
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
+
from langchain.chains.sql_database.base import SQLDatabaseChain # Updated import
|
9 |
from langchain.prompts import PromptTemplate
|
10 |
from langchain.chains import LLMChain
|
11 |
+
from langchain.sql_database import SQLDatabase
|
12 |
|
13 |
# Initialize logging
|
14 |
logging.basicConfig(level=logging.INFO)
|
|
|
71 |
st.session_state.history.append({"role": "assistant", "content": response})
|
72 |
|
73 |
# Generate insights based on the response
|
74 |
+
insights_template = """
|
75 |
You are an expert data analyst. Based on the user's question and the response provided below, generate a concise analysis that includes key data insights and actionable recommendations. Limit the response to a maximum of 150 words.
|
76 |
|
77 |
User's Question: {question}
|
|
|
80 |
{response}
|
81 |
|
82 |
Concise Analysis:
|
83 |
+
"""
|
84 |
insights_prompt = PromptTemplate(template=insights_template, input_variables=['question', 'response'])
|
85 |
insights_chain = LLMChain(llm=llm, prompt=insights_prompt)
|
86 |
|