refactor: restructure to core/ + ui/ with multi-threaded backend

This commit is contained in:
root
2026-04-12 18:15:55 +08:00
parent c13d3f671c
commit 83906a6985
64 changed files with 5269 additions and 571 deletions

27
core/client.py Normal file
View File

@ -0,0 +1,27 @@
import threading
from typing import Any, Dict
from .server import BackendServer
class BackendClient:
def __init__(self, server: BackendServer):
self._server = server
self._request_counter = 0
self._lock = threading.Lock()
def process_message(self, user_input: str, timeout: float = 30.0) -> Dict[str, Any]:
with self._lock:
self._request_counter += 1
return self._server.process_message(user_input, timeout)
def execute_tool(self, tool_name: str, arguments: Dict[str, Any], timeout: float = 10.0) -> str:
with self._lock:
self._request_counter += 1
return self._server.execute_tool(tool_name, arguments, timeout)
def update_config(self, api_key: str, base_url: str = "https://api.deepseek.com") -> None:
self._server.update_config(api_key, base_url)
def shutdown(self) -> None:
self._server.shutdown()