AmpParth commited on
Commit
82d7727
·
verified ·
1 Parent(s): 6ef8af5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -50,6 +50,19 @@ 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(
@@ -91,7 +104,10 @@ 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,
@@ -100,7 +116,8 @@ def summarize_text(text: str):
100
  )
101
  if response.choices:
102
  # Extract the text from the response
103
- summary = response.choices[0].text.strip()
 
104
 
105
  # Use regular expressions to find the keywords/metrics and summary sections
106
  keywords_match = re.search(r"Keywords/Metrics:(.*?)(\n|$)", summary, re.S)
 
50
  class GenerateResponse4(BaseModel):
51
  text: list
52
 
53
+ # #Prepare the chat prompt
54
+ # chat_prompt = [
55
+ # {
56
+ # "role": "system",
57
+ # "content": [
58
+ # {
59
+ # "type": "text",
60
+ # "text": "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: "
61
+ # }
62
+ # ]
63
+ # }
64
+ # ]
65
+
66
  # #Summarize function
67
  # def summarize_text(text: str):
68
  # response = client.chat.completions.create(
 
104
  response = client.chat.completions.create(
105
  model = deployment_name,
106
  #engine="AmplifAI-Chat",
107
+ messages=[
108
+ {"role": "system", "content": "You are an AI assistant that summarizes conversations and extracts keywords/metrics."},
109
+ {"role": "user", "content": f"The data is a pre-recorded conversation between a call center agent and a customer. Identify the following: \n\n1. Keywords/Metrics about the conversation \n2. A summary of the conversation including details. \n\nOutput format: \nKeywords/Metrics: [Extracted Keywords]\nSummary: [Generated Summary]\n\nData: {text}"}
110
+ ],
111
  temperature=0.7,
112
  max_tokens=750,
113
  top_p=1.0,
 
116
  )
117
  if response.choices:
118
  # Extract the text from the response
119
+ # summary = response.choices[0].text.strip()
120
+ summary = response["choices"][0]["message"]["content"].strip()
121
 
122
  # Use regular expressions to find the keywords/metrics and summary sections
123
  keywords_match = re.search(r"Keywords/Metrics:(.*?)(\n|$)", summary, re.S)