diff --git a/docs/cn/open_source/open_source_api/chat/chat.md b/docs/cn/open_source/open_source_api/chat/chat.md index 990e0f8a7..3d014c611 100644 --- a/docs/cn/open_source/open_source_api/chat/chat.md +++ b/docs/cn/open_source/open_source_api/chat/chat.md @@ -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: diff --git a/docs/cn/open_source/open_source_api/message/feedback.md b/docs/cn/open_source/open_source_api/message/feedback.md index eaa73d72d..e356818d3 100644 --- a/docs/cn/open_source/open_source_api/message/feedback.md +++ b/docs/cn/open_source/open_source_api/message/feedback.md @@ -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}") ``` diff --git a/docs/cn/open_source/open_source_api/message/get_suggestion_queries.md b/docs/cn/open_source/open_source_api/message/get_suggestion_queries.md index 34bcbd1ee..71d26f2c9 100644 --- a/docs/cn/open_source/open_source_api/message/get_suggestion_queries.md +++ b/docs/cn/open_source/open_source_api/message/get_suggestion_queries.md @@ -3,8 +3,6 @@ title: 获取建议问题 (Get Suggestions) desc: 基于当前对话语境或 Cube 内的近期记忆,自动生成 3 条后续对话建议。 --- -# 获取建议问题 (Get Suggestion Queries) - **接口路径**:`POST /product/suggestions` **功能描述**:本接口用于实现“猜你想问”功能。系统会根据提供的对话上下文或目标 **MemCube** 中的近期记忆,通过大语言模型生成 3 个相关的建议问题,帮助用户延续对话。 @@ -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. 使用场景建议 diff --git a/docs/en/open_source/open_source_api/chat/chat.md b/docs/en/open_source/open_source_api/chat/chat.md index 8524106c1..602d8c93e 100644 --- a/docs/en/open_source/open_source_api/chat/chat.md +++ b/docs/en/open_source/open_source_api/chat/chat.md @@ -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: diff --git a/docs/en/open_source/open_source_api/message/feedback.md b/docs/en/open_source/open_source_api/message/feedback.md index 0ce7fb9e3..96d346125 100644 --- a/docs/en/open_source/open_source_api/message/feedback.md +++ b/docs/en/open_source/open_source_api/message/feedback.md @@ -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}") ``` diff --git a/docs/en/open_source/open_source_api/message/get_suggestion_queries.md b/docs/en/open_source/open_source_api/message/get_suggestion_queries.md index 074d35497..2cafab44f 100644 --- a/docs/en/open_source/open_source_api/message/get_suggestion_queries.md +++ b/docs/en/open_source/open_source_api/message/get_suggestion_queries.md @@ -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. @@ -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