| #!/bin/bash |
|
|
| |
| echo "=== Запуск исправления интерфейса TEN Agent ===" |
|
|
| |
| mkdir -p /tmp/ten-agent |
| cd /tmp/ten-agent |
|
|
| |
| cat > proxy_server.py << 'EOF' |
| |
| import http.server |
| import socketserver |
| import json |
|
|
| |
| PORT = 9090 |
|
|
| |
| GRAPHS_DATA = [ |
| {"name": "Voice Agent", "description": "Voice Agent with OpenAI", "file": "voice_agent.json", "id": "voice_agent", "package": "default"}, |
| {"name": "Chat Agent", "description": "Chat Agent", "file": "chat_agent.json", "id": "chat_agent", "package": "default"} |
| ] |
|
|
| |
| DESIGNER_DATA = {"success": True, "packages": [{"name": "default", "description": "Default package", "graphs": GRAPHS_DATA}]} |
|
|
| class Handler(http.server.BaseHTTPRequestHandler): |
| def do_GET(self): |
| if self.path == "/graphs": |
| self._send_json(GRAPHS_DATA) |
| elif "/api/designer/" in self.path or "/api/dev/" in self.path: |
| self._send_json(DESIGNER_DATA) |
| else: |
| self._send_json({"status": "ok"}) |
| |
| def do_POST(self): |
| if "/api/designer/" in self.path or "/api/dev/" in self.path: |
| self._send_json({"success": True}) |
| else: |
| self._send_json({"status": "ok"}) |
| |
| def do_OPTIONS(self): |
| self.send_response(200) |
| self.send_header('Access-Control-Allow-Origin', '*') |
| self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS') |
| self.send_header('Access-Control-Allow-Headers', 'Content-Type') |
| self.end_headers() |
| |
| def _send_json(self, data): |
| self.send_response(200) |
| self.send_header('Content-type', 'application/json') |
| self.send_header('Access-Control-Allow-Origin', '*') |
| self.end_headers() |
| self.wfile.write(json.dumps(data).encode()) |
|
|
| |
| try: |
| with socketserver.TCPServer(("", PORT), Handler) as httpd: |
| print(f"Proxy server running at http://localhost:{PORT}") |
| httpd.serve_forever() |
| except Exception as e: |
| print(f"Error starting server: {e}") |
| EOF |
|
|
| # Запускаем прокси-сервер |
| echo "Запуск прокси-сервера..." |
| python3 proxy_server.py & |
| PROXY_PID=$! |
| echo "Прокси-сервер запущен с PID: $PROXY_PID" |
| echo $PROXY_PID > proxy.pid |
|
|
| # Настраиваем переменные окружения для UI |
| export PORT=7860 |
| export AGENT_SERVER_URL="http://localhost:9090" |
| export NEXT_PUBLIC_DEV_MODE="false" |
| export NEXT_PUBLIC_API_BASE_URL="/api/agents" |
| export NEXT_PUBLIC_DESIGNER_API_URL="http://localhost:9090" |
| export NEXT_PUBLIC_EDIT_GRAPH_MODE="true" |
| export NEXT_PUBLIC_DISABLE_CAMERA="true" |
|
|
| echo "Настройки применены" |
| echo "Для запуска UI выполните: cd /app/playground && pnpm dev" |
| echo "Для проверки прокси: curl http://localhost:9090/graphs" |