Severian commited on
Commit
9979a06
1 Parent(s): d13268c

Update llm_handler.py

Browse files
Files changed (1) hide show
  1. llm_handler.py +8 -1
llm_handler.py CHANGED
@@ -29,7 +29,14 @@ def send_to_llm(provider, msg_list):
29
 
30
  # Call get_chat_response with the full message string
31
  response = agent.get_chat_response(full_message, llm_sampling_settings=settings)
32
- return response.content, None # We don't have usage info in this case
 
 
 
 
 
 
 
33
  except Exception as e:
34
  print(f"Error in send_to_llm: {str(e)}")
35
  return f"Error: {str(e)}", None
 
29
 
30
  # Call get_chat_response with the full message string
31
  response = agent.get_chat_response(full_message, llm_sampling_settings=settings)
32
+
33
+ # Check if response is a string or an object with content attribute
34
+ if isinstance(response, str):
35
+ return response, None
36
+ elif hasattr(response, 'content'):
37
+ return response.content, None
38
+ else:
39
+ return str(response), None # Convert to string if it's neither
40
  except Exception as e:
41
  print(f"Error in send_to_llm: {str(e)}")
42
  return f"Error: {str(e)}", None