Skip to content

Commit

Permalink
multiline code for openai doc (#1929)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-Khant authored Sep 30, 2024
1 parent 23279d4 commit 0dbfcbe
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions docs/features/openai_compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,32 @@ client = Mem0(api_key="m0-xxx")

# First interaction: Storing user preferences
messages = [
{
"role": "user",
"content": "I love indian food but I cannot eat pizza since allergic to cheese."
},
{
"role": "user",
"content": "I love indian food but I cannot eat pizza since allergic to cheese."
},
]
user_id = "alice"
chat_completion = client.chat.completions.create(messages=messages, model="gpt-4o-mini", user_id=user_id)
chat_completion = client.chat.completions.create(
messages=messages,
model="gpt-4o-mini",
user_id=user_id
)
# Memory saved after this will look like: "Loves Indian food. Allergic to cheese and cannot eat pizza."

# Second interaction: Leveraging stored memory
messages = [
{
"role": "user",
"content": "Suggest restaurants in San Francisco to eat.",
}
{
"role": "user",
"content": "Suggest restaurants in San Francisco to eat.",
}
]

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

0 comments on commit 0dbfcbe

Please sign in to comment.