rairo commited on
Commit
60e9507
·
verified ·
1 Parent(s): fcfff0c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -2
main.py CHANGED
@@ -1047,19 +1047,23 @@ class ConversationalAIHandler:
1047
 
1048
  def start_conversation(self, agent_id):
1049
  try:
 
1050
  logger.info(f"[CONVERSATION] Starting conversation with agent: {agent_id}")
1051
- conversation_url = f"{self.base_url}/convai/agents/{agent_id}/conversations"
 
1052
 
1053
- response = requests.post(conversation_url, headers=self.headers, json={}, timeout=30)
1054
 
1055
  if response.status_code == 200:
1056
  conversation_info = response.json()
1057
  conversation_id = conversation_info.get("conversation_id")
1058
  logger.info(f"[CONVERSATION] Conversation started successfully: {conversation_id}")
 
1059
  return conversation_id
1060
  else:
1061
  logger.error(f"[CONVERSATION] Failed to start conversation. Status: {response.status_code}, Response: {response.text}")
1062
  raise Exception(f"Failed to start conversation: {response.text}")
 
1063
  except Exception as e:
1064
  logger.error(f"[CONVERSATION] An exception occurred in start_conversation: {e}")
1065
  raise
 
1047
 
1048
  def start_conversation(self, agent_id):
1049
  try:
1050
+
1051
  logger.info(f"[CONVERSATION] Starting conversation with agent: {agent_id}")
1052
+ conversation_url = f"{self.base_url}/convai/conversations"
1053
+ payload = {"agent_id": agent_id}
1054
 
1055
+ response = requests.post(conversation_url, headers=self.headers, json=payload, timeout=30)
1056
 
1057
  if response.status_code == 200:
1058
  conversation_info = response.json()
1059
  conversation_id = conversation_info.get("conversation_id")
1060
  logger.info(f"[CONVERSATION] Conversation started successfully: {conversation_id}")
1061
+
1062
  return conversation_id
1063
  else:
1064
  logger.error(f"[CONVERSATION] Failed to start conversation. Status: {response.status_code}, Response: {response.text}")
1065
  raise Exception(f"Failed to start conversation: {response.text}")
1066
+
1067
  except Exception as e:
1068
  logger.error(f"[CONVERSATION] An exception occurred in start_conversation: {e}")
1069
  raise