baruga commited on
Commit
b3036ac
·
1 Parent(s): 5155d1c

Add env variables

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +6 -5
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
app.py CHANGED
@@ -3,10 +3,12 @@ import openai
3
  import os
4
  import requests
5
 
6
- openai.api_key = "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"
7
- # openai.api_key = os.getenv("OPENAI_API_KEY")
8
 
9
- default_system_message = {"role": "system", "content": "You are a brilliant, helpful assistant, always providing answers to the best of your knowledge. If you are unsure of the answer, you indicate it to the user."}
 
 
10
 
11
  def get_completion(model, user_message, message_history, chatlog_history, temperature, maximum_length, top_p, frequency_penalty, presence_penalty):
12
  new_history_row = {"role": "user", "content": user_message}
@@ -117,5 +119,4 @@ with gr.Blocks(theme=theme) as app:
117
  retry_button.click(retry_completion, inputs=[model, message_history, chatlog_history, temperature, maximum_length, top_p, frequency_penalty, presence_penalty], outputs=[user_message, message_history, chatlog_history, chatbot, token_count])
118
  reset_button.click(reset_chat, inputs=[], outputs=[user_message, message_history, chatlog_history, chatbot, token_count])
119
 
120
- app.launch()
121
- # app.launch(auth=("admin", "C%nc6mrn8*BCwQF9HhH4CX35d7Q**eQY"))
 
3
  import os
4
  import requests
5
 
6
+ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
7
+ ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD")
8
 
9
+ openai.api_key = OPENAI_API_KEY
10
+
11
+ default_system_message = {"role": "system", "content": "You are a brilliant, helpful assistant, always providing answers to the best of your knowledge. If you are unsure of the answer, you indicate it to the user. Currently, you don't have access to the internet."}
12
 
13
  def get_completion(model, user_message, message_history, chatlog_history, temperature, maximum_length, top_p, frequency_penalty, presence_penalty):
14
  new_history_row = {"role": "user", "content": user_message}
 
119
  retry_button.click(retry_completion, inputs=[model, message_history, chatlog_history, temperature, maximum_length, top_p, frequency_penalty, presence_penalty], outputs=[user_message, message_history, chatlog_history, chatbot, token_count])
120
  reset_button.click(reset_chat, inputs=[], outputs=[user_message, message_history, chatlog_history, chatbot, token_count])
121
 
122
+ app.launch(auth=("admin", ADMIN_PASSWORD))