Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/cn/open_source/open_source_api/chat/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ client = MemOSClient(api_key="...", base_url="...")
# 发起对话请求
res = client.chat(
user_id="dev_user_01",
conversation_id="conv_r_study_001",
query="根据我之前的偏好,推荐一套 R 语言数据清理方案",
readable_cube_ids=["private_cube_01", "public_kb_r_lang"], # 读:个人偏好+公共库
writable_cube_ids=["private_cube_01"], # 写:沉淀至个人空间
add_message_on_answer=True, # 开启自动记忆回写
mode="fine" # 使用精细检索模式
knowledgebase_ids=["kb_r_lang"], # 检索 R 语言公共知识库
add_message_on_answer=True, # 开启自动记忆回写
temperature=0.7
)

if res:
Expand Down
17 changes: 4 additions & 13 deletions docs/cn/open_source/open_source_api/message/feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,15 @@ from memos.api.client import MemOSClient

client = MemOSClient(api_key="...", base_url="...")

# 场景:修正 AI 关于用户职业的错误记忆
# 场景:修正 AI 关于用户饮食偏好的错误记忆
res = client.add_feedback(
user_id="dev_user_01",
feedback_content="我不再减肥了,现在不需要控制饮食。",
history=[
{"role": "assistant", "content": "您正在减肥中,近期是否控制了摄入食物的热量?"},
{"role": "user", "content": "我不再减肥了..."}
],
writable_cube_ids=["private_cube_01"],
# 指定具体的错误记忆 ID,以实现精准打击
retrieved_memory_ids=["mem_id_old_job_123"],
corrected_answer=True # 要求 AI 重新根据新事实回复我
conversation_id="conv_diet_001",
feedback_content="我不再减肥了,现在不需要控制饮食。"
)

if res and res.code == 200:
print(f"修正进度: {res.message}")
if res.data:
print(f"更正后的回复: {res.data}")
print(f"反馈已提交: {res.message}")
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: 获取建议问题 (Get Suggestions)
desc: 基于当前对话语境或 Cube 内的近期记忆,自动生成 3 条后续对话建议。
---

# 获取建议问题 (Get Suggestion Queries)

**接口路径**:`POST /product/suggestions`
**功能描述**:本接口用于实现“猜你想问”功能。系统会根据提供的对话上下文或目标 **MemCube** 中的近期记忆,通过大语言模型生成 3 个相关的建议问题,帮助用户延续对话。

Expand Down Expand Up @@ -41,27 +39,29 @@ desc: 基于当前对话语境或 Cube 内的近期记忆,自动生成 3 条

## 4. 快速上手示例

使用 SDK 获取针对当前对话的中文建议
使用 HTTP 请求获取针对当前对话的中文建议

```python
from memos.api.client import MemOSClient

client = MemOSClient(api_key="...", base_url="...")

# 场景:根据刚刚关于“R语言”的对话生成建议
res = client.get_suggestions(
user_id="dev_user_01",
mem_cube_id="private_cube_01",
language="zh",
message=[
{"role": "user", "content": "我想学习 R 语言的可视化。"},
{"role": "assistant", "content": "推荐您学习 ggplot2 包,它是 R 语言可视化的核心工具。"}
]
import requests

# 场景:根据刚刚关于”R语言”的对话生成建议
res = requests.post(
“http://localhost:8000/product/suggestions”,
json={
“user_id”: “dev_user_01”,
“mem_cube_id”: “private_cube_01”,
“language”: “zh”,
“message”: [
{“role”: “user”, “content”: “我想学习 R 语言的可视化。”},
{“role”: “assistant”, “content”: “推荐您学习 ggplot2 包,它是 R 语言可视化的核心工具。”}
]
}
)

if res and res.code == 200:
# 示例输出: ["如何安装 ggplot2?", "有哪些经典的 ggplot2 教程?", "R 语言还有哪些可视化包?"]
print(f"建议问题: {res.data}")
if res.status_code == 200:
data = res.json()
# 示例输出: [“如何安装 ggplot2?”, “有哪些经典的 ggplot2 教程?”, “R 语言还有哪些可视化包?”]
print(f”建议问题: {data['data']}”)
```

