Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -137,8 +137,7 @@ def query(category, text):
|
|
137 |
]
|
138 |
)
|
139 |
answer = result.generations[0][0].text
|
140 |
-
|
141 |
-
return answer
|
142 |
|
143 |
|
144 |
PARSING_REGEXP = r"\*\*System:\*\*\n([\s\S]+)\n\n\*\*Human:\*\*\n([\s\S]+)"
|
@@ -148,12 +147,12 @@ def parse(category, chatbot):
|
|
148 |
"""Takes the chatbot prompt and response and updates the extracted information"""
|
149 |
global PARSING_REGEXP
|
150 |
|
151 |
-
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
|
158 |
if category not in Category.__members__:
|
159 |
# Handle the case when an invalid category is provided
|
@@ -205,7 +204,7 @@ def process_and_output_files(input_files):
|
|
205 |
"File Name": file.name,
|
206 |
"Extracted Text": text,
|
207 |
"Category": category,
|
208 |
-
"Chatbot Response": chatbot_response, # Access the first element as a list
|
209 |
"Parsed Information": parsed_info,
|
210 |
})
|
211 |
|
@@ -418,4 +417,4 @@ page.queue(
|
|
418 |
concurrency_count=20,
|
419 |
max_size=1,
|
420 |
)
|
421 |
-
page.launch(show_api=True, show_error=True, debug=True)
|
|
|
137 |
]
|
138 |
)
|
139 |
answer = result.generations[0][0].text
|
140 |
+
yield gr.Chatbot.update([[question, answer]])
|
|
|
141 |
|
142 |
|
143 |
PARSING_REGEXP = r"\*\*System:\*\*\n([\s\S]+)\n\n\*\*Human:\*\*\n([\s\S]+)"
|
|
|
147 |
"""Takes the chatbot prompt and response and updates the extracted information"""
|
148 |
global PARSING_REGEXP
|
149 |
|
150 |
+
|
151 |
|
152 |
+
try:
|
153 |
+
answer = next(chatbot)[1]
|
154 |
+
except StopIteration:
|
155 |
+
answer = ""
|
156 |
|
157 |
if category not in Category.__members__:
|
158 |
# Handle the case when an invalid category is provided
|
|
|
204 |
"File Name": file.name,
|
205 |
"Extracted Text": text,
|
206 |
"Category": category,
|
207 |
+
# "Chatbot Response": chatbot_response[0][1], # Access the first element as a list
|
208 |
"Parsed Information": parsed_info,
|
209 |
})
|
210 |
|
|
|
417 |
concurrency_count=20,
|
418 |
max_size=1,
|
419 |
)
|
420 |
+
page.launch(show_api=True, show_error=True, debug=True)
|