fixed timezone bug and openai expectation

This commit is contained in:
karthikeyareddy183 2025-09-05 17:19:24 +05:30
parent 0d7ee98460
commit e1e909192f
3 changed files with 16 additions and 52 deletions

View file

@ -662,28 +662,11 @@
# # Use mem_local_short mode
# elif memory_type == "mem_local_short":
# self.logger.bind(tag=TAG).info("Memory module initialized: LOCAL STORAGE (mem_local_short)")
# memory_llm_name = memory_config[self.config["selected_module"]["Memory"]][
# "llm"
# ]
# if memory_llm_name and memory_llm_name in self.config["LLM"]:
# # If a dedicated LLM is configured, create an independent LLM instance
# from core.utils import llm as llm_utils
# memory_llm_config = self.config["LLM"][memory_llm_name]
# memory_llm_type = memory_llm_config.get(
# "type", memory_llm_name)
# memory_llm = llm_utils.create_instance(
# memory_llm_type, memory_llm_config
# )
# self.logger.bind(tag=TAG).info(
# f"Created a dedicated LLM for memory summary: {memory_llm_name}, type: {memory_llm_type}"
# )
# self.memory.set_llm(memory_llm)
# else:
# # Otherwise use main LLM
# self.memory.set_llm(self.llm)
# self.logger.bind(tag=TAG).info(
# "Using main LLM as memory model")
# # ALWAYS use the main LLM for memory operations
# # This ensures consistency and avoids configuration issues
# self.memory.set_llm(self.llm)
# self.logger.bind(tag=TAG).info(
# f"Using main LLM ({self.config['selected_module']['LLM']}) for memory operations")
# elif memory_type == "mem0ai":
# self.logger.bind(tag=TAG).info("Memory module initialized: MEM0 CLOUD (mem0ai)")
# else:
@ -1884,28 +1867,11 @@ class ConnectionHandler:
# Use mem_local_short mode
elif memory_type == "mem_local_short":
self.logger.bind(tag=TAG).info("Memory module initialized: LOCAL STORAGE (mem_local_short)")
memory_llm_name = memory_config[self.config["selected_module"]["Memory"]][
"llm"
]
if memory_llm_name and memory_llm_name in self.config["LLM"]:
# If a dedicated LLM is configured, create an independent LLM instance
from core.utils import llm as llm_utils
memory_llm_config = self.config["LLM"][memory_llm_name]
memory_llm_type = memory_llm_config.get(
"type", memory_llm_name)
memory_llm = llm_utils.create_instance(
memory_llm_type, memory_llm_config
)
self.logger.bind(tag=TAG).info(
f"Created a dedicated LLM for memory summary: {memory_llm_name}, type: {memory_llm_type}"
)
self.memory.set_llm(memory_llm)
else:
# Otherwise use main LLM
self.memory.set_llm(self.llm)
self.logger.bind(tag=TAG).info(
"Using main LLM as memory model")
# ALWAYS use the main LLM for memory operations
# This ensures consistency and avoids configuration issues
self.memory.set_llm(self.llm)
self.logger.bind(tag=TAG).info(
f"Using main LLM ({self.config['selected_module']['LLM']}) for memory operations")
elif memory_type == "mem0ai":
self.logger.bind(tag=TAG).info("Memory module initialized: MEM0 CLOUD (mem0ai)")
else:

View file

@ -96,9 +96,8 @@ class LLMProvider(LLMProviderBase):
except Exception as e:
logger.bind(tag=TAG).error(f"Error in response generation: {e}")
# Ensure the error message is properly encoded
error_msg = str(e).encode('utf-8', errors='ignore').decode('utf-8')
yield f"[OpenAI Service Response Exception: {error_msg}]"
# Send user-friendly message instead of technical error details
yield "Server is busy! Will get back soon."
def response_with_functions(self, session_id, dialogue, functions=None):
@ -126,6 +125,5 @@ class LLMProvider(LLMProviderBase):
except Exception as e:
logger.bind(tag=TAG).error(f"Error in function call streaming: {e}")
# Ensure the error message is properly encoded
error_msg = str(e).encode('utf-8', errors='ignore').decode('utf-8')
yield f"[OpenAI Service Response Exception: {error_msg}]", None
# Send user-friendly message instead of technical error details
yield "Server is busy! Will get back soon.", None

View file

@ -201,7 +201,7 @@ class SileroVADAnalyzer(VADAnalyzer):
if self._confidence_log_counter % 100 == 0: # Log every 100th frame (reduced from 10)
audio_rms = float(np.sqrt(np.mean(audio_float32 ** 2)))
confidence_val = float(new_confidence)
confidence_val = float(new_confidence.item()) # Use .item() to extract scalar from numpy array
logger.debug(f"VAD confidence: {confidence_val:.3f}, RMS: {audio_rms:.4f}")
# Reset model periodically to prevent memory growth
@ -211,7 +211,7 @@ class SileroVADAnalyzer(VADAnalyzer):
self._model.reset_states()
self._last_reset_time = curr_time
return float(new_confidence)
return float(new_confidence.item()) # Use .item() to extract scalar from numpy array
except Exception as e:
logger.error(f"Error analyzing audio with Silero ONNX VAD: {e}")
return 0.0