kudo1026 commited on
Commit
05de806
1 Parent(s): 4259577

make api key part of config

Browse files
Files changed (2) hide show
  1. app.py +1 -0
  2. gpt_dialogue.py +3 -3
app.py CHANGED
@@ -85,6 +85,7 @@ def process_instruction_callback(inp_api_key, instruction, llm_name):
85
 
86
  # get oepnai config
87
  openai_config = get_openai_config(llm_name)
 
88
 
89
  # get LLM response
90
 
 
85
 
86
  # get oepnai config
87
  openai_config = get_openai_config(llm_name)
88
+ openai_config['api_key'] = inp_api_key
89
 
90
  # get LLM response
91
 
gpt_dialogue.py CHANGED
@@ -4,7 +4,6 @@ import datetime
4
  # import openai
5
  # openai.api_key = os.getenv("OPENAI_API_KEY")
6
  from openai import OpenAI
7
- client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
8
 
9
 
10
  # HUGGINGFACE_MODELS = {
@@ -19,7 +18,8 @@ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
19
 
20
 
21
  class Dialogue:
22
- def __init__(self, model='gpt-4', temperature=0, top_p=0.0, max_tokens=10, system_message='', load_path=None, save_path='chats', debug=False):
 
23
  self.model = model
24
  self.temperature = temperature
25
  self.top_p = top_p
@@ -98,7 +98,7 @@ class Dialogue:
98
  messages = self.pretext + user_message
99
  # print('messages: ', messages)
100
  if 'gpt' in self.model:
101
- completion = client.chat.completions.create(
102
  model=self.model,
103
  messages=self.pretext + user_message,
104
  temperature=self.temperature,
 
4
  # import openai
5
  # openai.api_key = os.getenv("OPENAI_API_KEY")
6
  from openai import OpenAI
 
7
 
8
 
9
  # HUGGINGFACE_MODELS = {
 
18
 
19
 
20
  class Dialogue:
21
+ def __init__(self, api_key, model='gpt-4', temperature=0, top_p=0.0, max_tokens=10, system_message='', load_path=None, save_path='chats', debug=False):
22
+ self.client = OpenAI(api_key=api_key)
23
  self.model = model
24
  self.temperature = temperature
25
  self.top_p = top_p
 
98
  messages = self.pretext + user_message
99
  # print('messages: ', messages)
100
  if 'gpt' in self.model:
101
+ completion = self.client.chat.completions.create(
102
  model=self.model,
103
  messages=self.pretext + user_message,
104
  temperature=self.temperature,