Update Setup UI
This commit is contained in:
parent
494f6e2943
commit
a25e1e4e8b
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
*.log
|
||||
llm_debug.log
|
||||
config.py
|
||||
config.py.bak
|
||||
__pycache__/
|
||||
debug_screenshots/
|
||||
chat_logs/
|
||||
|
||||
60
Setup.py
60
Setup.py
@ -26,13 +26,17 @@ import shutil
|
||||
VERSION = "1.0.0"
|
||||
CONFIG_TEMPLATE_PATH = "config_template.py"
|
||||
ENV_FILE_PATH = ".env"
|
||||
DEFAULT_CHROMA_DATA_PATH = "chroma_data"
|
||||
# Use absolute path for chroma_data
|
||||
DEFAULT_CHROMA_DATA_PATH = os.path.abspath("chroma_data")
|
||||
DEFAULT_CONFIG_SECTION = """# ====================================================================
|
||||
# Wolf Chat Configuration
|
||||
# Generated by setup.py - Edit with care
|
||||
# ====================================================================
|
||||
"""
|
||||
|
||||
# Get current Windows username for default paths
|
||||
CURRENT_USERNAME = os.getenv("USERNAME", "user")
|
||||
|
||||
# ===============================================================
|
||||
# Helper Functions
|
||||
# ===============================================================
|
||||
@ -64,14 +68,20 @@ def load_current_config():
|
||||
config_data = {
|
||||
"OPENAI_API_BASE_URL": "",
|
||||
"LLM_MODEL": "deepseek/deepseek-chat-v3-0324",
|
||||
"MCP_SERVERS": {},
|
||||
"MCP_SERVERS": {
|
||||
"exa": {
|
||||
"enabled": True,
|
||||
"use_smithery": False,
|
||||
"server_path": f"C:/Users/{CURRENT_USERNAME}/AppData/Roaming/npm/exa-mcp-server"
|
||||
}
|
||||
},
|
||||
"ENABLE_CHAT_LOGGING": True,
|
||||
"LOG_DIR": "chat_logs",
|
||||
"GAME_WINDOW_CONFIG": {
|
||||
"WINDOW_TITLE": "Last War-Survival Game",
|
||||
"ENABLE_SCHEDULED_RESTART": True,
|
||||
"RESTART_INTERVAL_MINUTES": 60,
|
||||
"GAME_EXECUTABLE_PATH": r"C:\Users\user\AppData\Local\TheLastWar\Launch.exe",
|
||||
"GAME_EXECUTABLE_PATH": fr"C:\Users\{CURRENT_USERNAME}\AppData\Local\TheLastWar\Launch.exe",
|
||||
"GAME_WINDOW_X": 50,
|
||||
"GAME_WINDOW_Y": 30,
|
||||
"GAME_WINDOW_WIDTH": 600,
|
||||
@ -207,6 +217,12 @@ def generate_config_file(config_data, env_data):
|
||||
shutil.copy2("config.py", backup_path)
|
||||
print(f"Created backup of existing config at {backup_path}")
|
||||
|
||||
# Helper function to ensure absolute path
|
||||
def ensure_absolute_path(path):
|
||||
if not os.path.isabs(path):
|
||||
return os.path.abspath(path)
|
||||
return path
|
||||
|
||||
with open("config.py", 'w', encoding='utf-8') as f:
|
||||
f.write(DEFAULT_CONFIG_SECTION)
|
||||
f.write("import os\n")
|
||||
@ -279,14 +295,17 @@ def generate_config_file(config_data, env_data):
|
||||
|
||||
# Handle Chroma server
|
||||
elif server_name == "chroma":
|
||||
# Ensure absolute path for chroma data directory
|
||||
data_dir = server_config.get("data_dir", DEFAULT_CHROMA_DATA_PATH)
|
||||
absolute_data_dir = ensure_absolute_path(data_dir)
|
||||
|
||||
f.write(" \"command\": \"uvx\",\n")
|
||||
f.write(" \"args\": [\n")
|
||||
f.write(" \"chroma-mcp\",\n")
|
||||
f.write(" \"--client-type\",\n")
|
||||
f.write(" \"persistent\",\n")
|
||||
f.write(" \"--data-dir\",\n")
|
||||
f.write(f" \"{data_dir}\"\n")
|
||||
f.write(f" \"{absolute_data_dir}\"\n")
|
||||
f.write(" ]\n")
|
||||
|
||||
# Handle custom server - just write as raw JSON
|
||||
@ -537,25 +556,25 @@ class WolfChatSetup(tk.Tk):
|
||||
type_label = ttk.Label(type_frame, text="Server Type:", width=15)
|
||||
type_label.pack(side=tk.LEFT)
|
||||
|
||||
self.exa_type_var = tk.StringVar(value="smithery")
|
||||
self.exa_type_var = tk.StringVar(value="local") # Changed default to local
|
||||
|
||||
smithery_radio = ttk.Radiobutton(type_frame, text="Smithery (recommended)",
|
||||
variable=self.exa_type_var, value="smithery",
|
||||
command=self.update_exa_settings_visibility)
|
||||
smithery_radio.pack(anchor=tk.W)
|
||||
|
||||
local_radio = ttk.Radiobutton(type_frame, text="Local Server",
|
||||
local_radio = ttk.Radiobutton(type_frame, text="Local Server (recommended)",
|
||||
variable=self.exa_type_var, value="local",
|
||||
command=self.update_exa_settings_visibility)
|
||||
local_radio.pack(anchor=tk.W)
|
||||
|
||||
smithery_radio = ttk.Radiobutton(type_frame, text="Smithery",
|
||||
variable=self.exa_type_var, value="smithery",
|
||||
command=self.update_exa_settings_visibility)
|
||||
smithery_radio.pack(anchor=tk.W)
|
||||
|
||||
# Local Server Path
|
||||
self.exa_local_frame = ttk.Frame(self.exa_frame)
|
||||
|
||||
local_path_label = ttk.Label(self.exa_local_frame, text="Server Path:", width=15)
|
||||
local_path_label.pack(side=tk.LEFT)
|
||||
|
||||
self.exa_path_var = tk.StringVar()
|
||||
self.exa_path_var = tk.StringVar(value=f"C:/Users/{CURRENT_USERNAME}/AppData/Roaming/npm/exa-mcp-server")
|
||||
self.exa_path_entry = ttk.Entry(self.exa_local_frame, textvariable=self.exa_path_var)
|
||||
self.exa_path_entry.pack(side=tk.LEFT, fill=tk.X, expand=True)
|
||||
|
||||
@ -577,8 +596,8 @@ class WolfChatSetup(tk.Tk):
|
||||
info_text = (
|
||||
"• Exa MCP provides web search and research capabilities\n"
|
||||
"• An Exa API key is required (obtain from https://exa.ai)\n"
|
||||
"• Smithery is easiest to use but requires an internet connection\n"
|
||||
"• Local server requires manual installation of exa-mcp-server"
|
||||
"• Local server is the default and preferred option\n"
|
||||
"• Smithery requires an internet connection each time"
|
||||
)
|
||||
|
||||
info_label = ttk.Label(info_frame, text=info_text, justify=tk.LEFT, wraplength=400)
|
||||
@ -710,7 +729,7 @@ class WolfChatSetup(tk.Tk):
|
||||
path_label = ttk.Label(path_frame, text="Game Executable Path:", width=20)
|
||||
path_label.pack(side=tk.LEFT, padx=(0, 5))
|
||||
|
||||
self.game_path_var = tk.StringVar()
|
||||
self.game_path_var = tk.StringVar(value=fr"C:\Users\{CURRENT_USERNAME}\AppData\Local\TheLastWar\Launch.exe")
|
||||
path_entry = ttk.Entry(path_frame, textvariable=self.game_path_var)
|
||||
path_entry.pack(side=tk.LEFT, fill=tk.X, expand=True)
|
||||
|
||||
@ -869,7 +888,11 @@ class WolfChatSetup(tk.Tk):
|
||||
self.chroma_enable_var.set(chroma_config.get("enabled", True))
|
||||
data_dir = chroma_config.get("data_dir", "")
|
||||
if data_dir:
|
||||
self.chroma_dir_var.set(data_dir)
|
||||
# Ensure data directory is absolute path
|
||||
self.chroma_dir_var.set(os.path.abspath(data_dir))
|
||||
else:
|
||||
# Set default as absolute path
|
||||
self.chroma_dir_var.set(DEFAULT_CHROMA_DATA_PATH)
|
||||
|
||||
# Update servers list to include custom servers
|
||||
self.update_servers_list()
|
||||
@ -938,10 +961,11 @@ class WolfChatSetup(tk.Tk):
|
||||
"""Browse for Chroma data directory"""
|
||||
dir_path = filedialog.askdirectory(
|
||||
title="Select Chroma Data Directory",
|
||||
initialdir=os.path.abspath(DEFAULT_CHROMA_DATA_PATH)
|
||||
initialdir=os.path.dirname(DEFAULT_CHROMA_DATA_PATH)
|
||||
)
|
||||
if dir_path:
|
||||
self.chroma_dir_var.set(dir_path)
|
||||
# Always store as absolute path
|
||||
self.chroma_dir_var.set(os.path.abspath(dir_path))
|
||||
|
||||
def browse_game_path(self):
|
||||
"""Browse for game executable"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user