forked from pmekala01/HackUNT2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (20 loc) · 674 Bytes
/
test.py
File metadata and controls
28 lines (20 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import openai
from dotenv import load_dotenv
import os
# Set up your OpenAI API key
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
# Define your query
query = 'What is the capital of France?'
# Make the API request
response = openai.Completion.create(
engine='text-davinci-003', # Specify the language model to use
prompt=query,
max_tokens=100, # Set the maximum length of the response
n=1, # Specify the number of responses to generate
stop=None, # Set any stop conditions for the response generation
)
# Extract the generated response
generated_text = response.choices[0].text.strip()
# Print the generated response
print(generated_text)