Spaces:
Runtime error
Runtime error
Commit
·
0db2a92
1
Parent(s):
9457e26
Update app.py
Browse files
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 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
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 = [
|