Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,10 +49,27 @@ def summarize_text(text: str):
|
|
| 49 |
presence_penalty=0.0
|
| 50 |
)
|
| 51 |
if response.choices:
|
|
|
|
| 52 |
summary = response.choices[0].text.strip()
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
else:
|
| 55 |
return "No response from the API."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
# QA Automation function
|
|
|
|
| 49 |
presence_penalty=0.0
|
| 50 |
)
|
| 51 |
if response.choices:
|
| 52 |
+
# Extract the text from the response
|
| 53 |
summary = response.choices[0].text.strip()
|
| 54 |
+
|
| 55 |
+
# Use regular expressions to find the keywords/metrics and summary sections
|
| 56 |
+
keywords_match = re.search(r"Keywords/Metrics:(.*?)(\n|$)", summary, re.S)
|
| 57 |
+
summary_match = re.search(r"Summary:(.*?)(\n|$)", summary, re.S)
|
| 58 |
+
|
| 59 |
+
# Extract the content if matches are found
|
| 60 |
+
keywords = keywords_match.group(1).strip() if keywords_match else "No keywords found"
|
| 61 |
+
conversation_summary = summary_match.group(1).strip() if summary_match else "No summary found"
|
| 62 |
+
|
| 63 |
+
# Return a clean version with just the keywords and summary
|
| 64 |
+
return GenerateResponse(text=f"Keywords/Metrics: {keywords}\nSummary: {conversation_summary}")
|
| 65 |
+
|
| 66 |
else:
|
| 67 |
return "No response from the API."
|
| 68 |
+
# if response.choices:
|
| 69 |
+
# summary = response.choices[0].text.strip()
|
| 70 |
+
# return GenerateResponse(text=summary)
|
| 71 |
+
# else:
|
| 72 |
+
# return "No response from the API."
|
| 73 |
|
| 74 |
|
| 75 |
# QA Automation function
|