Skip to content

Commit 0dbfcbe

Browse files
authored
multiline code for openai doc (mem0ai#1929)
1 parent 23279d4 commit 0dbfcbe

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

docs/features/openai_compatibility.mdx

+18-10
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,32 @@ client = Mem0(api_key="m0-xxx")
1717

1818
# First interaction: Storing user preferences
1919
messages = [
20-
{
21-
"role": "user",
22-
"content": "I love indian food but I cannot eat pizza since allergic to cheese."
23-
},
20+
{
21+
"role": "user",
22+
"content": "I love indian food but I cannot eat pizza since allergic to cheese."
23+
},
2424
]
2525
user_id = "alice"
26-
chat_completion = client.chat.completions.create(messages=messages, model="gpt-4o-mini", user_id=user_id)
26+
chat_completion = client.chat.completions.create(
27+
messages=messages,
28+
model="gpt-4o-mini",
29+
user_id=user_id
30+
)
2731
# Memory saved after this will look like: "Loves Indian food. Allergic to cheese and cannot eat pizza."
2832

2933
# Second interaction: Leveraging stored memory
3034
messages = [
31-
{
32-
"role": "user",
33-
"content": "Suggest restaurants in San Francisco to eat.",
34-
}
35+
{
36+
"role": "user",
37+
"content": "Suggest restaurants in San Francisco to eat.",
38+
}
3539
]
3640

37-
chat_completion = client.chat.completions.create(messages=messages, model="gpt-4o-mini", user_id=user_id)
41+
chat_completion = client.chat.completions.create(
42+
messages=messages,
43+
model="gpt-4o-mini",
44+
user_id=user_id
45+
)
3846
print(chat_completion.choices[0].message.content)
3947
# Answer: You might enjoy Indian restaurants in San Francisco, such as Amber India, Dosa, or Curry Up Now, which offer delicious options without cheese.
4048
```

0 commit comments

Comments
 (0)