2023-05-29 23:25:00 +02:00
|
|
|
import os
|
|
|
|
import openai
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
|
|
api_key = os.getenv('OPENAI_API_KEY')
|
|
|
|
|
|
|
|
openai.api_key = api_key
|
|
|
|
|
2023-05-30 22:36:28 +02:00
|
|
|
# modelos = openai.Model.list()
|
2023-05-29 23:25:00 +02:00
|
|
|
|
2023-05-30 22:36:28 +02:00
|
|
|
# print(modelos)
|
2023-05-29 23:25:00 +02:00
|
|
|
|
2023-05-30 22:36:28 +02:00
|
|
|
modelo = "text-ada-001"
|
|
|
|
prompt = "¿Cuál es la capital de Costa Rica?"
|
|
|
|
|
|
|
|
respuesta = openai.Completion.create(
|
|
|
|
engine=modelo,
|
|
|
|
prompt=prompt,
|
|
|
|
n=1
|
|
|
|
)
|
|
|
|
|
|
|
|
print(respuesta)
|