Spaces:
Sleeping
Sleeping
Update
Browse files
app.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1 |
import openai
|
2 |
import os
|
|
|
3 |
|
4 |
-
#
|
|
|
|
|
|
|
5 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
6 |
|
7 |
def generate_text(prompt):
|
8 |
response = openai.ChatCompletion.create(
|
9 |
-
model="gpt-3.5-turbo",
|
10 |
messages=[
|
11 |
{"role": "system", "content": "You are a helpful assistant."},
|
12 |
{"role": "user", "content": prompt},
|
|
|
1 |
import openai
|
2 |
import os
|
3 |
+
from dotenv import load_dotenv
|
4 |
|
5 |
+
# Load environment variables from .env file
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
# Set the OpenAI API key from environment variable
|
9 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
10 |
|
11 |
def generate_text(prompt):
|
12 |
response = openai.ChatCompletion.create(
|
13 |
+
model="gpt-3.5-turbo",
|
14 |
messages=[
|
15 |
{"role": "system", "content": "You are a helpful assistant."},
|
16 |
{"role": "user", "content": prompt},
|