diff --git a/main/xiaozhi-server/client.py b/main/xiaozhi-server/client.py index 355eb601a..784acf2da 100644 --- a/main/xiaozhi-server/client.py +++ b/main/xiaozhi-server/client.py @@ -19,9 +19,9 @@ import opuslib # --- Configuration --- -SERVER_IP = "192.168.1.105" # !!! UPDATE with your server's local IP address !!! +SERVER_IP = "192.168.1.4" # !!! UPDATE with your server's local IP address !!! OTA_PORT = 8003 -MQTT_BROKER_HOST = "192.168.1.105" # MQTT gateway IP +MQTT_BROKER_HOST = "192.168.1.4" # MQTT gateway IP MQTT_BROKER_PORT = 1883 @@ -87,7 +87,7 @@ class TestClient: def __init__(self): self.mqtt_client = None # Generate a unique MAC address for this client instance - self.device_mac_formatted = generate_unique_mac() + self.device_mac_formatted = "00:16:3e:ac:b5:38" print(f"Generated unique MAC address: {self.device_mac_formatted}") # MQTT credentials will be set from OTA response diff --git a/main/xiaozhi-server/config/config_loader.py b/main/xiaozhi-server/config/config_loader.py index cd03ce359..fc72dd10d 100644 --- a/main/xiaozhi-server/config/config_loader.py +++ b/main/xiaozhi-server/config/config_loader.py @@ -46,18 +46,26 @@ def get_config_from_api(config): """Get configuration from Java API""" # Initialize API client init_service(config) - + # Get server configuration config_data = get_server_config() if config_data is None: raise Exception("Failed to fetch server config from API") - + + # Print the configuration received from API + print("=" * 80) + print("CONFIGURATION RECEIVED FROM API:") + print("=" * 80) + import json + print(json.dumps(config_data, indent=2, ensure_ascii=False)) + print("=" * 80) + config_data["read_config_from_api"] = True config_data["manager-api"] = { "url": config["manager-api"].get("url", ""), "secret": config["manager-api"].get("secret", ""), } - + # Use local server configuration as priority if config.get("server"): config_data["server"] = { @@ -67,7 +75,12 @@ def get_config_from_api(config): "vision_explain": config["server"].get("vision_explain", ""), "auth_key": config["server"].get("auth_key", ""), } - + + print("FINAL MERGED CONFIGURATION:") + print("=" * 80) + print(json.dumps(config_data, indent=2, ensure_ascii=False)) + print("=" * 80) + return config_data def get_private_config_from_api(config, device_id, client_id): diff --git a/main/xiaozhi-server/config/logger.py b/main/xiaozhi-server/config/logger.py index dc9003c7a..abd2b98d7 100644 --- a/main/xiaozhi-server/config/logger.py +++ b/main/xiaozhi-server/config/logger.py @@ -139,6 +139,13 @@ def setup_logging(): log_format_file = log_format_file.replace("{version}", SERVER_VERSION) log_level = log_config.get("log_level", "INFO") + + # Validate log level - if it's not a valid log level, default to INFO + valid_log_levels = ["TRACE", "DEBUG", "INFO", "SUCCESS", "WARNING", "ERROR", "CRITICAL"] + if log_level not in valid_log_levels: + logger.warning(f"Invalid log level '{log_level}' found in config, defaulting to INFO") + log_level = "INFO" + log_dir = log_config.get("log_dir", "tmp") log_file = log_config.get("log_file", "server.log") data_dir = log_config.get("data_dir", "data") diff --git a/main/xiaozhi-server/core/providers/llm/openai/openai.py b/main/xiaozhi-server/core/providers/llm/openai/openai.py index 5c22401a8..1f31082cb 100644 --- a/main/xiaozhi-server/core/providers/llm/openai/openai.py +++ b/main/xiaozhi-server/core/providers/llm/openai/openai.py @@ -96,6 +96,9 @@ 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}]" def response_with_functions(self, session_id, dialogue, functions=None): @@ -123,4 +126,6 @@ class LLMProvider(LLMProviderBase): except Exception as e: logger.bind(tag=TAG).error(f"Error in function call streaming: {e}") - yield f"[OpenAI Service Response Exception: {e}]", None \ No newline at end of file + # 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 \ No newline at end of file