Skip to content

Commit add6676

Browse files
authored
Add files via upload
1 parent c7e4c72 commit add6676

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

chap02/03/main.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from openai import OpenAI
2+
3+
client = OpenAI()
4+
5+
completion = client.chat.completions.create(
6+
model="gpt-4o-mini",
7+
messages=[
8+
{"role": "system", "content": "You are a helpful assistant."},
9+
{
10+
"role": "user",
11+
"content": "Write a haiku about recursion in programming."
12+
}
13+
]
14+
)
15+
# Returns a chat completion object
16+
print(completion)
17+
print(completion.choices[0].message)

0 commit comments

Comments
 (0)