fix(agent): proxy gradio config and reduce translate blocking
This commit is contained in:
@@ -11,6 +11,7 @@ FASTAPI_URL: str = os.getenv("FASTAPI_URL", "http://localhost:8000")
|
||||
SERVICE_JWT: str = os.getenv("SERVICE_JWT", "")
|
||||
GRADIO_SERVER_NAME: str = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
|
||||
GRADIO_SERVER_PORT: int = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
|
||||
GRADIO_ROOT_PATH: str = os.getenv("GRADIO_ROOT_PATH", "/api/agent/gradio")
|
||||
GRADIO_ALLOW_PORT_FALLBACK: bool = os.getenv("GRADIO_ALLOW_PORT_FALLBACK", "").strip().lower() in {"1", "true", "yes"}
|
||||
STORAGE_ROOT: str = os.getenv("STORAGE_ROOT", "/app/storage")
|
||||
AGENT_PREFETCH_DASHBOARD_LIMIT: int = int(os.getenv("AGENT_PREFETCH_DASHBOARD_LIMIT", "25"))
|
||||
|
||||
@@ -33,7 +33,7 @@ from langchain_core.messages import HumanMessage
|
||||
from langchain_openai import ChatOpenAI
|
||||
from openai import APIConnectionError, APITimeoutError, AuthenticationError, RateLimitError
|
||||
|
||||
from ss_tools.agent._config import GRADIO_SERVER_NAME, GRADIO_SERVER_PORT, STORAGE_ROOT as _STORAGE_ROOT
|
||||
from ss_tools.agent._config import GRADIO_ROOT_PATH, GRADIO_SERVER_NAME, GRADIO_SERVER_PORT, STORAGE_ROOT as _STORAGE_ROOT
|
||||
from ss_tools.agent._confirmation import (
|
||||
_pending_confirmations,
|
||||
confirmation_payload,
|
||||
@@ -817,5 +817,6 @@ if __name__ == "__main__":
|
||||
demo.launch(
|
||||
server_name=GRADIO_SERVER_NAME,
|
||||
server_port=GRADIO_SERVER_PORT,
|
||||
root_path=GRADIO_ROOT_PATH,
|
||||
)
|
||||
# #endregion AgentChat.GradioApp
|
||||
|
||||
@@ -12,7 +12,14 @@ import socket
|
||||
|
||||
import httpx
|
||||
|
||||
from ss_tools.agent._config import FASTAPI_URL, GRADIO_ALLOW_PORT_FALLBACK, GRADIO_SERVER_NAME, GRADIO_SERVER_PORT, SERVICE_JWT
|
||||
from ss_tools.agent._config import (
|
||||
FASTAPI_URL,
|
||||
GRADIO_ALLOW_PORT_FALLBACK,
|
||||
GRADIO_ROOT_PATH,
|
||||
GRADIO_SERVER_NAME,
|
||||
GRADIO_SERVER_PORT,
|
||||
SERVICE_JWT,
|
||||
)
|
||||
from ss_tools.shared.cot_logger import seed_trace_id
|
||||
from ss_tools.shared.logger import logger
|
||||
|
||||
@@ -128,5 +135,6 @@ if __name__ == "__main__":
|
||||
demo.launch(
|
||||
server_name=GRADIO_SERVER_NAME,
|
||||
server_port=port,
|
||||
root_path=GRADIO_ROOT_PATH,
|
||||
)
|
||||
# #endregion AgentChat.Run
|
||||
|
||||
@@ -160,6 +160,7 @@ class TestMainBlock:
|
||||
patch('ss_tools.agent.langgraph_setup.init_checkpointer'), \
|
||||
patch('ss_tools.agent.run.SERVICE_JWT', svc_jwt), \
|
||||
patch('ss_tools.agent.run.GRADIO_SERVER_PORT', gradio_port), \
|
||||
patch('ss_tools.agent.run.GRADIO_ROOT_PATH', env_overrides.get("GRADIO_ROOT_PATH", "/api/agent/gradio")), \
|
||||
patch('ss_tools.agent.run.GRADIO_ALLOW_PORT_FALLBACK', gradio_fallback):
|
||||
mock_asyncio_run.side_effect = lambda coro: coro.close() if hasattr(coro, "close") else None
|
||||
|
||||
@@ -206,6 +207,7 @@ class TestMainBlock:
|
||||
result['set_jwt'].assert_not_called()
|
||||
result['configure'].assert_not_called()
|
||||
result['demo'].launch.assert_called_once()
|
||||
assert result['demo'].launch.call_args.kwargs["root_path"] == "/api/agent/gradio"
|
||||
|
||||
def test_main_block_with_service_jwt(self, monkeypatch):
|
||||
"""Main block sets service JWT via ContextVar."""
|
||||
|
||||
Reference in New Issue
Block a user