Spaces:
Runtime error
Runtime error
Nitish Raghav
commited on
Update gptcall.py
Browse files- gptcall.py +4 -2
gptcall.py
CHANGED
@@ -2,7 +2,9 @@ import requests
|
|
2 |
import json
|
3 |
import openai
|
4 |
import configparser
|
5 |
-
|
|
|
|
|
6 |
# Load configuration
|
7 |
config = configparser.ConfigParser()
|
8 |
config.read('test.env')
|
@@ -10,7 +12,7 @@ API_KEY = config.get('API', 'OPEN_AI_KEY')
|
|
10 |
API_URL = config.get('API', 'OPEN_AI_URL')
|
11 |
|
12 |
# Set the OpenAI API key
|
13 |
-
openai.api_key =
|
14 |
|
15 |
def generate(prompt):
|
16 |
try:
|
|
|
2 |
import json
|
3 |
import openai
|
4 |
import configparser
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
load_dotenv()
|
7 |
+
import os
|
8 |
# Load configuration
|
9 |
config = configparser.ConfigParser()
|
10 |
config.read('test.env')
|
|
|
12 |
API_URL = config.get('API', 'OPEN_AI_URL')
|
13 |
|
14 |
# Set the OpenAI API key
|
15 |
+
openai.api_key = os.environ.get('OPEN_AI_KEY')
|
16 |
|
17 |
def generate(prompt):
|
18 |
try:
|