gpt4free/example_gpt-3.5-turbo.py

13 行
453 B
Python
Raw パーマリンク 通常表示 履歴

2023-06-06 17:46:22 +09:00
import g4f
import sys
# Automatic selection of provider, streamed completion
response = g4f.ChatCompletion.create(model='gpt-3.5-turbo',
messages=[{"role": "user",
2023-06-06 18:16:23 +09:00
"content": "Write a poem about a tree."}],
2023-06-06 17:46:22 +09:00
stream=True)
for message in response:
print(message, end="")
sys.stdout.flush()