robertselvam commited on
Commit
0db2a92
·
1 Parent(s): 9457e26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -135,17 +135,11 @@ class ChatDocumentQA:
135
  vectorstore = self._create_vector_store_from_text_chunks(text_chunks)
136
  return "file uploaded", {"knowledge_base": vectorstore}
137
  elif file_extension == '.csv':
138
- # df = pd.read_csv(file_path)
139
- # pd_agent = create_pandas_dataframe_agent(OpenAI(temperature=0), df, verbose=True)
140
- # tools = self.get_agent_tools(pd_agent)
141
- # memory,tools,prompt = self.create_memory_for_csv_qa(tools)
142
- # agent_chain = self.create_agent_chain_for_csv_qa(memory,tools,prompt)
143
- agent_chain = create_csv_agent(
144
- OpenAI(temperature=0),
145
- file_path,
146
- verbose=True,
147
- agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
148
- )
149
  return "file uploaded", {"knowledge_base": agent_chain}
150
 
151
  else:
@@ -168,6 +162,14 @@ class ChatDocumentQA:
168
  #************************
169
  # csv qa
170
  #************************
 
 
 
 
 
 
 
 
171
  def get_agent_tools(self,agent):
172
  # search = agent
173
  tools = [
 
135
  vectorstore = self._create_vector_store_from_text_chunks(text_chunks)
136
  return "file uploaded", {"knowledge_base": vectorstore}
137
  elif file_extension == '.csv':
138
+ agent = create_agent(file_path)
139
+ tools = self.get_agent_tools(agent)
140
+ memory,tools,prompt = self.create_memory_for_csv_qa(tools)
141
+ agent_chain = self.create_agent_chain_for_csv_qa(memory,tools,prompt)
142
+
 
 
 
 
 
 
143
  return "file uploaded", {"knowledge_base": agent_chain}
144
 
145
  else:
 
162
  #************************
163
  # csv qa
164
  #************************
165
+ def create_agent(self,file_path):
166
+ agent_chain = create_csv_agent(
167
+ OpenAI(temperature=0),
168
+ file_path,
169
+ verbose=True,
170
+ agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
171
+ )
172
+ return agent_chain
173
  def get_agent_tools(self,agent):
174
  # search = agent
175
  tools = [