Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,11 +4,11 @@ import gradio as gr
|
|
4 |
from paper2cmap import Paper2CMap
|
5 |
|
6 |
|
7 |
-
def set_key(openai_api_key):
|
8 |
os.environ["OPENAI_API_TYPE"] = "openai"
|
9 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
10 |
-
os.environ["OPENAI_MODEL_NAME"] =
|
11 |
-
return openai_api_key
|
12 |
|
13 |
|
14 |
def load_text(state, paper_path, temperature, max_num_sections):
|
@@ -43,14 +43,21 @@ with gr.Blocks(css=css) as demo:
|
|
43 |
|
44 |
# Set Key
|
45 |
with gr.Row():
|
46 |
-
with gr.Column(scale=0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
openai_api_key = gr.Textbox(
|
48 |
show_label=False,
|
49 |
placeholder="Set your OpenAI API key here and press Enter",
|
50 |
lines=1,
|
51 |
type="password"
|
52 |
).style(container=False)
|
53 |
-
with gr.Column(scale=0.
|
54 |
set_key_btn = gr.Button("Submit")
|
55 |
|
56 |
# Inputs
|
@@ -98,8 +105,8 @@ with gr.Blocks(css=css) as demo:
|
|
98 |
concept_map = gr.JSON(label="Concept Map")
|
99 |
|
100 |
# Event Handlers
|
101 |
-
openai_api_key.submit(set_key, [openai_api_key], [openai_api_key])
|
102 |
-
set_key_btn.click(set_key, [openai_api_key], [openai_api_key])
|
103 |
|
104 |
generate_btn.click(
|
105 |
fn=load_text,
|
|
|
4 |
from paper2cmap import Paper2CMap
|
5 |
|
6 |
|
7 |
+
def set_key(openai_api_key, model_name):
|
8 |
os.environ["OPENAI_API_TYPE"] = "openai"
|
9 |
os.environ["OPENAI_API_KEY"] = openai_api_key
|
10 |
+
os.environ["OPENAI_MODEL_NAME"] = model_name
|
11 |
+
return openai_api_key, model_name
|
12 |
|
13 |
|
14 |
def load_text(state, paper_path, temperature, max_num_sections):
|
|
|
43 |
|
44 |
# Set Key
|
45 |
with gr.Row():
|
46 |
+
with gr.Column(scale=0.25):
|
47 |
+
model_name = gr.Dropdown(
|
48 |
+
show_label=False,
|
49 |
+
choices=["gpt-3.5-turbo", "gpt-4"],
|
50 |
+
value="gpt-3.5-turbo",
|
51 |
+
interactive=True,
|
52 |
+
).style(container=False)
|
53 |
+
with gr.Column(scale=0.65):
|
54 |
openai_api_key = gr.Textbox(
|
55 |
show_label=False,
|
56 |
placeholder="Set your OpenAI API key here and press Enter",
|
57 |
lines=1,
|
58 |
type="password"
|
59 |
).style(container=False)
|
60 |
+
with gr.Column(scale=0.1, min_width=0):
|
61 |
set_key_btn = gr.Button("Submit")
|
62 |
|
63 |
# Inputs
|
|
|
105 |
concept_map = gr.JSON(label="Concept Map")
|
106 |
|
107 |
# Event Handlers
|
108 |
+
openai_api_key.submit(set_key, [openai_api_key, model_name], [openai_api_key, model_name])
|
109 |
+
set_key_btn.click(set_key, [openai_api_key, model_name], [openai_api_key, model_name])
|
110 |
|
111 |
generate_btn.click(
|
112 |
fn=load_text,
|