🔄 卡若AI 同步 2026-02-25 10:15 | 更新:水桥平台对接、运营中枢、运营中枢工作台 | 排除 >20MB: 13 个
This commit is contained in:
50
02_卡人(水)/水桥_平台对接/飞书管理/脚本/write_today_20260225.py
Normal file
50
02_卡人(水)/水桥_平台对接/飞书管理/脚本/write_today_20260225.py
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
2026-02-25 今日工作写入飞书
|
||||
用法: python3 write_today_20260225.py
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
if SCRIPT_DIR not in sys.path:
|
||||
sys.path.insert(0, SCRIPT_DIR)
|
||||
|
||||
from auto_log import get_token_silent, write_log, open_result
|
||||
|
||||
DATE_STR = "2月25日"
|
||||
TASKS = [
|
||||
{
|
||||
"person": "卡若",
|
||||
"events": ["飞书卡若AI开发", "创业实业小程序对接", "阿猫投资落地"],
|
||||
"quadrant": "重要紧急",
|
||||
"t_targets": [
|
||||
"飞书卡若AI开发→接口完成并部署服务器 🔧 (0%)",
|
||||
"创业实业小程序→完成对接与上线清单 📱 (0%)",
|
||||
"投资落地→与阿猫确定目标与方向 💰 (0%)",
|
||||
],
|
||||
"n_process": [
|
||||
"【飞书卡若AI】接口字段梳理→鉴权与异常处理→本地联调→部署上线→健康检查",
|
||||
"【小程序对接】需求边界确认→参数与回调对齐→待改项整理→提审前检查",
|
||||
"【投资沟通】同步最新机会→确认执行范围→确定收益目标与风险边界",
|
||||
],
|
||||
"t_thoughts": [
|
||||
"先打通接口与部署,再推进业务对接与投资落地",
|
||||
"2月内容固定写入2月日志,避免跨月错写",
|
||||
],
|
||||
"w_work": ["接口开发", "服务器部署", "小程序对接", "投资规划"],
|
||||
"f_feedback": ["三项任务→待执行 ⏰"],
|
||||
},
|
||||
]
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🔑 获取 Token...")
|
||||
token = get_token_silent()
|
||||
if not token:
|
||||
print("❌ 无法获取 Token")
|
||||
sys.exit(1)
|
||||
print("📝 写入飞书日志(2月25日)...")
|
||||
ok = write_log(token, DATE_STR, TASKS)
|
||||
if ok:
|
||||
open_result()
|
||||
sys.exit(0 if ok else 1)
|
||||
@@ -287,6 +287,60 @@ def _messages_to_prompt(messages: List[Dict[str, Any]]) -> str:
|
||||
return (last_user or ("\n".join(chunks))).strip()
|
||||
|
||||
|
||||
def _deep_extract_text(node: Any, out: List[str]) -> None:
|
||||
"""
|
||||
从任意 JSON 结构里尽量提取可读文本。
|
||||
"""
|
||||
if isinstance(node, str):
|
||||
s = node.strip()
|
||||
if s:
|
||||
out.append(s)
|
||||
return
|
||||
if isinstance(node, dict):
|
||||
# 优先常见字段
|
||||
for k in ("text", "input_text", "output_text", "content"):
|
||||
if k in node:
|
||||
_deep_extract_text(node.get(k), out)
|
||||
return
|
||||
if isinstance(node, list):
|
||||
for it in node:
|
||||
_deep_extract_text(it, out)
|
||||
|
||||
|
||||
async def _fallback_prompt_from_request_body(request: Request) -> str:
|
||||
"""
|
||||
当标准 messages 解析失败时,从原始 body 尽力恢复用户文本。
|
||||
"""
|
||||
try:
|
||||
raw = await request.body()
|
||||
if not raw:
|
||||
return ""
|
||||
data = json.loads(raw.decode("utf-8", errors="replace"))
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
texts: List[str] = []
|
||||
|
||||
# 优先取 messages
|
||||
msgs = data.get("messages")
|
||||
if isinstance(msgs, list):
|
||||
_deep_extract_text(msgs, texts)
|
||||
|
||||
# 兼容 responses API 风格 input
|
||||
if not texts:
|
||||
_deep_extract_text(data.get("input"), texts)
|
||||
|
||||
prompt = "\n".join(t for t in texts if t).strip()
|
||||
if prompt:
|
||||
return prompt
|
||||
|
||||
# 只有附件时兜底,避免 empty messages
|
||||
body_str = json.dumps(data, ensure_ascii=False)
|
||||
if any(k in body_str for k in ["image_url", "input_image", "image", "file"]):
|
||||
return "[用户发送了附件,请结合上下文处理]"
|
||||
return ""
|
||||
|
||||
|
||||
def _template_reply(prompt: str, matched_skill: str, skill_path: str, error: str = "") -> str:
|
||||
"""未配置 LLM 或调用失败时返回模板回复(仍含复盘格式)。"""
|
||||
err = f"\n(当前未配置 OPENAI_API_KEY 或调用失败:{error})" if error else ""
|
||||
@@ -451,6 +505,8 @@ async def openai_chat_completions(req: OpenAIChatCompletionsRequest, request: Re
|
||||
tenant_name = str((tenant or {}).get("name", "")).strip()
|
||||
|
||||
prompt = _messages_to_prompt(req.messages)
|
||||
if not prompt:
|
||||
prompt = await _fallback_prompt_from_request_body(request)
|
||||
if not prompt:
|
||||
raise HTTPException(status_code=400, detail="empty messages")
|
||||
|
||||
|
||||
@@ -134,3 +134,4 @@
|
||||
| 2026-02-25 06:51:14 | 🔄 卡若AI 同步 2026-02-25 06:51 | 更新:水桥平台对接、水溪整理归档、总索引与入口、运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 13 个 |
|
||||
| 2026-02-25 09:24:48 | 🔄 卡若AI 同步 2026-02-25 09:24 | 更新:水桥平台对接、总索引与入口、运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 13 个 |
|
||||
| 2026-02-25 09:28:50 | 🔄 卡若AI 同步 2026-02-25 09:28 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 13 个 |
|
||||
| 2026-02-25 09:31:15 | 🔄 卡若AI 同步 2026-02-25 09:31 | 更新:运营中枢、运营中枢工作台 | 排除 >20MB: 13 个 |
|
||||
|
||||
@@ -137,3 +137,4 @@
|
||||
| 2026-02-25 06:51:14 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 06:51 | 更新:水桥平台对接、水溪整理归档、总索引与入口、运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||
| 2026-02-25 09:24:48 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 09:24 | 更新:水桥平台对接、总索引与入口、运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||
| 2026-02-25 09:28:50 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 09:28 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||
| 2026-02-25 09:31:15 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 09:31 | 更新:运营中枢、运营中枢工作台 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||
|
||||
Reference in New Issue
Block a user