Spaces:
Runtime error
Runtime error
fix
Browse files
app.py
CHANGED
@@ -108,51 +108,64 @@ def create_demo() -> gr.Blocks:
|
|
108 |
|
109 |
gr.Markdown("<br>")
|
110 |
|
111 |
-
gr.
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
examples=[
|
157 |
["What is the trolley problem and what are its main ethical implications?"],
|
158 |
["Can you explain Plato's Theory of Forms?"],
|
@@ -160,14 +173,18 @@ def create_demo() -> gr.Blocks:
|
|
160 |
["How does Kant's Categorical Imperative work?"],
|
161 |
["What is the problem of consciousness in philosophy of mind?"],
|
162 |
],
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
171 |
)
|
172 |
|
173 |
gr.Markdown(LICENSE)
|
|
|
108 |
|
109 |
gr.Markdown("<br>")
|
110 |
|
111 |
+
chatbot = gr.Chatbot(
|
112 |
+
show_label=False,
|
113 |
+
avatar_images=(None, None),
|
114 |
+
)
|
115 |
+
|
116 |
+
with gr.Row():
|
117 |
+
msg = gr.Textbox(
|
118 |
+
scale=4,
|
119 |
+
show_label=False,
|
120 |
+
placeholder="Enter text and press enter",
|
121 |
+
container=False,
|
122 |
+
)
|
123 |
+
submit = gr.Button("Submit", scale=1, variant="primary")
|
124 |
+
|
125 |
+
system_prompt = gr.Textbox(
|
126 |
+
label="System prompt",
|
127 |
+
lines=6,
|
128 |
+
value="You are a knowledgeable philosophy professor using the Stanford Encyclopedia of Philosophy as your knowledge base. Provide clear, accurate responses using markdown formatting. Focus on philosophical concepts and maintain academic rigor while being accessible. Always cite relevant philosophers and concepts."
|
129 |
+
)
|
130 |
+
|
131 |
+
with gr.Accordion("Generation Parameters", open=False):
|
132 |
+
max_new_tokens = gr.Slider(
|
133 |
+
label="Max new tokens",
|
134 |
+
minimum=1,
|
135 |
+
maximum=MAX_MAX_NEW_TOKENS,
|
136 |
+
step=1,
|
137 |
+
value=DEFAULT_MAX_NEW_TOKENS,
|
138 |
+
)
|
139 |
+
temperature = gr.Slider(
|
140 |
+
label="Temperature",
|
141 |
+
minimum=0.1,
|
142 |
+
maximum=4.0,
|
143 |
+
step=0.1,
|
144 |
+
value=0.7,
|
145 |
+
)
|
146 |
+
top_p = gr.Slider(
|
147 |
+
label="Top-p (nucleus sampling)",
|
148 |
+
minimum=0.05,
|
149 |
+
maximum=1.0,
|
150 |
+
step=0.05,
|
151 |
+
value=0.9,
|
152 |
+
)
|
153 |
+
top_k = gr.Slider(
|
154 |
+
label="Top-k",
|
155 |
+
minimum=1,
|
156 |
+
maximum=1000,
|
157 |
+
step=1,
|
158 |
+
value=50,
|
159 |
+
)
|
160 |
+
repetition_penalty = gr.Slider(
|
161 |
+
label="Repetition penalty",
|
162 |
+
minimum=1.0,
|
163 |
+
maximum=2.0,
|
164 |
+
step=0.05,
|
165 |
+
value=1.1,
|
166 |
+
)
|
167 |
+
|
168 |
+
gr.Examples(
|
169 |
examples=[
|
170 |
["What is the trolley problem and what are its main ethical implications?"],
|
171 |
["Can you explain Plato's Theory of Forms?"],
|
|
|
173 |
["How does Kant's Categorical Imperative work?"],
|
174 |
["What is the problem of consciousness in philosophy of mind?"],
|
175 |
],
|
176 |
+
inputs=msg,
|
177 |
+
)
|
178 |
+
|
179 |
+
msg.submit(
|
180 |
+
generate,
|
181 |
+
[msg, chatbot, system_prompt, max_new_tokens, temperature, top_p, top_k, repetition_penalty],
|
182 |
+
[chatbot],
|
183 |
+
)
|
184 |
+
submit.click(
|
185 |
+
generate,
|
186 |
+
[msg, chatbot, system_prompt, max_new_tokens, temperature, top_p, top_k, repetition_penalty],
|
187 |
+
[chatbot],
|
188 |
)
|
189 |
|
190 |
gr.Markdown(LICENSE)
|