Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,28 +62,28 @@ def summarize_text(text: str):
|
|
| 62 |
frequency_penalty=0.0,
|
| 63 |
presence_penalty=0.0
|
| 64 |
)
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
#
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
# Return a clean version with just the keywords and summary
|
| 78 |
-
return GenerateResponse(text=f"Keywords/Metrics: {keywords}\nSummary: {conversation_summary}")
|
| 79 |
-
|
| 80 |
-
else:
|
| 81 |
-
return "No response from the API."
|
| 82 |
-
# if response.choices:
|
| 83 |
-
# summary = response.choices[0].text.strip()
|
| 84 |
-
# return GenerateResponse(text=summary)
|
| 85 |
-
# else:
|
| 86 |
-
# return "No response from the API."
|
| 87 |
|
| 88 |
|
| 89 |
# QA Automation function
|
|
|
|
| 62 |
frequency_penalty=0.0,
|
| 63 |
presence_penalty=0.0
|
| 64 |
)
|
| 65 |
+
if response.choices:
|
| 66 |
+
# Extract the text from the response
|
| 67 |
+
summary = response.choices[0].text.strip()
|
| 68 |
+
|
| 69 |
+
# Use regular expressions to find the keywords/metrics and summary sections
|
| 70 |
+
keywords_match = re.search(r"Keywords/Metrics:(.*?)(\n|$)", summary, re.S)
|
| 71 |
+
summary_match = re.search(r"Summary:(.*?)(\n|$)", summary, re.S)
|
| 72 |
+
|
| 73 |
+
# Extract the content if matches are found
|
| 74 |
+
keywords = keywords_match.group(1).strip() if keywords_match else "No keywords found"
|
| 75 |
+
conversation_summary = summary_match.group(1).strip() if summary_match else "No summary found"
|
| 76 |
+
|
| 77 |
+
# Return a clean version with just the keywords and summary
|
| 78 |
+
return GenerateResponse(text=f"Keywords/Metrics: {keywords}\nSummary: {conversation_summary}")
|
| 79 |
|
| 80 |
+
else:
|
| 81 |
+
return "No response from the API."
|
| 82 |
+
# if response.choices:
|
| 83 |
+
# summary = response.choices[0].text.strip()
|
| 84 |
+
# return GenerateResponse(text=summary)
|
| 85 |
+
# else:
|
| 86 |
+
# return "No response from the API."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
|
| 89 |
# QA Automation function
|