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常量替代硬编码状态值
- 更新审核操作常量引用
```
This commit is contained in:
2026-07-06 00:02:03 +08:00
parent d82116d637
commit aa81fc5321
36 changed files with 2328 additions and 337 deletions

View File

@@ -3,6 +3,8 @@ from functools import lru_cache
from pydantic import Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
DEFAULT_MODEL_PROVIDER = "noop"
class Settings(BaseSettings):
"""Runtime settings loaded from environment variables and `.env`."""
@@ -29,11 +31,16 @@ class Settings(BaseSettings):
feishu_encrypt_key: str | None = None
feishu_default_chat_id: str | None = None
model_provider: str = "noop"
openclaw_base_url: str = "http://127.0.0.1:18789"
model_provider: str = DEFAULT_MODEL_PROVIDER
openclaw_base_url: str = "http://127.0.0.1:2070"
openclaw_http_url: str | None = None
openclaw_ws_url: str | None = None
openclaw_api_key: str | None = None
hermes_base_url: str = "http://127.0.0.1:8080"
openclaw_gateway_token: str | None = None
hermes_base_url: str = "http://127.0.0.1:2073/v1"
hermes_api_key: str | None = None
hermes_model: str = "hermes-agent"
hermes_session_id: str | None = None
direct_llm_base_url: str = "https://api.openai.com/v1"
direct_llm_api_key: str | None = None
direct_llm_model: str = "gpt-4.1-mini"

15
app/core/constants.py Normal file
View File

@@ -0,0 +1,15 @@
from enum import StrEnum
class ActorValue(StrEnum):
API = "api"
SYSTEM = "system"
SCHEDULER = "scheduler"
FEISHU = "feishu"
class HttpHeader(StrEnum):
AUTHORIZATION = "Authorization"
BEARER_TOKEN_TEMPLATE = "Bearer {token}"

View File

@@ -1,6 +1,8 @@
from fastapi import FastAPI
from app.core.constants import ActorValue
from app.core.config import get_settings
from app.modules.feishu.constants import FeishuReceiveIdType
def attach_scheduler(app: FastAPI) -> None:
@@ -30,8 +32,8 @@ def attach_scheduler(app: FastAPI) -> None:
ReportService(db).push_report(
report,
receive_id=settings.feishu_default_chat_id,
receive_id_type="chat_id",
actor="scheduler",
receive_id_type=FeishuReceiveIdType.CHAT_ID,
actor=ActorValue.SCHEDULER,
)
finally:
db.close()
@@ -49,8 +51,8 @@ def attach_scheduler(app: FastAPI) -> None:
ReportService(db).push_report(
report,
receive_id=settings.feishu_default_chat_id,
receive_id_type="chat_id",
actor="scheduler",
receive_id_type=FeishuReceiveIdType.CHAT_ID,
actor=ActorValue.SCHEDULER,
)
finally:
db.close()