Update Knowledgebase File
Submit new content for an existing Knowledge Base file to create its next version.
POST
import os
import requests
import json
# Replace with your API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"
# file.content accepts a public URL or a Base64 data URI
data = {
"file_id": "1f35642253606ed1e9dd8cd8113a8998", # Replace with the Knowledge Base file ID
"file": {
"name": "Software_Procurement_Reimbursement_Policy.pdf",
"content": "https://cdn.memtensor.com.cn/file/Software_Procurement_Reimbursement_Policy_v2.pdf"
}
}
headers = {
"Content-Type": "application/json",
"Authorization": f"Token {os.environ['MEMOS_API_KEY']}"
}
url = f"{os.environ['MEMOS_BASE_URL']}/update/knowledgebase-file"
res = requests.post(url=url, headers=headers, data=json.dumps(data))
print(f"result: {res.json()}")
import os
import requests
# Replace with your API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"
file_id = "1f35642253606ed1e9dd8cd8113a8998" # Replace with the Knowledge Base file ID
path = "./Software_Procurement_Reimbursement_Policy_v2.pdf"
headers = {"Authorization": f"Token {os.environ['MEMOS_API_KEY']}"}
url = f"{os.environ['MEMOS_BASE_URL']}/update/knowledgebase-file"
with open(path, "rb") as f:
files = {"file": (os.path.basename(path), f, "application/pdf")}
res = requests.post(url=url, headers=headers, data={"file_id": file_id}, files=files)
print(f"result: {res.json()}")
curl --request POST \
--url https://memos.memtensor.cn/api/openmem/v1/update/knowledgebase-file \
--header 'Authorization: Token YOUR_API_KEY' \
--form 'file_id=1f35642253606ed1e9dd8cd8113a8998' \
--form 'file=@"./Software_Procurement_Reimbursement_Policy_v2.pdf"'
{
"code": 0,
"message": "ok",
"data": {
"file_id": "1f35642253606ed1e9dd8cd8113a8998",
"version": 2,
"current_version": 2,
"version_id": "1958123456789012345",
"task_id": "1958123456789012345",
"status": "PROCESSING"
}
}Authorizations
Authorization
string
header
required
Token API_key, available in API Console > API Keys
Body
application/json
file_id
string
required
ID of the Knowledge Base file to update.
file
object
required
New version of the file.
Show child attributes
Response
application/json
Successful Response
code
number
required
API status code. See Error Code for details.
data
object
Show child attributes
message
string
required
API response message
import os
import requests
import json
# Replace with your API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"
# file.content accepts a public URL or a Base64 data URI
data = {
"file_id": "1f35642253606ed1e9dd8cd8113a8998", # Replace with the Knowledge Base file ID
"file": {
"name": "Software_Procurement_Reimbursement_Policy.pdf",
"content": "https://cdn.memtensor.com.cn/file/Software_Procurement_Reimbursement_Policy_v2.pdf"
}
}
headers = {
"Content-Type": "application/json",
"Authorization": f"Token {os.environ['MEMOS_API_KEY']}"
}
url = f"{os.environ['MEMOS_BASE_URL']}/update/knowledgebase-file"
res = requests.post(url=url, headers=headers, data=json.dumps(data))
print(f"result: {res.json()}")
import os
import requests
# Replace with your API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"
file_id = "1f35642253606ed1e9dd8cd8113a8998" # Replace with the Knowledge Base file ID
path = "./Software_Procurement_Reimbursement_Policy_v2.pdf"
headers = {"Authorization": f"Token {os.environ['MEMOS_API_KEY']}"}
url = f"{os.environ['MEMOS_BASE_URL']}/update/knowledgebase-file"
with open(path, "rb") as f:
files = {"file": (os.path.basename(path), f, "application/pdf")}
res = requests.post(url=url, headers=headers, data={"file_id": file_id}, files=files)
print(f"result: {res.json()}")
curl --request POST \
--url https://memos.memtensor.cn/api/openmem/v1/update/knowledgebase-file \
--header 'Authorization: Token YOUR_API_KEY' \
--form 'file_id=1f35642253606ed1e9dd8cd8113a8998' \
--form 'file=@"./Software_Procurement_Reimbursement_Policy_v2.pdf"'
{
"code": 0,
"message": "ok",
"data": {
"file_id": "1f35642253606ed1e9dd8cd8113a8998",
"version": 2,
"current_version": 2,
"version_id": "1958123456789012345",
"task_id": "1958123456789012345",
"status": "PROCESSING"
}
}