Files
company-ai-platform/app/modules/ai_agent/constants.py
JiuContinent d7db84571d ```
feat: 添加飞书用户模块和订阅功能支持

- 新增feishu_users模块用于处理飞书用户身份验证和权限管理
- 新增subscriptions模块用于处理订阅相关功能
- 新增personalization模块用于个性化服务
- 在alembic迁移配置中注册新的模型模块
- 在API路由器中添加feishu_users和subscriptions路由
- 实现事件调度服务的改进,包括错误处理和状态更新优化
- 添加飞书命令处理的权限检查机制
- 实现飞书应用票据事件处理
- 改进审计日志记录功能
```
2026-07-27 08:02:17 +08:00

190 lines
5.3 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"
LOCAL_MEMORY = "local_memory"
MEMORY_WRITE = "memory_write"
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"
LOCAL_MEMORY = "local_memory"
MEMORY_SCOPE = "memory_scope"
MEMORY_SUBJECT = "memory_subject"
OPENCLAW = "openclaw"
MODE = "mode"
USER_PROMPT = "user_prompt"
REQUEST_CONTEXT = "request_context"
ASSISTANT_ANSWER = "assistant_answer"
USER_RULES = "user_rules"
COMPANY_RULES = "company_rules"
PERSONAL_RULES = "personal_rules"
PREFERENCES = "preferences"
INTERESTS = "interests"
CONVERSATION_HISTORY = "conversation_history"
PROVIDER_SESSION_ID = "provider_session_id"
ALLOW_PROVIDER_MEMORY = "allow_provider_memory"
EXECUTION_MODE = "execution_mode"
class AIMemoryMode(StrEnum):
RECALL = "memory_recall"
WRITE = "memory_write"
class AIExecutionMode(StrEnum):
INTERNAL = "internal"
PERSONALIZED = "personalized"
PREFERENCE_EXTRACTION = "preference_extraction"
SCHEDULED_PRIVATE = "scheduled_private"
SCHEDULED_GROUP = "scheduled_group"
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, hermes, or direct_llm after "
"credentials are ready."
)
AI_UNAVAILABLE_ANSWER = "AI 当前不可用,请稍后重试。"
PREFERENCE_EXTRACTION_INSTRUCTIONS = (
"Extract only durable user communication preferences from the supplied user text. "
"Allowed categories are language, tone, detail, topic, and interest. "
"Return strict JSON only in this shape: "
'{"preferences":[{"category":"language","value":"中文"}]}. '
"Return an empty preferences list when there is no durable preference. "
"Never return secrets, credentials, health, religion, politics, sexual orientation, "
"performance, compensation, or confidential financial information."
)
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"
OPENCLAW_CHAT_PROVIDER_REQUIRED = (
"OpenClaw Gateway is not exposed as a tool-execution provider. "
"Use MODEL_PROVIDER=hermes, openclaw_hermes, or direct_llm for AI answers."
)
OPENCLAW_TOOL_NOT_ALLOWED = "OpenClaw tool is not allowed"
OPENCLAW_ACTION_NOT_ALLOWED = "OpenClaw action is not allowed"
UNSUPPORTED_AI_SKILL_TEMPLATE = "Unsupported AI skill: {skill_id}"
AI_AUDIT_REDACTED_VALUE = "[REDACTED]"
AI_AUDIT_TRUNCATED_VALUE = "[TRUNCATED]"
AI_AUDIT_MAX_TEXT_LENGTH = 1000
AI_AUDIT_MAX_SEQUENCE_ITEMS = 20
AI_AUDIT_MAX_DEPTH = 4
AI_AUDIT_SENSITIVE_KEYS = frozenset(
{
"authorization",
"api_key",
"apikey",
"access_token",
"tenant_access_token",
"token",
"secret",
"password",
"openclaw_gateway_token",
"hermes_api_key",
"direct_llm_api_key",
"market_data_token",
}
)