Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,7 @@ client = AzureOpenAI(
|
|
| 30 |
azure_endpoint = "https://amplifai-openai.openai.azure.com/"
|
| 31 |
)
|
| 32 |
|
| 33 |
-
deployment_name='
|
| 34 |
|
| 35 |
DEEPGRAM_API_KEY = os.getenv("DEEPGRAM_API_KEY")
|
| 36 |
if not DEEPGRAM_API_KEY:
|
|
@@ -50,12 +50,48 @@ class GenerateResponse3(BaseModel):
|
|
| 50 |
class GenerateResponse4(BaseModel):
|
| 51 |
text: list
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
#Summarize function
|
| 54 |
def summarize_text(text: str):
|
| 55 |
response = client.chat.completions.create(
|
| 56 |
model = deployment_name,
|
| 57 |
#engine="AmplifAI-Chat",
|
| 58 |
-
messages="The data is a pre-recorded conversation between a call center agent and a customer. Identify the following: keywords/metrics about the conversation, a summary of the conversation including details. Output should be in the format Keywords/Metrics: ,\n Summary:. \n Data: " + text,
|
| 59 |
temperature=0.7,
|
| 60 |
max_tokens=750,
|
| 61 |
top_p=1.0,
|
|
@@ -85,7 +121,6 @@ def summarize_text(text: str):
|
|
| 85 |
# else:
|
| 86 |
# return "No response from the API."
|
| 87 |
|
| 88 |
-
|
| 89 |
# QA Automation function
|
| 90 |
def qa_automation(text: str):
|
| 91 |
questions = [
|
|
|
|
| 30 |
azure_endpoint = "https://amplifai-openai.openai.azure.com/"
|
| 31 |
)
|
| 32 |
|
| 33 |
+
deployment_name='gpt-4'
|
| 34 |
|
| 35 |
DEEPGRAM_API_KEY = os.getenv("DEEPGRAM_API_KEY")
|
| 36 |
if not DEEPGRAM_API_KEY:
|
|
|
|
| 50 |
class GenerateResponse4(BaseModel):
|
| 51 |
text: list
|
| 52 |
|
| 53 |
+
# #Summarize function
|
| 54 |
+
# def summarize_text(text: str):
|
| 55 |
+
# response = client.chat.completions.create(
|
| 56 |
+
# model = deployment_name,
|
| 57 |
+
# #engine="AmplifAI-Chat",
|
| 58 |
+
# messages="The data is a pre-recorded conversation between a call center agent and a customer. Identify the following: keywords/metrics about the conversation, a summary of the conversation including details. Output should be in the format Keywords/Metrics: ,\n Summary:. \n Data: " + text,
|
| 59 |
+
# temperature=0.7,
|
| 60 |
+
# max_tokens=750,
|
| 61 |
+
# top_p=1.0,
|
| 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 |
#Summarize function
|
| 90 |
def summarize_text(text: str):
|
| 91 |
response = client.chat.completions.create(
|
| 92 |
model = deployment_name,
|
| 93 |
#engine="AmplifAI-Chat",
|
| 94 |
+
messages=["The data is a pre-recorded conversation between a call center agent and a customer. Identify the following: keywords/metrics about the conversation, a summary of the conversation including details. Output should be in the format Keywords/Metrics: ,\n Summary:. \n Data: " + text],
|
| 95 |
temperature=0.7,
|
| 96 |
max_tokens=750,
|
| 97 |
top_p=1.0,
|
|
|
|
| 121 |
# else:
|
| 122 |
# return "No response from the API."
|
| 123 |
|
|
|
|
| 124 |
# QA Automation function
|
| 125 |
def qa_automation(text: str):
|
| 126 |
questions = [
|