Spaces:
Sleeping
Sleeping
Update app.py
Browse filesChanged the /api/custom-qa endpoint as well as the custom_qa_automation function to try and return only string output instead of JSON.
app.py
CHANGED
|
@@ -221,7 +221,8 @@ def custom_qa_automation(text: str, custom_question: str):
|
|
| 221 |
# Format the answer with the "Comments:" tag in bold and on a new line
|
| 222 |
formatted_answer = f"<p><b>Response:</b> {main_answer}</p><p><b>Comment:</b> {details}</p>" #f"**{custom_question}** {main_answer}\n\n**Comments:** {details}"
|
| 223 |
|
| 224 |
-
return GenerateResponse(text=formatted_answer)
|
|
|
|
| 225 |
|
| 226 |
# Transcription function
|
| 227 |
def transcription(file):
|
|
@@ -286,7 +287,11 @@ def inference(input_prompt: Prompt):
|
|
| 286 |
def inference(input_prompt: Prompt):
|
| 287 |
return check_agent_steps(text=input_prompt.text)
|
| 288 |
|
| 289 |
-
@app.post("/api/custom-qa", summary="Generate text from prompt", tags=["Generate"], response_model=GenerateResponse)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
def inference(input_prompt: Prompt, question: Prompt):
|
| 291 |
return custom_qa_automation(text=input_prompt.text, custom_question=question.text)
|
| 292 |
|
|
|
|
| 221 |
# Format the answer with the "Comments:" tag in bold and on a new line
|
| 222 |
formatted_answer = f"<p><b>Response:</b> {main_answer}</p><p><b>Comment:</b> {details}</p>" #f"**{custom_question}** {main_answer}\n\n**Comments:** {details}"
|
| 223 |
|
| 224 |
+
#return GenerateResponse(text=formatted_answer)
|
| 225 |
+
return formatted_answer # Returning string directly instead of being placed within the GenerateResponse class
|
| 226 |
|
| 227 |
# Transcription function
|
| 228 |
def transcription(file):
|
|
|
|
| 287 |
def inference(input_prompt: Prompt):
|
| 288 |
return check_agent_steps(text=input_prompt.text)
|
| 289 |
|
| 290 |
+
# @app.post("/api/custom-qa", summary="Generate text from prompt", tags=["Generate"], response_model=GenerateResponse)
|
| 291 |
+
# def inference(input_prompt: Prompt, question: Prompt):
|
| 292 |
+
# return custom_qa_automation(text=input_prompt.text, custom_question=question.text)
|
| 293 |
+
|
| 294 |
+
@app.post("/api/custom-qa", summary="Generate text from prompt", response_class=PlainTextResponse) # Attempt to only return HTML string instead of json output
|
| 295 |
def inference(input_prompt: Prompt, question: Prompt):
|
| 296 |
return custom_qa_automation(text=input_prompt.text, custom_question=question.text)
|
| 297 |
|