fix hotbug🚀

This commit is contained in:
cvcat
2025-04-21 14:41:16 +08:00
parent df07e54cd8
commit 50097d1924
2 changed files with 11 additions and 8 deletions

View File

@ -66,16 +66,13 @@ Lark MCP是一个现代化的Python应用程序,能够:
|-------|------| |-------|------|
| `tell_joke` | 讲一个随机笑话 | | `tell_joke` | 讲一个随机笑话 |
| `get_time` | 获取当前时间 | | `get_time` | 获取当前时间 |
| `roll_dice` | 掷一个指定面数的骰子 |
| `make_todo_list` | 从逗号分隔的任务创建待办清单 |
| `translate_to_chinese` | 将英文单词翻译成中文 |
| `countdown` | 创建一个从指定数字开始的倒计时 |
| `random_color` | 生成一个随机的十六进制颜色代码 |
| `fortune` | 抽取一个随机运势 | | `fortune` | 抽取一个随机运势 |
| `get_weather` | 获取城市天气 |
| `count_daily_speakers` | 获取今天发言的人数统计 | | `count_daily_speakers` | 获取今天发言的人数统计 |
| `get_top_speaker_today` | 获取今天发言最多的用户 | | `get_top_speaker_today` | 获取今天发言最多的用户 |
| `send_message` | 给指定用户发送消息 | | `send_message` | 给指定用户发送消息 |
| `list_tools` | 列出所有可用的工具及其描述 | | `list_tools` | 列出所有可用的工具及其描述 |
| `extra_order_from_content` | 提取文字中的订单信息,包括订单号、商品名称、数量等 |
你可以通过在飞书中输入触发指令后跟要执行的操作来调用这些功能,例如: `/run 讲个笑话` 你可以通过在飞书中输入触发指令后跟要执行的操作来调用这些功能,例如: `/run 讲个笑话`
@ -91,19 +88,24 @@ project/
│ ├── config/ # 配置模块 │ ├── config/ # 配置模块
│ │ └── settings.py # 应用配置 │ │ └── settings.py # 应用配置
│ ├── core/ # 核心业务逻辑 │ ├── core/ # 核心业务逻辑
│ │ ├── mcp_server.py # MCP服务器 │ │ ├── mcp_server.py # MCP服务器(函数注册和处理)
│ │ ├── llm_service.py # LLM服务
│ │ └── message_service.py # 消息处理服务 │ │ └── message_service.py # 消息处理服务
│ ├── db/ # 数据库相关 │ ├── db/ # 数据库相关
│ │ ├── models.py # 数据模型 │ │ ├── models.py # 数据模型
│ │ └── session.py # 数据库会话管理 │ │ └── session.py # 数据库会话管理
│ └── utils/ # 工具函数 │ └── utils/ # 工具函数
├── builder/ # 请求构建器 ├── builder/ # 请求构建器
├── extension/ # 扩展功能
│ └── weather_api/ # 天气API集成
├── static/ # 静态资源 ├── static/ # 静态资源
│ ├── resource/ # 图片资源 │ ├── resource/ # 图片资源
│ ├── proto_pb2.py # 协议定义 │ ├── proto_pb2.py # 协议定义
│ └── lark_decrypt.js # 飞书解密工具 │ └── lark_decrypt.js # 飞书解密工具
├── .env # 环境变量 ├── .env # 环境变量
├── main.py # 应用入口 ├── main.py # 应用入口
├── requirements.txt # 项目依赖
├── docker-compose.yml # Docker Compose配置
└── Dockerfile # Docker配置 └── Dockerfile # Docker配置
``` ```

View File

@ -55,7 +55,7 @@ class MessageService:
logger.info(f"触发flag函数调用 - 用户: {user_name}, 内容: {content}") logger.info(f"触发flag函数调用 - 用户: {user_name}, 内容: {content}")
query = content.strip()[len(settings.FUNCTION_TRIGGER_FLAG):].strip() query = content.strip()[len(settings.FUNCTION_TRIGGER_FLAG):].strip()
if not self.llm_service.is_available(): if not self.llm_service.is_available():
error_msg = "未在配置中设置 OPENAI_API_KEY" error_msg = settings.AI_BOT_PREFIX + " 未在配置中设置 OPENAI_API_KEY"
logger.error(error_msg) logger.error(error_msg)
self.lark_client.send_msg(error_msg, chat_id) self.lark_client.send_msg(error_msg, chat_id)
return return
@ -94,10 +94,11 @@ class MessageService:
response = summary.choices[0].message.content response = summary.choices[0].message.content
else: else:
response = msg.content response = msg.content
response = f'{settings.AI_BOT_PREFIX} {response}'
self.lark_client.send_msg(response, chat_id) self.lark_client.send_msg(response, chat_id)
except Exception as e: except Exception as e:
logger.error(f"处理flag函数调用时出错: {str(e)}") logger.error(f"处理flag函数调用时出错: {str(e)}")
error_msg = f"执行错误: {str(e)}" error_msg = f"{settings.AI_BOT_PREFIX} 处理请求时出错: {str(e)}"
try: try:
self.lark_client.send_msg(error_msg, chat_id) self.lark_client.send_msg(error_msg, chat_id)
except Exception as send_err: except Exception as send_err: