runtime.py 788 B

1234567891011121314151617181920212223242526272829303132
  1. """Agent 运行时端口。
  2. 实际 LangChain/DeepSeek 实现在 ``app.harness.kernel``,领域服务只依赖此协议。
  3. """
  4. from typing import Protocol
  5. from app.core.errors import AppError
  6. from app.harness.kernel import AgentInvocation
  7. from app.harness.schemas import AgentReply
  8. __all__ = [
  9. "AgentInvocation",
  10. "AgentReply",
  11. "AgentRuntime",
  12. "UnavailableAgentRuntime",
  13. ]
  14. class AgentRuntime(Protocol):
  15. def reply(self, invocation: AgentInvocation) -> AgentReply: ...
  16. class UnavailableAgentRuntime:
  17. def reply(self, invocation: AgentInvocation) -> AgentReply:
  18. del invocation
  19. raise AppError(
  20. "AGENT_NOT_CONFIGURED",
  21. "DeepSeek尚未配置,无法启动智能体",
  22. 503,
  23. retryable=False,
  24. )