Nitish Raghav commited on
Commit
3ef7bfa
·
verified ·
1 Parent(s): 8ef0602

Update gptcall.py

Browse files
Files changed (1) hide show
  1. 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 = 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: