Last active
March 22, 2024 11:55
-
-
Save mouredev/2233398766b3d8803060d0822360273a to your computer and use it in GitHub Desktop.
Ejemplo de uso de ChatGPT desde Python
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
import openai | |
# Tutorial en vídeo: https://youtu.be/1Pl1FWHKHXQ | |
# Genera una API Key desde https://openai.com/api | |
openai.api_key = "TU_API_KEY" | |
while True: | |
prompt = input("\nIntroduce una pregunta: ") | |
if prompt == "exit": | |
break | |
completion = openai.Completion.create(engine="text-davinci-003", | |
prompt=prompt, | |
max_tokens=2048) | |
print(completion.choices[0].text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment