Spaces:
Running
Running
update clarification function
Browse files
main.py
CHANGED
@@ -424,6 +424,24 @@ def parse_followup_response(response):
|
|
424 |
|
425 |
return response_content, clarification
|
426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
@app.post("/followup-agent")
|
428 |
async def followup_agent(query: FollowupQueryModel, background_tasks: BackgroundTasks, api_key: str = Depends(verify_api_key)):
|
429 |
"""
|
|
|
424 |
|
425 |
return response_content, clarification
|
426 |
|
427 |
+
|
428 |
+
def parse_clarification(text):
|
429 |
+
questions = []
|
430 |
+
current_question = None
|
431 |
+
|
432 |
+
for line in text.split('\n'):
|
433 |
+
line = line.strip()
|
434 |
+
if line.startswith('- text:'):
|
435 |
+
if current_question:
|
436 |
+
questions.append(current_question)
|
437 |
+
current_question = {'text': line[7:].strip(), 'options': []}
|
438 |
+
elif line.startswith('- ') and current_question:
|
439 |
+
current_question['options'].append(line[2:].strip())
|
440 |
+
|
441 |
+
if current_question:
|
442 |
+
questions.append(current_question)
|
443 |
+
|
444 |
+
|
445 |
@app.post("/followup-agent")
|
446 |
async def followup_agent(query: FollowupQueryModel, background_tasks: BackgroundTasks, api_key: str = Depends(verify_api_key)):
|
447 |
"""
|