项目已标记 DEPRECATED,官方不再维护支持;必须提供 REDIS_URL,且长期记忆需开启 MOTORHEAD_LONG_TERM_MEMORY 并依赖 Redisearch VSS;摘要依赖 OPENAI_API_KEY,模型建议只用 gpt-3.5-turbo 或 gpt-4;README 中 PORT 默认值写 8000,但示例用 8080,需自行对齐端口
docker-compose build && docker-compose up
docker run --name motorhead -p 8080:8080 -e PORT=8080 -e REDIS_URL='redis://redis:6379' -d ghcr.io/getmetal/motorhead:latestREADME 未说明硬件要求,仅需能运行 Docker 并连接 Redis 的环境
给 LLM 聊天应用提供会话记忆与检索的服务器,省去每次自己实现记忆管理
给 LLM 应用提供记忆与信息检索能力的服务端,用 Rust 实现,帮你在对话中持久化上下文并做检索,省去自己搭记忆层。
核心能力
- 用 GET/POST/DELETE /sessions/:id/memory 管理会话消息
- 窗口满后自动把一半消息增量摘要压缩上下文
- 用 Redisearch VSS 按文本查询做会话内检索
- 会话不存在时自动创建,检索自动按 session 过滤
- 支持通过 context 字段从其他存储加载上下文
容易踩的坑
- v3.0.2最新正式版2023-12-19 · 2023-12-19 03:18 UTC
What's Changed
- Bump aiohttp from 3.8.5 to 3.8.6 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/99
- Bump langchain from 0.0.325 to 0.0.329 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/96
- Bump aiohttp from 3.8.6 to 3.9.0 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/101
- Add
OPENAI_API_BASEconfig by @Czechh in https://github.com/getmetal/motorhead/pull/104
Full Changelog: https://github.com/getmetal/motorhead/compare/v3.0.1...v3.0.2
- v3.0.12023-11-14 · 2023-11-14 14:47 UTC
查看更新说明
What's Changed
- Fix readme by @Czechh in https://github.com/getmetal/motorhead/pull/98
Full Changelog: https://github.com/getmetal/motorhead/compare/v3.0.0...v3.0.1
- v3.0.1rc12023-11-14 · 2023-11-14 14:44 UTC
查看更新说明
What's Changed
- Fix readme by @Czechh in https://github.com/getmetal/motorhead/pull/98
Full Changelog: https://github.com/getmetal/motorhead/compare/v3.0.0...v3.0.1rc1
- v3.0.02023-11-14 · 2023-11-14 14:15 UTC
查看更新说明
Breaking change
sessionchanged fromTEXTtoTAG. This will change how data is indexed in Redisearch.
** If you have data already indexed, you can reindex it by dropping the index and restarting the server.
FT.DROPINDEX motorhead. Do NOT use the DD option to keep the data and reindex it once the server restarts**What's Changed
- Move
apt-getto top of Dockerfile for better caching by @jacobwgillespie in https://github.com/getmetal/motorhead/pull/76 - Correct a typo in chat-vanilla-js-hosted/README.md by @felixonmars in https://github.com/getmetal/motorhead/pull/80
- Bump urllib3 from 1.26.15 to 1.26.17 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/81
- Configure Sweep by @sweep-ai in https://github.com/getmetal/motorhead/pull/84
- Bump urllib3 from 1.26.17 to 1.26.18 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/88
- Bump zod from 3.21.4 to 3.22.4 in /examples/chat-js by @dependabot in https://github.com/getmetal/motorhead/pull/89
- Bump certifi from 2022.12.7 to 2023.7.22 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/66
- Bump rustls-webpki from 0.100.1 to 0.100.2 by @dependabot in https://github.com/getmetal/motorhead/pull/70
- Bump langchain from 0.0.152 to 0.0.312 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/87
- update packages by @softboyjimbo in https://github.com/getmetal/motorhead/pull/90
- Bump langchain from 0.0.312 to 0.0.325 in /examples/chat-py by @dependabot in https://github.com/getmetal/motorhead/pull/92
- Bump axios and openai in /examples/chat-vanilla-js by @dependabot in https://github.com/getmetal/motorhead/pull/94
- Bump axios and openai in /examples/chat-vanilla-js-hosted by @dependabot in https://github.com/getmetal/motorhead/pull/95
- Bump axios and langchain in /examples/chat-js by @dependabot in https://github.com/getmetal/motorhead/pull/93
- Handle azure long term memory + session tag fix by @Czechh in https://github.com/getmetal/motorhead/pull/97
New Contributors
- @jacobwgillespie made their first contribution in https://github.com/getmetal/motorhead/pull/76
- @felixonmars made their first contribution in https://github.com/getmetal/motorhead/pull/80
- @sweep-ai made their first contribution in https://github.com/getmetal/motorhead/pull/84
Full Changelog: https://github.com/getmetal/motorhead/compare/v2.0.4...v3.0.0
- v2.0.4rc32023-08-23 · 2023-08-23 21:03 UTC
查看更新说明
What's Changed
- Try depot for builds by @Czechh in https://github.com/getmetal/motorhead/pull/75
Full Changelog: https://github.com/getmetal/motorhead/compare/v2.0.4rc2...v2.0.4rc3
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Motorhead is a memory and information retrieval server for LLMs.
Why use Motorhead?
When building chat applications using LLMs, memory handling is something that has to be built every time. Motorhead is a server to assist with that process. It provides 3 simple APIs:
- GET
/sessions/:id/memoryreturns messages up toMAX_WINDOW_SIZE.
{
"messages": [
{
"role": "AI",
"content": "Electronic music and salsa are two very different genres of music, and the way people dance to them is also quite different."
},
{
"role": "Human",
"content": "how does it compare to salsa?"
},
{
"role": "AI",
"content": "Electronic music is a broad genre that encompasses many different styles, so there is no one \"right\" way to dance to it."
},
{
"role": "Human",
"content": "how do you dance electronic music?"
},
{
"role": "AI",
"content": "Colombia has a vibrant electronic music scene, and there are many talented DJs and producers who have gained international recognition."
},
{
"role": "Human",
"content": "What are some famous djs from Colombia?"
},
{
"role": "AI",
"content": "Baum opened its doors in 2014 and has quickly become one of the most popular clubs for electronic music in Bogotá."
}
],
"context": "The conversation covers topics such as clubs for electronic music in Bogotá, popular tourist attractions in the city, and general information about Colombia. The AI provides information about popular electronic music clubs such as Baum and Video Club, as well as electronic music festivals that take place in Bogotá. The AI also recommends tourist attractions such as La Candelaria, Monserrate and the Salt Cathedral of Zipaquirá, and provides general information about Colombia's diverse culture, landscape and wildlife.",
"tokens": 744 // tokens used for incremental summarization
}
- POST
/sessions/:id/memory- Send an array of messages to Motorhead to store.
curl --location 'localhost:8080/sessions/${SESSION_ID}/memory' \
--header 'Content-Type: application/json' \
--data '{
"messages": [{ "role": "Human", "content": "ping" }, { "role": "AI", "content": "pong" }]
}'
Either an existing or new SESSION_ID can be used when storing messages, and the session is automatically created if it did not previously exist.
Optionally, context can be send in if it needs to get loaded from another datastore.
- DELETE
/sessions/:id/memory- deletes the session's message list.
A max window_size is set for the LLM to keep track of the conversation. Once that max is hit, Motorhead will process (window_size / 2 messages) and summarize them. Subsequent summaries, as the messages grow, are incremental.
- POST
/sessions/:id/retrieval- searches by text query using VSS.
curl --location 'localhost:8080/sessions/${SESSION_ID}/retrieval' \
--header 'Content-Type: application/json' \
--data '{
"text": "Generals gathered in their masses, just like witches in black masses"
}'
Searches are segmented (filtered) by the session id provided automatically.
Config
MOTORHEAD_MAX_WINDOW_SIZE(default:12) - Number of max messages returned by the server. When this number is reached, a job is triggered to halve it.MOTORHEAD_LONG_TERM_MEMORY(default:false) - Enables long term memory using Redisearch VSS.MOTORHEAD_MODEL(default:gpt-3.5-turbo) - Model used to run the incremental summarization. Usegpt-3.5-turboorgpt-4- otherwise some weird things might happen.PORT(default:8000) - Motorhead Server PortOPENAI_API_KEY- Your api key to connect to OpenAI.REDIS_URL(required)- URL used to connect toredis.OPENAI_API_BASE(default:https://api.openai.com/v1) - OpenAI API Base URL
Azure deployment
Additional Environment Variables are required for Azure deployments:
AZURE_DEPLOYMENT_IDAZURE_DEPLOYMENT_ID_ADAAZURE_API_BASEAZURE_API_KEY
How to run
With docker-compose:
docker-compose build && docker-compose up
Or you can use the image docker pull ghcr.io/getmetal/motorhead:latest directly:
docker run --name motorhead -p 8080:8080 -e PORT=8080 -e REDIS_URL='redis://redis:6379' -d ghcr.io/getmetal/motorhead:latest