Spaces:
Runtime error
Runtime error
refactor: add role params in function
Browse files- modules/gpt_modules.py +2 -6
modules/gpt_modules.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import openai
|
2 |
-
import os
|
3 |
|
4 |
from dotenv import dotenv_values
|
5 |
|
@@ -8,14 +7,11 @@ config = dotenv_values(".env")
|
|
8 |
openai.organization = config.get('OPENAI_ORGANIZATION')
|
9 |
openai.api_key = config.get('OPENAI_API_KEY')
|
10 |
|
11 |
-
|
12 |
-
# openai.api_key = os.environ['OPENAI_API_KEY']
|
13 |
-
|
14 |
-
def gpt_call(prompt):
|
15 |
response = openai.ChatCompletion.create(
|
16 |
model="gpt-3.5-turbo",
|
17 |
messages=[
|
18 |
-
{"role":
|
19 |
]
|
20 |
)
|
21 |
output_text = response["choices"][0]["message"]["content"]
|
|
|
1 |
import openai
|
|
|
2 |
|
3 |
from dotenv import dotenv_values
|
4 |
|
|
|
7 |
openai.organization = config.get('OPENAI_ORGANIZATION')
|
8 |
openai.api_key = config.get('OPENAI_API_KEY')
|
9 |
|
10 |
+
def gpt_call(prompt, role="user"):
|
|
|
|
|
|
|
11 |
response = openai.ChatCompletion.create(
|
12 |
model="gpt-3.5-turbo",
|
13 |
messages=[
|
14 |
+
{"role": role, "content": prompt},
|
15 |
]
|
16 |
)
|
17 |
output_text = response["choices"][0]["message"]["content"]
|