mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
changed provider pare , add model and dialogue box to englih
This commit is contained in:
parent
eb4b6bfecc
commit
c5aff8874b
4 changed files with 33 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ def get_config_from_api(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", ""),
|
||||
|
|
@ -68,6 +76,11 @@ def get_config_from_api(config):
|
|||
"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):
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
# 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
|
||||
Loading…
Reference in a new issue