無(wú)錫知名網(wǎng)站制作求職seo
LLMs 的記憶和信息檢索服務(wù)器 Motorhead
- 1. 為什么使用 Motorhead?
- 2. 通過(guò) Docker 啟動(dòng) Motorhead
- 3. Github 地址
- 4. python 使用示例地址
1. 為什么使用 Motorhead?
使用 LLMs構(gòu)建聊天應(yīng)用程序時(shí),每次都必須構(gòu)建記憶處理。Motorhead是協(xié)助該過(guò)程的服務(wù)器。
它提供了 4 個(gè)簡(jiǎn)單的 API:
- GET
/sessions/:id/memory
返回最多MAX_WINDOW_SIZE
的 messages
{"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
- 向 Motorhead 發(fā)送數(shù)組 messages 進(jìn)行存儲(chǔ)
curl --location 'localhost:8080/sessions/${SESSION_ID}/memory' \
--header 'Content-Type: application/json' \
--data '{"messages": [{ "role": "Human", "content": "ping" }, { "role": "AI", "content": "pong" }]
}'
存儲(chǔ)消息時(shí),可以使用現(xiàn)有會(huì)話或新 SESSION_ID
會(huì)話,如果會(huì)話以前不存在,則會(huì)自動(dòng)創(chuàng)建會(huì)話。
(可選) context
如果需要從其他數(shù)據(jù)存儲(chǔ)加載,則可以將其送入。
- DELETE
/sessions/:id/memory
- 刪除會(huì)話的消息列表。
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.
為跟蹤對(duì)話設(shè)置了 LLM 最大值 window_size
。一旦達(dá)到最大值,Motorhead 將處理( window_size / 2
messages)并匯總它們。隨著消息的增長(zhǎng),后續(xù)摘要是增量的。
- POST
/sessions/:id/retrieval
- 使用 VSS 按文本查詢進(jìn)行搜索
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"
}'
2. 通過(guò) Docker 啟動(dòng) Motorhead
docker run --rm --name some-redis -p 6379:6379 -d redis
docker run --rm --name motorhead -p 8080:8080 -e PORT=8080 -e REDIS_URL='redis://some-redis:6379' -d ghcr.io/getmetal/motorhead:latest
3. Github 地址
https://github.com/getmetal/motorhead
4. python 使用示例地址
https://github.com/getmetal/motorhead/tree/main/examples/chat-py
p.s. 暫時(shí)使用的可能性不大,所以先不做深入研究。
完結(jié)!