Fix deprecation warning of output_format for ADD and Version Bump (#2216)

This commit is contained in:
Dev Khant
2025-02-18 10:50:56 +05:30
committed by GitHub
parent be46f4eb40
commit 04d7f2e48c
4 changed files with 23 additions and 147 deletions

View File

@@ -95,22 +95,6 @@
],
"operationId": "entities_list",
"parameters": [
{
"name": "org_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter entities by organization name. Will be deprecated soon, use `org_id` instead."
},
{
"name": "project_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter entities by project name. Will be deprecated soon, use `project_id` instead."
},
{
"name": "org_id",
"in": "query",
@@ -699,22 +683,6 @@
},
"description": "Filter memories by categories"
},
{
"name": "org_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter memories by organization name. Will be deprecated soon, use `org_id` instead."
},
{
"name": "project_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter memories by project name. Will be deprecated soon, use `project_id` instead."
},
{
"name": "org_id",
"in": "query",
@@ -978,19 +946,19 @@
},
{
"lang": "cURL",
"source": "curl --request POST \\\n --url https://api.mem0.ai/v1/memories/ \\\n --header 'Authorization: Token <api-key>' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"messages\": [\n {}\n ],\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"app_id\": \"<string>\",\n \"run_id\": \"<string>\",\n \"metadata\": {},\n \"includes\": \"<string>\",\n \"excludes\": \"<string>\",\n \"infer\": true,\n \"custom_categories\": {},\n \"org_name\": \"<string>\",\n \"project_name\": \"<string>\", \n \"org_id\": \"<string>\",\n \"project_id\": \"<string>\"\n}'"
"source": "curl --request POST \\\n --url https://api.mem0.ai/v1/memories/ \\\n --header 'Authorization: Token <api-key>' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"messages\": [\n {}\n ],\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"app_id\": \"<string>\",\n \"run_id\": \"<string>\",\n \"metadata\": {},\n \"includes\": \"<string>\",\n \"excludes\": \"<string>\",\n \"infer\": true,\n \"custom_categories\": {}, \n \"org_id\": \"<string>\",\n \"project_id\": \"<string>\"\n}'"
},
{
"lang": "Go",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v1/memories/\"\n\n\tpayload := strings.NewReader(\"{\n \\\"messages\\\": [\n {}\n ],\n \\\"agent_id\\\": \\\"<string>\\\",\n \\\"user_id\\\": \\\"<string>\\\",\n \\\"app_id\\\": \\\"<string>\\\",\n \\\"run_id\\\": \\\"<string>\\\",\n \\\"metadata\\\": {},\n \\\"includes\\\": \\\"<string>\\\",\n \\\"excludes\\\": \\\"<string>\\\",\n \\\"infer\\\": true,\n \\\"custom_categories\\\": {},\n \\\"org_name\\\": \\\"<string>\\\",\n \\\"project_name\\\": \\\"<string>\\\", \n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\"\n}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v1/memories/\"\n\n\tpayload := strings.NewReader(\"{\n \\\"messages\\\": [\n {}\n ],\n \\\"agent_id\\\": \\\"<string>\\\",\n \\\"user_id\\\": \\\"<string>\\\",\n \\\"app_id\\\": \\\"<string>\\\",\n \\\"run_id\\\": \\\"<string>\\\",\n \\\"metadata\\\": {},\n \\\"includes\\\": \\\"<string>\\\",\n \\\"excludes\\\": \\\"<string>\\\",\n \\\"infer\\\": true,\n \\\"custom_categories\\\": {},\n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\"\n}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "PHP",
"source": "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n CURLOPT_URL => \"https://api.mem0.ai/v1/memories/\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => \"{\n \\\"messages\\\": [\n {}\n ],\n \\\"agent_id\\\": \\\"<string>\\\",\n \\\"user_id\\\": \\\"<string>\\\",\n \\\"app_id\\\": \\\"<string>\\\",\n \\\"run_id\\\": \\\"<string>\\\",\n \\\"metadata\\\": {},\n \\\"includes\\\": \\\"<string>\\\",\n \\\"excludes\\\": \\\"<string>\\\",\n \\\"infer\\\": true,\n \\\"custom_categories\\\": {},\n \\\"org_name\\\": \\\"<string>\\\",\n \\\"project_name\\\": \\\"<string>\\\", \n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\"\n}\",\n CURLOPT_HTTPHEADER => [\n \"Authorization: Token <api-key>\",\n \"Content-Type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}"
"source": "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n CURLOPT_URL => \"https://api.mem0.ai/v1/memories/\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => \"{\n \\\"messages\\\": [\n {}\n ],\n \\\"agent_id\\\": \\\"<string>\\\",\n \\\"user_id\\\": \\\"<string>\\\",\n \\\"app_id\\\": \\\"<string>\\\",\n \\\"run_id\\\": \\\"<string>\\\",\n \\\"metadata\\\": {},\n \\\"includes\\\": \\\"<string>\\\",\n \\\"excludes\\\": \\\"<string>\\\",\n \\\"infer\\\": true,\n \\\"custom_categories\\\": {}, \n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\"\n}\",\n CURLOPT_HTTPHEADER => [\n \"Authorization: Token <api-key>\",\n \"Content-Type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}"
},
{
"lang": "Java",
"source": "HttpResponse<String> response = Unirest.post(\"https://api.mem0.ai/v1/memories/\")\n .header(\"Authorization\", \"Token <api-key>\")\n .header(\"Content-Type\", \"application/json\")\n .body(\"{\n \\\"messages\\\": [\n {}\n ],\n \\\"agent_id\\\": \\\"<string>\\\",\n \\\"user_id\\\": \\\"<string>\\\",\n \\\"app_id\\\": \\\"<string>\\\",\n \\\"run_id\\\": \\\"<string>\\\",\n \\\"metadata\\\": {},\n \\\"includes\\\": \\\"<string>\\\",\n \\\"excludes\\\": \\\"<string>\\\",\n \\\"infer\\\": true,\n \\\"custom_categories\\\": {},\n \\\"org_name\\\": \\\"<string>\\\",\n \\\"project_name\\\": \\\"<string>\\\", \n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\"\n}\")\n .asString();"
"source": "HttpResponse<String> response = Unirest.post(\"https://api.mem0.ai/v1/memories/\")\n .header(\"Authorization\", \"Token <api-key>\")\n .header(\"Content-Type\", \"application/json\")\n .body(\"{\n \\\"messages\\\": [\n {}\n ],\n \\\"agent_id\\\": \\\"<string>\\\",\n \\\"user_id\\\": \\\"<string>\\\",\n \\\"app_id\\\": \\\"<string>\\\",\n \\\"run_id\\\": \\\"<string>\\\",\n \\\"metadata\\\": {},\n \\\"includes\\\": \\\"<string>\\\",\n \\\"excludes\\\": \\\"<string>\\\",\n \\\"infer\\\": true,\n \\\"custom_categories\\\": {}, \n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\"\n}\")\n .asString();"
}
],
"x-codegen-request-body-name": "data"
@@ -1044,22 +1012,6 @@
"style": "deepObject",
"explode": true
},
{
"name": "org_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter memories by organization name. Will be deprecated soon, use `org_id` instead."
},
{
"name": "project_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter memories by project name. Will be deprecated soon, use `project_id` instead."
},
{
"name": "org_id",
"in": "query",
@@ -1165,22 +1117,6 @@
"style": "deepObject",
"explode": true
},
{
"name": "org_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter memories by organization name. Will be deprecated soon, use `org_id` instead."
},
{
"name": "project_name",
"in": "query",
"schema": {
"type": "string"
},
"description": "Filter memories by project name. Will be deprecated soon, use `project_id` instead."
},
{
"name": "org_id",
"in": "query",
@@ -1435,7 +1371,7 @@
},
{
"lang": "cURL",
"source": "curl --request POST \\\n --url https://api.mem0.ai/v1/memories/search/ \\\n --header 'Authorization: Token <api-key>' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"query\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"app_id\": \"<string>\",\n \"run_id\": \"<string>\",\n \"metadata\": {},\n \"top_k\": 123,\n \"fields\": [\n \"<string>\"\n ],\n \"rerank\": true,\n \"org_name\": \"<string>\",\n \"project_name\": \"<string>\", \n \"org_id\": \"<string>\",\n \"project_id\": \"<string>\"\n}'"
"source": "curl --request POST \\\n --url https://api.mem0.ai/v1/memories/search/ \\\n --header 'Authorization: Token <api-key>' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"query\": \"<string>\",\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"app_id\": \"<string>\",\n \"run_id\": \"<string>\",\n \"metadata\": {},\n \"top_k\": 123,\n \"fields\": [\n \"<string>\"\n ],\n \"rerank\": true,\n \"org_id\": \"<string>\",\n \"project_id\": \"<string>\"\n}'"
},
{
"lang": "Go",
@@ -1540,19 +1476,19 @@
},
{
"lang": "cURL",
"source": "curl --request POST \\\n --url https://api.mem0.ai/v2/memories/search/ \\\n --header 'Authorization: Token <api-key>' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"query\": \"<string>\",\n \"filters\": {},\n \"top_k\": 123,\n \"fields\": [\n \"<string>\"\n ],\n \"rerank\": true,\n \"org_name\": \"<string>\",\n \"project_name\": \"<string>\",\n \"org_id\": \"<string>\",\n \"project_id\": \"<string>\"\n}'"
"source": "curl --request POST \\\n --url https://api.mem0.ai/v2/memories/search/ \\\n --header 'Authorization: Token <api-key>' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"query\": \"<string>\",\n \"filters\": {},\n \"top_k\": 123,\n \"fields\": [\n \"<string>\"\n ],\n \"rerank\": true,\n \"org_id\": \"<string>\",\n \"project_id\": \"<string>\"\n}'"
},
{
"lang": "Go",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v2/memories/search/\"\n\n\tpayload := strings.NewReader(\"{\n \\\"query\\\": \\\"<string>\\\",\n \\\"filters\\\": {},\n \\\"top_k\\\": 123,\n \\\"fields\\\": [\n \\\"<string>\\\"\n ],\n \\\"rerank\\\": true,\n \\\"org_name\\\": \\\"<string>\\\",\n \\\"project_name\\\": \\\"<string>\\\",\n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\\\"\n}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://api.mem0.ai/v2/memories/search/\"\n\n\tpayload := strings.NewReader(\"{\n \\\"query\\\": \\\"<string>\\\",\n \\\"filters\\\": {},\n \\\"top_k\\\": 123,\n \\\"fields\\\": [\n \\\"<string>\\\"\n ],\n \\\"rerank\\\": true,\n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\\\"\n}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "PHP",
"source": "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n CURLOPT_URL => \"https://api.mem0.ai/v2/memories/search/\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => \"{\n \\\"query\\\": \\\"<string>\\\",\n \\\"filters\\\": {},\n \\\"top_k\\\": 123,\n \\\"fields\\\": [\n \\\"<string>\\\"\n ],\n \\\"rerank\\\": true,\n \\\"org_name\\\": \\\"<string>\\\",\n \\\"project_name\\\": \\\"<string>\\\",\n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\\\"\n}\",\n CURLOPT_HTTPHEADER => [\n \"Authorization: Token <api-key>\",\n \"Content-Type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}"
"source": "<?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n CURLOPT_URL => \"https://api.mem0.ai/v2/memories/search/\",\n CURLOPT_RETURNTRANSFER => true,\n CURLOPT_ENCODING => \"\",\n CURLOPT_MAXREDIRS => 10,\n CURLOPT_TIMEOUT => 30,\n CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n CURLOPT_CUSTOMREQUEST => \"POST\",\n CURLOPT_POSTFIELDS => \"{\n \\\"query\\\": \\\"<string>\\\",\n \\\"filters\\\": {},\n \\\"top_k\\\": 123,\n \\\"fields\\\": [\n \\\"<string>\\\"\n ],\n \\\"rerank\\\": true,\n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\\\"\n}\",\n CURLOPT_HTTPHEADER => [\n \"Authorization: Token <api-key>\",\n \"Content-Type: application/json\"\n ],\n]);\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\n\ncurl_close($curl);\n\nif ($err) {\n echo \"cURL Error #:\" . $err;\n} else {\n echo $response;\n}"
},
{
"lang": "Java",
"source": "HttpResponse<String> response = Unirest.post(\"https://api.mem0.ai/v2/memories/search/\")\n .header(\"Authorization\", \"Token <api-key>\")\n .header(\"Content-Type\", \"application/json\")\n .body(\"{\n \\\"query\\\": \\\"<string>\\\",\n \\\"filters\\\": {},\n \\\"top_k\\\": 123,\n \\\"fields\\\": [\n \\\"<string>\\\"\n ],\n \\\"rerank\\\": true,\n \\\"org_name\\\": \\\"<string>\\\",\n \\\"project_name\\\": \\\"<string>\\\",\n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\\\"\n}\")\n .asString();"
"source": "HttpResponse<String> response = Unirest.post(\"https://api.mem0.ai/v2/memories/search/\")\n .header(\"Authorization\", \"Token <api-key>\")\n .header(\"Content-Type\", \"application/json\")\n .body(\"{\n \\\"query\\\": \\\"<string>\\\",\n \\\"filters\\\": {},\n \\\"top_k\\\": 123,\n \\\"fields\\\": [\n \\\"<string>\\\"\n ],\n \\\"rerank\\\": true,\n \\\"org_id\\\": \\\"<string>\\\",\n \\\"project_id\\\": \\\"<string>\\\"\n}\")\n .asString();"
}
],
"x-codegen-request-body-name": "data"
@@ -4340,18 +4276,6 @@
},
"nullable": true
},
"org_name": {
"description": "The name of the organization associated with this memory. Will be deprecated soon use `org_id` instead.",
"title": "Organization name",
"type": "string",
"nullable": true
},
"project_name": {
"description": "The name of the project associated with this memory. Will be deprecated soon use project_id instead.",
"title": "Project name",
"type": "string",
"nullable": true
},
"org_id": {
"description": "The unique identifier of the organization associated with this memory.",
"title": "Organization id",
@@ -4443,18 +4367,6 @@
"nullable": true,
"description": "The search method supports two output formats: `v1.0` (default) and `v1.1`."
},
"org_name": {
"title": "Organization Name",
"type": "string",
"nullable": true,
"description": "The name of the organization associated with the memory. Will be deprecated soon use `org_id` instead."
},
"project_name": {
"title": "Project Name",
"type": "string",
"nullable": true,
"description": "The name of the project associated with the memory. Will be deprecated soon use project_id instead."
},
"org_id": {
"title": "Organization id",
"type": "string",
@@ -4568,18 +4480,6 @@
"default": 0.3,
"description": "The minimum similarity threshold for returned results."
},
"org_name": {
"title": "Organization Name",
"type": "string",
"nullable": true,
"description": "The name of the organization associated with the memory. Will be deprecated soon use `org_id` instead."
},
"project_name": {
"title": "Project Name",
"type": "string",
"nullable": true,
"description": "The name of the project associated with the memory. Will be deprecated soon use `project_id` instead."
},
"org_id": {
"title": "Organization id",
"type": "string",

View File

@@ -165,7 +165,7 @@ curl -X POST "https://api.mem0.ai/v1/memories/" \
</CodeGroup>
<Note> The `add` method offers support for two output formats: `v1.0` (default) and `v1.1`. To enable the latest format, which provides enhanced detail for each memory operation, set the `output_format` parameter to `v1.1`. Note that `v1.0` will be deprecated in version `0.1.30`. </Note>
<Note> The `add` method offers support for two output formats: `v1.0` (default) and `v1.1`. To enable the latest format, which provides enhanced detail for each memory operation, set the `output_format` parameter to `v1.1`. </Note>
<Note>
Messages passed along with `user_id`, `run_id`, or `app_id` are stored as user memories, while messages from the assistant are excluded from memory. To store messages for the assistant, use `agent_id` exclusively and avoid including other IDs, such as user_id, alongside it. This ensures the memory is properly attributed to the assistant.

View File

@@ -14,6 +14,8 @@ logger = logging.getLogger(__name__)
# Setup user config
setup_config()
warnings.filterwarnings("default", category=DeprecationWarning)
class APIError(Exception):
"""Exception raised for errors in the API."""
@@ -48,8 +50,6 @@ class MemoryClient:
api_key (str): The API key for authenticating with the Mem0 API.
host (str): The base URL for the Mem0 API.
client (httpx.Client): The HTTP client used for making API requests.
organization (str, optional): (Deprecated) Organization name.
project (str, optional): (Deprecated) Project name.
org_id (str, optional): Organization ID.
project_id (str, optional): Project ID.
user_id (str): Unique identifier for the user.
@@ -59,8 +59,6 @@ class MemoryClient:
self,
api_key: Optional[str] = None,
host: Optional[str] = None,
organization: Optional[str] = None,
project: Optional[str] = None,
org_id: Optional[str] = None,
project_id: Optional[str] = None,
):
@@ -70,8 +68,6 @@ class MemoryClient:
api_key: The API key for authenticating with the Mem0 API. If not provided,
it will attempt to use the MEM0_API_KEY environment variable.
host: The base URL for the Mem0 API. Defaults to "https://api.mem0.ai".
organization: (Deprecated) The name of the organization. Use org_id instead.
project: (Deprecated) The name of the project. Use project_id instead.
org_id: The ID of the organization.
project_id: The ID of the project.
@@ -80,8 +76,6 @@ class MemoryClient:
"""
self.api_key = api_key or os.getenv("MEM0_API_KEY")
self.host = host or "https://api.mem0.ai"
self.organization = organization
self.project = project
self.org_id = org_id
self.project_id = project_id
self.user_id = get_user_id()
@@ -89,14 +83,6 @@ class MemoryClient:
if not self.api_key:
raise ValueError("Mem0 API Key not provided. Please provide an API Key.")
if organization or project:
warnings.warn(
"Using 'organization' and 'project' parameters is deprecated and will be removed in version 0.1.40. "
"Please use 'org_id' and 'project_id' instead.",
DeprecationWarning,
stacklevel=2,
)
self.client = httpx.Client(
base_url=self.host,
headers={"Authorization": f"Token {self.api_key}", "Mem0-User-ID": self.user_id},
@@ -136,6 +122,14 @@ class MemoryClient:
APIError: If the API request fails.
"""
kwargs = self._prepare_params(kwargs)
if kwargs.get("output_format") != "v1.1":
warnings.warn(
"Using default output format 'v1.0' is deprecated and will be removed in version 0.1.70. "
"Please use output_format='v1.1' for enhanced memory details. "
"Check out the docs for more information: https://docs.mem0.ai/platform/quickstart#4-1-create-memories",
DeprecationWarning,
stacklevel=2,
)
payload = self._prepare_payload(messages, kwargs)
response = self.client.post("/v1/memories/", json=payload)
response.raise_for_status()
@@ -556,21 +550,12 @@ class MemoryClient:
A dictionary containing the prepared parameters.
Raises:
ValueError: If both org_id/project_id and org_name/project_name are provided.
ValueError: If either org_id or project_id is provided but not both.
"""
if kwargs is None:
kwargs = {}
has_new = bool(self.org_id or self.project_id)
has_old = bool(self.organization or self.project)
if has_new and has_old:
raise ValueError(
"Please use either org_id/project_id or org_name/project_name, not both. "
"Note that org_name/project_name are deprecated."
)
# Add org_id and project_id if both are available
if self.org_id and self.project_id:
kwargs["org_id"] = self.org_id
@@ -578,13 +563,6 @@ class MemoryClient:
elif self.org_id or self.project_id:
raise ValueError("Please provide both org_id and project_id")
# Add deprecated org_name and project_name if both are available
if self.organization and self.project:
kwargs["org_name"] = self.organization
kwargs["project_name"] = self.project
elif self.organization or self.project:
raise ValueError("Please provide both org_name and project_name")
return {k: v for k, v in kwargs.items() if v is not None}
@@ -603,12 +581,10 @@ class AsyncMemoryClient:
self,
api_key: Optional[str] = None,
host: Optional[str] = None,
organization: Optional[str] = None,
project: Optional[str] = None,
org_id: Optional[str] = None,
project_id: Optional[str] = None,
):
self.sync_client = MemoryClient(api_key, host, organization, project, org_id, project_id)
self.sync_client = MemoryClient(api_key, host, org_id, project_id)
self.async_client = httpx.AsyncClient(
base_url=self.sync_client.host,
headers=self.sync_client.client.headers,

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "mem0ai"
version = "0.1.49"
version = "0.1.50"
description = "Long-term memory for AI Agents"
authors = ["Mem0 <founders@mem0.ai>"]
exclude = [