Spaces:
Runtime error
Runtime error
added button to add api key of users
Browse files
app.py
CHANGED
@@ -11,15 +11,15 @@ matplotlib.use('Agg')
|
|
11 |
|
12 |
|
13 |
#get openaiapikey from environment variable
|
14 |
-
openaiapikey = os.environ.get('OPENAI_API_KEY')
|
15 |
-
|
16 |
-
#install open-interpreter package
|
17 |
-
os.system(f"pip install open-interpreter")
|
18 |
|
19 |
interpreter.auto_run = True
|
20 |
interpreter.llm.model = "gpt-4-turbo"
|
21 |
interpreter.custom_instructions = "First ask the user what they want to do. Based on the input, describe the next steps. If user agrees, proceed; if not, ask what they want next.If it is anything to display , always at the end open up the file."
|
22 |
|
|
|
|
|
|
|
23 |
def json_to_markdown(json_data):
|
24 |
full_message = ""
|
25 |
images = []
|
@@ -50,6 +50,13 @@ def update_images(image_component):
|
|
50 |
def create_chat_widget():
|
51 |
with gr.Blocks() as chatblock:
|
52 |
gr.Markdown("Please note: Responses and updates may take some time to process.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Declare chatbot and txt here so they are accessible later
|
54 |
chatbot = gr.Chatbot(
|
55 |
[],
|
|
|
11 |
|
12 |
|
13 |
#get openaiapikey from environment variable
|
14 |
+
#openaiapikey = os.environ.get('OPENAI_API_KEY')
|
|
|
|
|
|
|
15 |
|
16 |
interpreter.auto_run = True
|
17 |
interpreter.llm.model = "gpt-4-turbo"
|
18 |
interpreter.custom_instructions = "First ask the user what they want to do. Based on the input, describe the next steps. If user agrees, proceed; if not, ask what they want next.If it is anything to display , always at the end open up the file."
|
19 |
|
20 |
+
def set_api_key(api_key):
|
21 |
+
os.environ['OPENAI_API_KEY'] = api_key
|
22 |
+
return "API Key set successfully."
|
23 |
def json_to_markdown(json_data):
|
24 |
full_message = ""
|
25 |
images = []
|
|
|
50 |
def create_chat_widget():
|
51 |
with gr.Blocks() as chatblock:
|
52 |
gr.Markdown("Please note: Responses and updates may take some time to process.")
|
53 |
+
|
54 |
+
|
55 |
+
gr.Markdown("Enter your OpenAI API key:")
|
56 |
+
api_key_input = gr.Textbox()
|
57 |
+
set_api_key_button = gr.Button("Set API Key")
|
58 |
+
set_api_key_button.click(set_api_key, inputs=api_key_input, outputs=None)
|
59 |
+
|
60 |
# Declare chatbot and txt here so they are accessible later
|
61 |
chatbot = gr.Chatbot(
|
62 |
[],
|