fix: Soulful代码审查修复
严重: - argparse语法错误 (-t,--type 顺序) - main()未定义但被调用 - API变量未定义导致call_llm崩溃 - os_sense中文提取失效(\w不匹配中文) 数据: - 牵挂去重(删除重复条目) - soulful_core.py结构修复 低优先级(记录,不阻塞): - 文件无锁并发写入 - 画像数据未在daemon使用(下次对话我会主动用) - 牵挂识别误报(待持续优化)
This commit is contained in:
parent
4e5ad6218c
commit
d536dca24f
|
|
@ -67,6 +67,8 @@ FAST_MODEL = "stepfun-ai/step-3.5-flash"
|
|||
DEEP_MODEL = "mistralai/mistral-large-3-675b-instruct-2512"
|
||||
FEISHU_WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/446db983-e392-4d2c-bfb8-f9060e5df3ad"
|
||||
|
||||
API = "http://127.0.0.1:3000/v1" # NewAPI gateway
|
||||
|
||||
_stop_event = threading.Event()
|
||||
|
||||
# Lazy-loaded soulful modules (avoid import at module load time)
|
||||
|
|
|
|||
|
|
@ -73,10 +73,12 @@ def get_journal_keywords(n=50):
|
|||
try:
|
||||
entry = json.loads(line)
|
||||
text = entry.get("summary", "") + " " + entry.get("action_taken", "")
|
||||
# 简单分词
|
||||
# 简单分词(英文)+ 中文词提取(\w 不匹配中文)
|
||||
tokens = re.findall(r'[\w]{2,}', text.lower())
|
||||
chinese_words = re.findall(r'[\u4e00-\u9fff]{2,}', text)
|
||||
tokens = [t for t in tokens if t not in STOPWORDS and len(t) > 1]
|
||||
words.extend(tokens)
|
||||
chinese_words = [w for w in chinese_words if w not in STOPWORDS]
|
||||
words.extend(tokens + chinese_words)
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ if __name__ == "__main__":
|
|||
p = argparse.ArgumentParser(description="心迹记录")
|
||||
p.add_argument("content")
|
||||
p.add_argument("--tags", nargs="+", default=[])
|
||||
p.add_argument("--type", "-t", default="moment", choices=["moment", "signal", "reflection"])
|
||||
p.add_argument("-t", "--type", default="moment", choices=["moment", "signal", "reflection"])
|
||||
p.add_argument("--importance", "-i", type=int, default=3)
|
||||
args = p.parse_args(sys.argv[2:])
|
||||
ht = HeartTraces()
|
||||
|
|
@ -396,12 +396,12 @@ if __name__ == "__main__":
|
|||
"cq-list": cmd_cq_list,
|
||||
}
|
||||
|
||||
if len(sys.argv) < 2 or sys.argv[1] not in commands:
|
||||
print("用法: soulful_core.py <command> [args]")
|
||||
print("命令:", list(commands.keys()))
|
||||
sys.exit(1)
|
||||
|
||||
commands[sys.argv[1]]()
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2 or sys.argv[1] not in commands:
|
||||
print("用法: soulful_core.py <command> [args]")
|
||||
print("命令:", list(commands.keys()))
|
||||
sys.exit(1)
|
||||
commands[sys.argv[1]]()
|
||||
|
||||
|
||||
# ====== 会话接口:供小唯在对话中调用 ======
|
||||
|
|
@ -442,8 +442,4 @@ def summarize():
|
|||
for c in cares_pending[:3]:
|
||||
lines.append(f" → {c['content'][:50]}")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
return "\n".join(lines)
|
||||
|
|
@ -1,16 +1,5 @@
|
|||
{
|
||||
"cares": [
|
||||
{
|
||||
"id": "41280638",
|
||||
"content": "记得同步文档到Obsidian",
|
||||
"context": "牧尘提到",
|
||||
"created_at": "2026-07-09T09:50:58.779920+00:00",
|
||||
"follow_up_date": "2026-07-10",
|
||||
"status": "pending",
|
||||
"reminder_count": 0,
|
||||
"last_reminded": null,
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
"id": "5a1465eb",
|
||||
"content": "记得测试牵挂功能",
|
||||
|
|
@ -18,8 +7,8 @@
|
|||
"created_at": "2026-07-09T09:51:04.369800+00:00",
|
||||
"follow_up_date": "2026-07-09",
|
||||
"status": "pending",
|
||||
"reminder_count": 2,
|
||||
"last_reminded": "2026-07-09T14:55:05.935006+00:00",
|
||||
"reminder_count": 4,
|
||||
"last_reminded": "2026-07-09T17:01:01.292270+00:00",
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
|
|
@ -34,5 +23,5 @@
|
|||
"tags": []
|
||||
}
|
||||
],
|
||||
"updated_at": "2026-07-09T14:55:05.935055+00:00"
|
||||
"updated_at": "2026-07-09T17:01:01.292324+00:00"
|
||||
}
|
||||
|
|
@ -1,2 +1 @@
|
|||
{"id": "eabf352f", "timestamp": "2026-07-09T09:50:50.730036+00:00", "session_id": "default", "type": "moment", "content": "我们一起修好了织忆", "tags": ["成长"], "importance": 5}
|
||||
{"id": "d945a6aa", "timestamp": "2026-07-09T13:29:22.581218+00:00", "session_id": "default", "type": "moment", "content": "我们一起修好了织忆", "tags": ["成长", "织忆"], "importance": 5}
|
||||
|
|
|
|||
Loading…
Reference in New Issue