获取消息
2.12 版本引入
使用此 API 获取对话式搜索的消息信息。
要检索消息信息,您可以
当安全插件启用时,所有内存都以私有
安全模式存在。只有创建内存的用户才能与该内存及其消息进行交互。
按 ID 获取消息
您可以使用 message_id
获取消息信息。
端点
GET /_plugins/_ml/memory/message/<message_id>
路径参数
下表列出了可用的路径参数。
参数 | 数据类型 | 描述 |
---|---|---|
message_id | 字符串 | 要检索的消息 ID。 |
请求示例
GET /_plugins/_ml/memory/message/0m8ya40BfUsSoeNTj-pU
示例响应
{
"memory_id": "gW8Aa40BfUsSoeNTvOKI",
"message_id": "0m8ya40BfUsSoeNTj-pU",
"create_time": "2024-02-02T19:01:32.113621539Z",
"input": null,
"prompt_template": null,
"response": "Hello, this is OpenAI. Here is the answer to your question.",
"origin": null,
"additional_info": {
"suggestion": "api.openai.com"
}
}
有关响应字段的信息,请参阅创建消息请求字段。
获取内存中的所有消息
使用此命令获取某个内存的消息列表。
端点
GET /_plugins/_ml/memory/<memory_id>/messages
路径参数
下表列出了可用的路径参数。
参数 | 数据类型 | 描述 |
---|---|---|
memory_id | 字符串 | 要检索消息的内存 ID。 |
请求示例
GET /_plugins/_ml/memory/gW8Aa40BfUsSoeNTvOKI/messages
POST /_plugins/_ml/message/_search
{
"query": {
"match_all": {}
},
"size": 1000
}
示例响应
{
"messages": [
{
"memory_id": "gW8Aa40BfUsSoeNTvOKI",
"message_id": "BW8ha40BfUsSoeNT8-i3",
"create_time": "2024-02-02T18:43:23.566994302Z",
"input": "How do I make an interaction?",
"prompt_template": "Hello OpenAI, can you answer this question?",
"response": "Hello, this is OpenAI. Here is the answer to your question.",
"origin": "MyFirstOpenAIWrapper",
"additional_info": {
"suggestion": "api.openai.com"
}
},
{
"memory_id": "gW8Aa40BfUsSoeNTvOKI",
"message_id": "0m8ya40BfUsSoeNTj-pU",
"create_time": "2024-02-02T19:01:32.113621539Z",
"input": null,
"prompt_template": null,
"response": "Hello, this is OpenAI. Here is the answer to your question.",
"origin": null,
"additional_info": {
"suggestion": "api.openai.com"
}
}
]
}
响应正文字段
有关响应字段的信息,请参阅创建消息请求字段。