-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
794c215
commit 023e71d
Showing
2 changed files
with
34 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from dotenv import load_dotenv | ||
from icecream import ic # noqa: F401 | ||
from openai import OpenAI | ||
|
||
load_dotenv() | ||
|
||
client = OpenAI() | ||
|
||
stream = client.chat.completions.create( | ||
model="gpt-3.5-turbo", | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "Say this is a test, write a 20 word text poem about it.", | ||
} | ||
], | ||
stream=True, | ||
) | ||
ic(stream) | ||
for chunk in stream: | ||
ic(chunk) | ||
if chunk.choices[0].delta.content is not None: | ||
print(chunk.choices[0].delta.content, end="") |