Atharva Thakur commited on
Commit
9591233
1 Parent(s): a0155bf

QA module added

Browse files
Files changed (5) hide show
  1. .gitignore +2 -0
  2. .gitpod.yml +11 -0
  3. data_QA.py +17 -0
  4. requirements.txt +4 -1
  5. test.py +14 -0
.gitignore CHANGED
@@ -7,6 +7,8 @@ __pycache__/
7
  # C extensions
8
  *.so
9
 
 
 
10
  # Distribution / packaging
11
  .Python
12
  build/
 
7
  # C extensions
8
  *.so
9
 
10
+ #Env variables
11
+ .env
12
  # Distribution / packaging
13
  .Python
14
  build/
.gitpod.yml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This configuration file was automatically generated by Gitpod.
2
+ # Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
3
+ # and commit this file to your remote git repository to share the goodness with others.
4
+
5
+ # Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
6
+
7
+ tasks:
8
+ - init: pip install -r requirements.txt
9
+ command: python app.py
10
+
11
+
data_QA.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain_google_genai import GoogleGenerativeAI
3
+ from langchain_experimental.agents import create_pandas_agent
4
+ import pandas as pd
5
+ from dotenv import load_dotenv
6
+
7
+ load_dotenv() # take environment variables from .env.
8
+
9
+ class DataQA:
10
+ def __init__(self, data):
11
+ self.data = data
12
+ def ask_csv(self):
13
+ llm = GoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_API_KEY)
14
+ csv_agent = create_pandas_agent(llm,self.data, verbose=True)
15
+ question = st.text_input("Ask your question:")
16
+ if question:
17
+ csv_agent.run(question)
requirements.txt CHANGED
@@ -2,4 +2,7 @@ streamlit
2
  pandas
3
  numpy
4
  matplotlib
5
- seaborn
 
 
 
 
2
  pandas
3
  numpy
4
  matplotlib
5
+ seaborn
6
+ langchain-google-genai
7
+ langchain-experimental
8
+ python-dotenv
test.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain_google_genai import GoogleGenerativeAI
3
+ from langchain_experimental.agents import create_pandas_agent
4
+ import pandas as pd
5
+ from dotenv import load_dotenv
6
+
7
+ load_dotenv() # take environment variables from .env.
8
+
9
+ data = pd.read_csv("")
10
+ llm = GoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_API_KEY)
11
+ csv_agent = create_pandas_agent(llm,self.data, verbose=True)
12
+ question = st.text_input("Ask your question:")
13
+ if question:
14
+ csv_agent.run(question)