Spaces:
Runtime error
Runtime error
modify interface
Browse files
app.py
CHANGED
@@ -67,8 +67,9 @@ def generate_response(message, history, system_message, max_tokens, temperature,
|
|
67 |
|
68 |
return assistant_response
|
69 |
|
|
|
70 |
def update_advanced_settings(show_advanced):
|
71 |
-
return
|
72 |
|
73 |
with gr.Blocks() as demo:
|
74 |
with gr.Row():
|
@@ -87,14 +88,15 @@ with gr.Blocks() as demo:
|
|
87 |
system_prompt = gr.TextArea(label="📑Context", placeholder="add context here...", lines=5)
|
88 |
user_input = gr.TextArea(label="🤷🏻♂️User Input", placeholder="Hi there my name is Tonic!", lines=2)
|
89 |
advanced_checkbox = gr.Checkbox(label="🧪 Advanced Settings", value=False)
|
90 |
-
|
|
|
91 |
max_length = gr.Slider(label="📏Max Length", minimum=12, maximum=1700, value=650, step=1)
|
92 |
temperature = gr.Slider(label="🌡️Temperature", minimum=0.01, maximum=1.0, value=0.7, step=0.01)
|
93 |
top_p = gr.Slider(label="⚛️Top-p (Nucleus Sampling)", minimum=0.1, maximum=1.0, value=0.9, step=0.01)
|
94 |
-
# do_sample = gr.Checkbox(label="Do Sample", value=True)
|
95 |
use_pipeline = gr.Checkbox(label="Use Pipeline", value=False)
|
96 |
use_tool = gr.Checkbox(label="Use Function Calling", value=False)
|
97 |
-
|
|
|
98 |
tool_definition = gr.Code(
|
99 |
label="Tool Definition (JSON)",
|
100 |
value=customtool,
|
@@ -110,9 +112,10 @@ with gr.Blocks() as demo:
|
|
110 |
def user(user_message, history):
|
111 |
return "", history + [[user_message, None]]
|
112 |
|
113 |
-
def bot(history, system_prompt, max_length, temperature, top_p,
|
114 |
user_message = history[-1][0]
|
115 |
-
|
|
|
116 |
history[-1][1] = bot_message
|
117 |
return history
|
118 |
|
@@ -130,7 +133,7 @@ with gr.Blocks() as demo:
|
|
130 |
advanced_checkbox.change(
|
131 |
fn=update_advanced_settings,
|
132 |
inputs=[advanced_checkbox],
|
133 |
-
outputs=advanced_settings
|
134 |
)
|
135 |
|
136 |
use_tool.change(
|
@@ -141,4 +144,4 @@ with gr.Blocks() as demo:
|
|
141 |
|
142 |
if __name__ == "__main__":
|
143 |
demo.queue()
|
144 |
-
demo.launch()
|
|
|
67 |
|
68 |
return assistant_response
|
69 |
|
70 |
+
|
71 |
def update_advanced_settings(show_advanced):
|
72 |
+
return gr.Column.update(visible=show_advanced)
|
73 |
|
74 |
with gr.Blocks() as demo:
|
75 |
with gr.Row():
|
|
|
88 |
system_prompt = gr.TextArea(label="📑Context", placeholder="add context here...", lines=5)
|
89 |
user_input = gr.TextArea(label="🤷🏻♂️User Input", placeholder="Hi there my name is Tonic!", lines=2)
|
90 |
advanced_checkbox = gr.Checkbox(label="🧪 Advanced Settings", value=False)
|
91 |
+
advanced_settings = gr.Column(visible=False)
|
92 |
+
with advanced_settings:
|
93 |
max_length = gr.Slider(label="📏Max Length", minimum=12, maximum=1700, value=650, step=1)
|
94 |
temperature = gr.Slider(label="🌡️Temperature", minimum=0.01, maximum=1.0, value=0.7, step=0.01)
|
95 |
top_p = gr.Slider(label="⚛️Top-p (Nucleus Sampling)", minimum=0.1, maximum=1.0, value=0.9, step=0.01)
|
|
|
96 |
use_pipeline = gr.Checkbox(label="Use Pipeline", value=False)
|
97 |
use_tool = gr.Checkbox(label="Use Function Calling", value=False)
|
98 |
+
tool_options = gr.Column(visible=False)
|
99 |
+
with tool_options:
|
100 |
tool_definition = gr.Code(
|
101 |
label="Tool Definition (JSON)",
|
102 |
value=customtool,
|
|
|
112 |
def user(user_message, history):
|
113 |
return "", history + [[user_message, None]]
|
114 |
|
115 |
+
def bot(history, system_prompt, max_length, temperature, top_p, advanced_checkbox, use_pipeline, tool_definition):
|
116 |
user_message = history[-1][0]
|
117 |
+
do_sample = advanced_checkbox
|
118 |
+
bot_message = generate_response(user_message, history, system_prompt, max_length, temperature, top_p, do_sample, use_pipeline, tool_definition)
|
119 |
history[-1][1] = bot_message
|
120 |
return history
|
121 |
|
|
|
133 |
advanced_checkbox.change(
|
134 |
fn=update_advanced_settings,
|
135 |
inputs=[advanced_checkbox],
|
136 |
+
outputs=[advanced_settings]
|
137 |
)
|
138 |
|
139 |
use_tool.change(
|
|
|
144 |
|
145 |
if __name__ == "__main__":
|
146 |
demo.queue()
|
147 |
+
demo.launch()
|