Sakil commited on
Commit
537bc8d
·
verified ·
1 Parent(s): bda721d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
3
  import logging
4
- #from IPython.display import Markdown, display
5
  from llama_index.core.query_engine import PandasQueryEngine
6
  from llama_index.llms.anthropic import Anthropic
7
 
@@ -9,20 +9,20 @@ logging.basicConfig(level=logging.INFO)
9
 
10
  def main():
11
  st.title('CSV Data Query Tool')
12
-
13
  # Upload CSV file
14
  uploaded_file = st.file_uploader("Upload CSV file", type=['csv'])
15
  if uploaded_file is not None:
16
  df = pd.read_csv(uploaded_file)
17
-
18
  # Input API Key
19
  api_key = st.text_input("Enter your ANTHROPIC_API_KEY:")
20
-
21
  # Initialize Anthropic
22
  if api_key:
23
  llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229', api_key=api_key)
24
  query_engine = PandasQueryEngine(df=df, llm=llm, verbose=True)
25
-
26
  # Input user question
27
  question = st.text_input("Ask a question about the data:")
28
  if st.button("Submit"):
@@ -30,5 +30,10 @@ def main():
30
  response = query_engine.query(question)
31
  st.markdown(f"**Response:** {response}")
32
 
 
 
 
 
 
33
  if __name__ == "__main__":
34
  main()
 
1
  import streamlit as st
2
  import pandas as pd
3
  import logging
4
+ from IPython.display import Markdown, display
5
  from llama_index.core.query_engine import PandasQueryEngine
6
  from llama_index.llms.anthropic import Anthropic
7
 
 
9
 
10
  def main():
11
  st.title('CSV Data Query Tool')
12
+
13
  # Upload CSV file
14
  uploaded_file = st.file_uploader("Upload CSV file", type=['csv'])
15
  if uploaded_file is not None:
16
  df = pd.read_csv(uploaded_file)
17
+
18
  # Input API Key
19
  api_key = st.text_input("Enter your ANTHROPIC_API_KEY:")
20
+
21
  # Initialize Anthropic
22
  if api_key:
23
  llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229', api_key=api_key)
24
  query_engine = PandasQueryEngine(df=df, llm=llm, verbose=True)
25
+
26
  # Input user question
27
  question = st.text_input("Ask a question about the data:")
28
  if st.button("Submit"):
 
30
  response = query_engine.query(question)
31
  st.markdown(f"**Response:** {response}")
32
 
33
+ # Clear input fields
34
+ if st.button("Clear"):
35
+ st.text_input("Enter your ANTHROPIC_API_KEY:", value='')
36
+ st.text_input("Ask a question about the data:", value='')
37
+
38
  if __name__ == "__main__":
39
  main()