-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemp.py
More file actions
33 lines (28 loc) · 806 Bytes
/
temp.py
File metadata and controls
33 lines (28 loc) · 806 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
25
26
27
28
29
30
31
32
33
import os
import openai
import secret
openai.api_key=secret.api_key
# CODIO SOLUTION BEGIN
import time
### write your code below
# Start the timer
import time
# Make the API call to generate the completion
# Start the timer
start_time = time.time()
# Make the API call to generate the completion
response=openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What's a good book to read on a rainy day? please just name 2."}
],
n=3
)
# Calculate the elapsed time
elapsed_time = time.time() - start_time
print(f"Elapsed time: {elapsed_time:.4f} seconds")
for i in (response["choices"]):
print(i["message"]['content'].strip())
print(" //////// ")
# CODIO SOLUTION END