跳到主要内容

待实现

每日发言记录
  • 通过get_group_member_info来刷新qq最新发言时间的缓存,之后通过get_group_member_list来获取最近发言时间,使用时间戳进行比较
表情包添加文字
async def group_photo(msg: Msg):
script_dir = os.path.dirname(os.path.abspath(__file__))
absolute_path = os.path.join(script_dir, "../resources/1.jpg")
img = Image.open(absolute_path)
new_img = Image.new("RGB", (img.width, img.height), (255, 255, 255))
new_img.paste(img, (0, 0))
draw = ImageDraw.Draw(new_img)
# 选择字体(可以根据需要调整路径和大小)
font = ImageFont.truetype("STXINGKA.TTF", 240)
text = msg.content.replace("我不要看子雨了≧ ﹏ ≦", "").strip()
# 计算文本位置
bbox = draw.textbbox((0, 0), text, font=font)
text_width = bbox[2] - bbox[0]
text_x = (img.width - text_width) // 2
text_y = 100
# 在图片上添加文本
draw.text((text_x, text_y), text, fill="white", font=font)
new_absolute_path = os.path.join(script_dir, "../resources/2.jpg")
new_img.save(new_absolute_path)

msg.content = [{"type": "image", "data": {"file": new_absolute_path}}]
await msg_send(msg)
资讯获取
{
"role": "assistant",
"tool_calls": {
"type": "function",
"function": {"arguments": '{"txt":"abc"}', "name": "get_symbol"},
},
}
{
"content": "用户想要使用尼古拉加密法加密一个字符串'abc'。我需要调用get_symbol工具来加密字符串'abc'。\n\t\n\t调用get_symbol工具来加密字符串'abc'。",
"refusal": None,
"role": "assistant",
"annotations": None,
"audio": None,
"function_call": None,
"tool_calls": [
{
"id": "call_d070ap42c3m19dophv10",
"function": {"arguments": '{"txt":"abc"}', "name": "get_symbol"},
"type": "function",
"index": 0,
}
],
}
{
"content": "\n",
"refusal": None,
"role": "assistant",
"annotations": None,
"audio": None,
"function_call": None,
"tool_calls": [
{
"id": "call_h8fha7mo7xdc44s65y4fit2o",
"function": {"arguments": '{"txt": "abc"}', "name": "get_symbol"},
"type": "function",
}
],
}
{
"role": "assistant",
"content": "",
"tool_calls": [
{
"id": "019677d5f9312482e36d2016f6b5a67e",
"type": "function",
"function": {"name": "get_symbol", "arguments": '{"txt": "abc"}'},
}
],
}
{
"content": None,
"role": "assistant",
"tool_calls": [
{
"id": "call_-8760983896639489558",
"function": {"arguments": '{"txt": "abc"}', "name": "get_symbol"},
"type": "function",
"index": 0,
}
],
}
  • ollama 本地调用
{
"role": "assistant",
"content": "",
"images": None,
"tool_calls": [{"function": {"name": "get_symbol", "arguments": {"txt": "abc"}}}],
}

schema 格式

filesystem中的可选参数是一个文件树 减少幻觉 文本向量化

各平台对于函数调用的支持: openai和claude:支持MCP协议 各平台api:较新的支持MCP协议,免费的api里面只有glm-4-flash ollama:部分标明tools的支持

各平台协议: openai和claude:MCP协议,基于json schema,服务器模式/输入输出流模式,拓展了密钥,类型除了函数之外支持知识库、提示词 各平台api:传入json schema格式的数据 ollama:传入json schema格式的数据,除此之外,支持传入函数,以google tostring格式书写可自动解析

测试: enum:qwen无法读取,glm能读取但还是会传入列表外的参数 format: 两个模型都能获取并且遵守 type:两个模型都能获取并传入符合参数类型的参数 descript:两个模型都能获取并且遵守 max/minLength:qwen无法读取,glm能读取但还是不会按照要求传入

知识库提取(kb)

安装 Tesseract OCR

  • Windows 安装步骤:
  • 下载 Tesseract 安装包(推荐官方发布):
  • 地址:https://github.com/tesseract-ocr/tesseract/releases
  • 下载文件如:tesseract-ocr-w64-setup-5.3.1.20230401.exe
  • 安装时注意勾选 Add to PATH,或者记住安装目录(比如 C:\Program Files\Tesseract-OCR)。
  • 如果你没勾选添加 PATH,需手动添加:
  • 打开「系统环境变量」 → 「系统变量」 → 找到 Path → 编辑 → 添加: C:\Program Files\Tesseract-OCR 安装 poppler-utils
  • pdftotext 是 poppler-utils 包的一部分,因此你需要确保已安装 poppler-utils 或相关工具。
  • Windows 用户可以使用以下方式安装:
  • 访问 poppler for Windows 下载并解压。
  • 将解压后的 bin 目录(包含 pdftotext.exe)添加到系统的 PATH 环境变量中。
  • 检查 pdftotext 是否正确安装:
  • 打开命令提示符或 PowerShell,输入 pdftotext,看看是否能识别并执行该命令。
知识库查询(kb)
  • 不使用 faiss 而使用 sql,每次重复构建 pkl 费时