multiline code for openai doc (#1929)

This commit is contained in:
Dev Khant
2024-09-30 23:21:32 +05:30
committed by GitHub
parent 23279d4248
commit 0dbfcbe6d9

View File

@@ -23,7 +23,11 @@ messages = [
}, },
] ]
user_id = "alice" 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." # Memory saved after this will look like: "Loves Indian food. Allergic to cheese and cannot eat pizza."
# Second interaction: Leveraging stored memory # Second interaction: Leveraging stored memory
@@ -34,7 +38,11 @@ messages = [
} }
] ]
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) 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. # Answer: You might enjoy Indian restaurants in San Francisco, such as Amber India, Dosa, or Curry Up Now, which offer delicious options without cheese.
``` ```