Romanchello-bit commited on
Commit
1596990
·
1 Parent(s): 33764ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -195,20 +195,24 @@ def generate_response(model, context, user_input, intent, lead_info, archetype):
195
  except: return "..."
196
 
197
  def generate_greeting(model, start_node_text, lead_info):
198
- """Генерує ПЕРШЕ повідомлення, щоб воно було живим"""
 
 
 
 
 
199
 
200
  prompt = f"""
201
- ROLE: Professional Sales Rep named {lead_info['bot_name']}.
202
- CLIENT: {lead_info['client_name']} from {lead_info['company']}.
203
- TYPE: {lead_info['type']} ({lead_info['context']}).
204
 
205
- GOAL: Start the conversation based on this script instruction: "{start_node_text}".
206
 
207
  INSTRUCTIONS:
208
- - If B2B Cold Call: Be formal, check if this is the right company, ask for the decision maker.
209
- - If B2C: Be friendly, use the client's name directly.
210
- - ALWAYS state your name ({lead_info['bot_name']}) and company (SellMe AI).
211
- - Make it sound natural, not robotic.
212
  - Language: Ukrainian.
213
 
214
  OUTPUT: Just the spoken greeting.
@@ -216,7 +220,7 @@ def generate_greeting(model, start_node_text, lead_info):
216
  try:
217
  return model.generate_content(prompt).text.strip()
218
  except:
219
- return f"Доброго дня, це {lead_info['bot_name']} з SellMe. Маєте хвилинку?"
220
 
221
 
222
  # --- UI COMPONENTS ---
@@ -345,7 +349,7 @@ elif st.session_state.page == "setup":
345
  # Зберігаємо все, включаючи ім'я бота
346
  st.session_state.lead_info = {
347
  "bot_name": bot_name,
348
- "client_name": name,
349
  "company": company,
350
  "type": type_,
351
  "context": context
 
195
  except: return "..."
196
 
197
  def generate_greeting(model, start_node_text, lead_info):
198
+ """Генерує ПЕРШЕ повідомлення"""
199
+
200
+ # Використовуємо .get(), щоб уникнути помилок, якщо ключа немає
201
+ bot_name = lead_info.get('bot_name', 'Олексій')
202
+ client_name = lead_info.get('name', 'Клієнт') # <--- ТУТ ТЕЖ МАЄ БУТИ 'name'
203
+ company = lead_info.get('company', 'Компанія')
204
 
205
  prompt = f"""
206
+ ROLE: Professional Sales Rep named {bot_name}.
207
+ CLIENT: {client_name} from {company}.
208
+ TYPE: {lead_info.get('type')} ({lead_info.get('context')}).
209
 
210
+ GOAL: Start conversation based on instruction: "{start_node_text}".
211
 
212
  INSTRUCTIONS:
213
+ - Always state your name ({bot_name}) and company (SellMe AI).
214
+ - If B2B: Be formal.
215
+ - If B2C: Be friendly.
 
216
  - Language: Ukrainian.
217
 
218
  OUTPUT: Just the spoken greeting.
 
220
  try:
221
  return model.generate_content(prompt).text.strip()
222
  except:
223
+ return f"Доброго дня, це {bot_name} з SellMe. Маєте хвилинку?"
224
 
225
 
226
  # --- UI COMPONENTS ---
 
349
  # Зберігаємо все, включаючи ім'я бота
350
  st.session_state.lead_info = {
351
  "bot_name": bot_name,
352
+ "name": name, # <--- ВИПРАВИЛИ НА "name"
353
  "company": company,
354
  "type": type_,
355
  "context": context