mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-19 03:00:09 +08:00
✨ feat(llm): 新增LLM模型管理插件并增强API密钥管理 (#1972)
🔧 新增功能: - LLM模型管理插件 (builtin_plugins/llm_manager/) • llm list - 查看可用模型列表 (图片格式) • llm info - 查看模型详细信息 (Markdown图片) • llm default - 管理全局默认模型 • llm test - 测试模型连通性 • llm keys - 查看API Key状态 (表格图片,含健康度/成功率/延迟) • llm reset-key - 重置API Key失败状态 🏗️ 架构重构: - 会话管理: AI/AIConfig 类迁移至独立的 session.py - 类型定义: TaskType 枚举移至 types/enums.py - API增强: • chat() 函数返回完整 LLMResponse,支持工具调用 • 新增 generate() 函数用于一次性响应生成 • 统一API调用核心方法 _perform_api_call,返回使用的API密钥 🚀 密钥管理增强: - 详细状态跟踪: 健康度、成功率、平均延迟、错误信息、建议操作 - 状态持久化: 启动时加载,关闭时自动保存密钥状态 - 智能冷却策略: 根据错误类型设置不同冷却时间 - 延迟监控: with_smart_retry 记录API调用延迟并更新统计 Co-authored-by: webjoin111 <455457521@qq.com> Co-authored-by: HibiKier <45528451+HibiKier@users.noreply.github.com>
This commit is contained in:
co-authored by
webjoin111
HibiKier
parent
8649aaaa54
commit
46a0768a45
@@ -198,7 +198,7 @@ print(search_result['text'])
|
||||
当你需要进行有上下文的、连续的对话时,`AI` 类是你的最佳选择。
|
||||
|
||||
```python
|
||||
from zhenxun.services.llm.api import AI, AIConfig
|
||||
from zhenxun.services.llm import AI, AIConfig
|
||||
|
||||
# 初始化一个AI会话,可以传入自定义配置
|
||||
ai_config = AIConfig(model="GLM/glm-4-flash", temperature=0.7)
|
||||
@@ -395,7 +395,7 @@ async def my_tool_factory(config: MyToolConfig):
|
||||
在 `analyze` 或 `generate_response` 中使用 `use_tools` 参数。框架会自动处理整个调用流程。
|
||||
|
||||
```python
|
||||
from zhenxun.services.llm.api import analyze
|
||||
from zhenxun.services.llm import analyze
|
||||
from nonebot_plugin_alconna.uniseg import UniMessage
|
||||
|
||||
response = await analyze(
|
||||
@@ -442,7 +442,6 @@ from zhenxun.services.llm.manager import (
|
||||
get_key_usage_stats,
|
||||
reset_key_status
|
||||
)
|
||||
from zhenxun.services.llm import clear_model_cache, get_cache_stats
|
||||
|
||||
# 列出所有在config.yaml中配置的可用模型
|
||||
models = list_available_models()
|
||||
|
||||
Reference in New Issue
Block a user