-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_roles_sample.py
More file actions
20 lines (18 loc) · 924 Bytes
/
Copy pathchat_roles_sample.py
File metadata and controls
20 lines (18 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
client = OpenAI(api_key="<OPENAI_API_TOKEN>")
response = client.chat.completions.create(
model="gpt-4o-mini",
# Add in the extra examples and responses
messages=[
{"role": "system", "content": "You are a helpful Geography tutor that generates concise summaries for different countries."},
{"role": "user", "content": "Give me a quick summary of Portugal."},
{"role": "assistant", "content": "Portugal is a country in Europe that borders Spain. The capital city is Lisboa."},
{"role": "user", "content": example1},
{"role": "assistant", "content": response1},
{"role": "user", "content": example2},
{"role": "assistant", "content": response2},
{"role": "user", "content": example3},
{"role": "assistant", "content": response3},
{"role": "user", "content": "Give me a quick summary of Greece."}
]
)
print(response.choices[0].message.content)