Files
company-ai-platform/app/modules/ai_agent/constants.py
JiuContinent 9cf7c44393 ```
feat: 添加生命周期报告和AI规则管理功能

- 在Dockerfile中添加pillow依赖包用于图像处理
- 实现生命周期报告调度任务,支持日报和周报两种类型
- 新增TASK_RUN_LIFECYCLE任务常量和相关配置选项
- 扩展AI Agent服务以支持用户规则,并在分析时应用规则
- 添加AI用户规则创建、更新和查询接口
- 增加项目生命周期和财务需求分析技能
- 扩展现有模型以支持更完整的业务数据字段
- 实现飞书图片上传功能用于报告展示
```
2026-07-12 17:44:49 +08:00

171 lines
4.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"
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 AIToolAuditKey(StrEnum):
TOOL = "tool"
ACTION = "action"
ARGS = "args"
SESSION_KEY = "session_key"
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"
OPENCLAW_CHAT_PROVIDER_REQUIRED = (
"OpenClaw Gateway is not configured as a chat provider. "
"Provide context.openclaw_tool for /tools/invoke, or use "
"MODEL_PROVIDER=hermes/openclaw_hermes 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",
}
)