Update llm_handler.py
Browse files- 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|