2025-05-14 16:37:32 +08:00
2024-05-29 20:58:45 +08:00
2025-05-11 20:31:47 +00:00
2025-05-14 16:35:26 +08:00
2025-05-13 11:12:24 +08:00
2025-05-13 11:12:24 +08:00
2024-05-29 20:44:12 +08:00
2025-05-13 11:12:24 +08:00
2025-05-14 16:37:32 +08:00

Lagrange.RagBot

> 简体中文 < | English

结构

每一个服务都放在 ./node 中,根据各自的 readme 分别配置。

你需要准备的环境变量:

export DEEPSEEK_API_TOKEN=xxx
export OMCP_DISCORD_SERVER_IP=xxx
export OMCP_DISCORD_SERVER_PORT=xxx
export OMCP_DISCORD_TOKEN=xxx

架构

graph TB
core(Lagrage.Core)
onebot(Lagrange.onebot)
vecdb(vecdb)
llm(LLM)
intent(intent tree)

core(Lagrange.Core) --> onebot(Lagrange.onebot)

onebot -->|query| intent
intent -->|intent| onebot

subgraph Intent Recognition
    intent -->|query| vecdb
    vecdb -->|ktop| intent
    intent -->|ktop,query| llm
    llm -->|intent| intent
end

subgraph execution
    onebot --> command{intent}
    command --> query
    command --> upload
    command --> ...
end

subgraph third party
LLM
Google
server
end

query --> LLM
query --> Google
upload --> server
  • Lagrange.onebot --> 📁bot
  • vecdb --> 📁rag
  • intent tree --> 📁prompt

接口规范

http 接口满足 HttpResponse 所示。

interface HttpResponse<T> {
    code: number,
    data: CommonResponse<T>
}

interface CommonResponse<T> {
    code: number,
    data?: T,
    msg?: string
}

开发须知

  • 非必要,请不要随意宣传本项目。
  • 虽然曾经无数个 QQ 相关的项目都死了,但是基本的 API 端口算是传承了下来。拉格朗日的返回类型,请参考 go-cqhttp 帮助中心 - API 篇 中的内容。

启动

# 1. 启动 拉格朗日
tsc
pm2 start dist/main.js --name Lagrange.onebot
pm2 start rag/main.py --name rag

测试命令

重训练 embedding -> intent 分类层

curl -X POST http://127.0.0.1:8081/intent/retrain-embedding-mapping

获取意图

curl -X POST -H "Content-Type: application/json" -d '{"query": "真的开线程是要tcl指令去改的"}' http://127.0.0.1:8081/intent/get-intent-recogition

获取向量数据库中的 topk

curl -X POST -H "Content-Type: application/json" -d '{"query": "这个插件有什么比较好的文档吗?"}' http://127.0.0.1:8081/vecdb/similarity_search_with_score
Description
No description provided
Readme Apache-2.0 620 KiB
Languages
Jupyter Notebook 60.3%
Python 16.5%
TypeScript 16.3%
JavaScript 6.9%