Files
abot/message_summary/message_split.py

40 lines
2.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json
# 模拟返回的API数据
data_string = '''{
"id":"chatcmpl-1739339885",
"object":"chat.completion",
"created":1739339885,
"model":"windsurf",
"choices":[
{
"index":0,
"message":{
"role":"assistant",
"content":"[聊天主题] 婚姻与创业话题讨论 \n☆☆参与者wxid_atv7kzgxv9lg21, wxid_j1f8su26egm222, wxid_nn630aasb1nb22, wxid_q1ugj6gbjj3o12, wxid_ne15uczjd2mi21, wxid_ayf2rispnhwi21 \n时间点2025-02-12 12:59:14 - 2025-02-12 13:56:02 \n内容摘要: 本次聊天涵盖了多个话题包括使用道具、杭州新兴科技公司、医疗手术、杜蕾斯品牌、创业公司、以及婚姻中性行为的问题。wxid_j1f8su26egm222提到杭州出现了新的科技公司而wxid_ayf2rispnhwi21则提出了关于婚姻和性行为的疑问引发了群内的讨论。 \n☑ 点评: 讨论内容较为分散,涉及多个话题。关于杭州科技公司的讨论显示出对当地创业环境的关注,而关于婚姻和性行为的问题则反映了个人生活中的实际困惑。这些话题虽然不直接相关,但都反映了群成员对生活不同方面的关注。 \n· 趣味互动 wxid_ayf2rispnhwi21关于婚姻和性行为的提问引发了群内的笑声和调侃体现了群成员之间轻松的互动氛围。 \n· 待跟进事项 无具体行动项。未来可以考虑深入讨论某一特定话题,如创业或婚姻问题。 \n· 结语 今日的讨论涉及多个生活领域,展现了群成员对不同话题的兴趣和幽默感。期待未来能有更多深入的讨论,鼓励大家继续积极参与。 \n注: 本次讨论话题较为多样,未深入展开某一单一主题。"
},
"finish_reason":"stop"
}
],
"usage":{
"completion_tokens":1024,
"prompt_tokens":0,
"total_tokens":1024
}
}'''
# 解析JSON
def extract_content(data_string):
try:
data = json.loads(data_string)
# 提取content字段
content = data["choices"][0]["message"].get("content", "")
return content
except json.JSONDecodeError:
print("Invalid JSON")
return None
# 获取并打印content内容
content = extract_content(data_string)
print(f"Extracted Content: {content}")