feat(ai_agent): 完善AI适配器和服务功能 - 添加OpenClaw和Hermes健康检查接口 - 实现OpenClaw工具调用功能 - 重构AI适配器使用常量定义 - 增加AI技能系统支持 - 更新配置文件中的默认模型提供者设置 refactor(scheduler): 使用常量替换硬编码值 - 将硬编码的actor值替换为ActorValue常量 - 将receive_id_type替换为FeishuReceiveIdType枚举 refactor(audit): 统一审计日志常量使用 - 将硬编码的actor、source、risk_level等值替换为对应常量 - 更新审核服务中的状态和操作常量引用 refactor(approvals): 标准化审批模块常量使用 - 将applicant默认值替换为ActorValue.API常量 - 使用ApprovalStatus常量替代硬编码状态值 - 更新审核操作常量引用 ```
129 lines
3.1 KiB
Python
129 lines
3.1 KiB
Python
from enum import StrEnum
|
|
|
|
|
|
class AIProviderName(StrEnum):
|
|
NOOP = "noop"
|
|
OPENCLAW = "openclaw"
|
|
HERMES = "hermes"
|
|
OPENCLAW_HERMES = "openclaw_hermes"
|
|
OPENCLAW_HERMES_DASH = "openclaw-hermes"
|
|
HYBRID = "hybrid"
|
|
DIRECT_LLM = "direct_llm"
|
|
|
|
|
|
class AIResponseKey(StrEnum):
|
|
PROVIDER = "provider"
|
|
ANSWER = "answer"
|
|
RAW = "raw"
|
|
RESULT = "result"
|
|
OK = "ok"
|
|
ERROR = "error"
|
|
MESSAGE = "message"
|
|
TYPE = "type"
|
|
BASE_URL = "base_url"
|
|
HEALTH = "health"
|
|
HEALTHZ = "healthz"
|
|
READYZ = "readyz"
|
|
DATA = "data"
|
|
STATUS_CODE = "status_code"
|
|
TEXT = "text"
|
|
PIPELINE = "pipeline"
|
|
HERMES_RECALL = "hermes_recall"
|
|
HERMES_ANSWER = "hermes_answer"
|
|
HERMES_REMEMBER = "hermes_remember"
|
|
OPENCLAW = "openclaw"
|
|
TOOL = "tool"
|
|
TOOL_INVOKED = "tool_invoked"
|
|
TOOL_ERROR = "tool_error"
|
|
|
|
|
|
class AIRequestKey(StrEnum):
|
|
PROMPT = "prompt"
|
|
CONTEXT = "context"
|
|
|
|
|
|
class AIContextKey(StrEnum):
|
|
OPENCLAW_TOOL = "openclaw_tool"
|
|
OPENCLAW_ACTION = "openclaw_action"
|
|
OPENCLAW_ARGS = "openclaw_args"
|
|
OPENCLAW_SESSION_KEY = "openclaw_session_key"
|
|
AGENT_PIPELINE = "agent_pipeline"
|
|
HERMES_MEMORY = "hermes_memory"
|
|
OPENCLAW = "openclaw"
|
|
MODE = "mode"
|
|
USER_PROMPT = "user_prompt"
|
|
REQUEST_CONTEXT = "request_context"
|
|
ASSISTANT_ANSWER = "assistant_answer"
|
|
|
|
|
|
class AIMemoryMode(StrEnum):
|
|
RECALL = "memory_recall"
|
|
WRITE = "memory_write"
|
|
|
|
|
|
class AIHttpPath(StrEnum):
|
|
CHAT_COMPLETIONS = "/chat/completions"
|
|
HEALTH = "/health"
|
|
HEALTHZ = "/healthz"
|
|
READYZ = "/readyz"
|
|
TOOLS_INVOKE = "/tools/invoke"
|
|
V1 = "/v1"
|
|
|
|
|
|
class AIHttpHeader(StrEnum):
|
|
AUTHORIZATION = "Authorization"
|
|
HERMES_SESSION_ID = "X-Hermes-Session-Id"
|
|
|
|
|
|
class AIHttpPayloadKey(StrEnum):
|
|
MODEL = "model"
|
|
MESSAGES = "messages"
|
|
ROLE = "role"
|
|
CONTENT = "content"
|
|
STREAM = "stream"
|
|
TOOL = "tool"
|
|
ACTION = "action"
|
|
ARGS = "args"
|
|
SESSION_KEY = "sessionKey"
|
|
CHOICES = "choices"
|
|
MESSAGE = "message"
|
|
|
|
|
|
class AIChatRole(StrEnum):
|
|
SYSTEM = "system"
|
|
USER = "user"
|
|
|
|
|
|
class AIDefault(StrEnum):
|
|
ACTION_JSON = "json"
|
|
SESSION_KEY_MAIN = "main"
|
|
|
|
|
|
class AIRiskPreference(StrEnum):
|
|
BALANCED = "balanced"
|
|
|
|
|
|
class AIErrorKey(StrEnum):
|
|
OPENCLAW = "openclaw_error"
|
|
HERMES = "hermes_error"
|
|
DIRECT_LLM = "llm_error"
|
|
|
|
|
|
OPENCLAW_HERMES_PIPELINE = (
|
|
"hermes_recall -> openclaw_gateway -> hermes_answer -> hermes_remember"
|
|
)
|
|
COMPANY_MANAGEMENT_SYSTEM_INSTRUCTIONS = (
|
|
"You are a company management AI. Be concise, cite data from context, "
|
|
"and never approve payments, performance changes, or trades automatically."
|
|
)
|
|
CHAT_USER_CONTENT_TEMPLATE = "Context:\n{context}\n\nTask:\n{task}"
|
|
AUTHORIZATION_BEARER_TEMPLATE = "Bearer {token}"
|
|
NOOP_PROVIDER_ANSWER = (
|
|
"AI provider is not configured yet. This is a deterministic placeholder. "
|
|
"Set MODEL_PROVIDER to openclaw_hermes, openclaw, hermes, or direct_llm "
|
|
"after credentials are ready."
|
|
)
|
|
OPENCLAW_TOOL_COMPLETED_ANSWER = "OpenClaw tool invocation completed."
|
|
DIRECT_LLM_API_KEY_MISSING = "DIRECT_LLM_API_KEY is not configured"
|
|
UNEXPECTED_HERMES_RESPONSE = "Unexpected chat completion response"
|