## 5. 使用场景建议
Expand Down
8 changes: 4 additions & 4 deletions docs/en/open_source/open_source_api/chat/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ client = MemOSClient(api_key="...", base_url="...")
# Initiate a chat request
res = client.chat(
user_id="dev_user_01",
conversation_id="conv_r_study_001",
query="Based on my previous preferences, recommend an R language data cleaning workflow",
readable_cube_ids=["private_cube_01", "public_kb_r_lang"], # Read: personal preferences + public knowledge base
writable_cube_ids=["private_cube_01"], # Write: persist to personal space
add_message_on_answer=True, # Enable automatic memory write-back
mode="fine" # Use fine-grained retrieval mode
knowledgebase_ids=["kb_r_lang"], # Retrieve from the public R language knowledge base
add_message_on_answer=True, # Enable automatic memory write-back
temperature=0.7
)

if res:
Expand Down
17 changes: 4 additions & 13 deletions docs/en/open_source/open_source_api/message/feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,15 @@ from memos.api.client import MemOSClient

client = MemOSClient(api_key="...", base_url="...")

# Scenario: Correct the AI's mistaken memory about the user's occupation
# Scenario: Correct the AI's mistaken memory about the user's diet preference
res = client.add_feedback(
user_id="dev_user_01",
feedback_content="I am no longer on a diet and don't need to control my food intake anymore.",
history=[
{"role": "assistant", "content": "You're on a diet — have you been controlling your calorie intake recently?"},
{"role": "user", "content": "I'm not on a diet anymore..."}
],
writable_cube_ids=["private_cube_01"],
# Specify the exact mistaken memory ID for precise correction
retrieved_memory_ids=["mem_id_old_job_123"],
corrected_answer=True # Ask the AI to respond again based on the updated facts
conversation_id="conv_diet_001",
feedback_content="I am no longer on a diet and don't need to control my food intake anymore."
)

if res and res.code == 200:
print(f"Correction progress: {res.message}")
if res.data:
print(f"Corrected response: {res.data}")
print(f"Feedback submitted: {res.message}")
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: Get Suggestion Queries
desc: Automatically generate 3 follow-up conversation suggestions based on the current dialogue context or recent memories within a Cube.
---

# Get Suggestion Queries

**API Path**: `POST /product/suggestions`
**Description**: This API implements the "Guess What You Want to Ask" feature. Based on the provided conversation context or recent memories in the target **MemCube**, the system uses a large language model to generate 3 relevant suggested questions, helping users continue the conversation.

Expand Down Expand Up @@ -39,27 +37,29 @@ desc: Automatically generate 3 follow-up conversation suggestions based on the c

## 4. Quick Start

Use the SDK to get Chinese-language suggestions for the current conversation:
Use an HTTP request to get Chinese-language suggestions for the current conversation:

```python
from memos.api.client import MemOSClient

client = MemOSClient(api_key="...", base_url="...")
import requests

# Scenario: Generate suggestions based on a recent conversation about "R language"
res = client.get_suggestions(
user_id="dev_user_01",
mem_cube_id="private_cube_01",
language="zh",
message=[
{"role": "user", "content": "I want to learn R language visualization."},
{"role": "assistant", "content": "I recommend learning the ggplot2 package — it's the core tool for R language visualization."}
]
res = requests.post(
"http://localhost:8000/product/suggestions",
json={
"user_id": "dev_user_01",
"mem_cube_id": "private_cube_01",
"language": "zh",
"message": [
{"role": "user", "content": "I want to learn R language visualization."},
{"role": "assistant", "content": "I recommend learning the ggplot2 package — it's the core tool for R language visualization."}
]
}
)

if res and res.code == 200:
if res.status_code == 200:
data = res.json()
# Example output: ["How do I install ggplot2?", "What are some classic ggplot2 tutorials?", "What other visualization packages does R have?"]
print(f"Suggested questions: {res.data}")
print(f"Suggested questions: {data['data']}")
```

## 5. Suggested Use Cases
Expand Down
Loading