Spaces:
Sleeping
Sleeping
fixing
Browse files
app.py
CHANGED
@@ -97,80 +97,83 @@ def generate(
|
|
97 |
gr.Warning(f"Error during generation: {str(e)}")
|
98 |
yield "I apologize, but I encountered an error. Please try again."
|
99 |
|
100 |
-
|
101 |
-
gr.
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
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 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
["What is the problem of consciousness in philosophy of mind?"],
|
162 |
-
],
|
163 |
-
chatbot=gr.Chatbot(
|
164 |
-
show_label=False,
|
165 |
-
avatar_images=(None, None),
|
166 |
-
),
|
167 |
-
autofocus=True,
|
168 |
-
retry_btn=None,
|
169 |
-
undo_btn=None,
|
170 |
-
clear_btn=None,
|
171 |
-
)
|
172 |
|
173 |
-
|
174 |
|
175 |
if __name__ == "__main__":
|
|
|
176 |
demo.queue(max_size=20).launch()
|
|
|
97 |
gr.Warning(f"Error during generation: {str(e)}")
|
98 |
yield "I apologize, but I encountered an error. Please try again."
|
99 |
|
100 |
+
def create_demo() -> gr.Blocks:
|
101 |
+
with gr.Blocks(css="style.css") as demo:
|
102 |
+
gr.Markdown("# Philosophy Chat with Llama 3.1")
|
103 |
+
gr.Markdown(DESCRIPTION)
|
104 |
+
gr.DuplicateButton(
|
105 |
+
value="Duplicate Space for private use",
|
106 |
+
elem_id="duplicate-button"
|
107 |
+
)
|
108 |
+
|
109 |
+
gr.Markdown("<br>")
|
110 |
+
|
111 |
+
gr.ChatInterface(
|
112 |
+
fn=generate,
|
113 |
+
additional_inputs=[
|
114 |
+
gr.Textbox(
|
115 |
+
label="System prompt",
|
116 |
+
lines=6,
|
117 |
+
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."
|
118 |
+
),
|
119 |
+
gr.Slider(
|
120 |
+
label="Max new tokens",
|
121 |
+
minimum=1,
|
122 |
+
maximum=MAX_MAX_NEW_TOKENS,
|
123 |
+
step=1,
|
124 |
+
value=DEFAULT_MAX_NEW_TOKENS,
|
125 |
+
),
|
126 |
+
gr.Slider(
|
127 |
+
label="Temperature",
|
128 |
+
minimum=0.1,
|
129 |
+
maximum=4.0,
|
130 |
+
step=0.1,
|
131 |
+
value=0.7,
|
132 |
+
),
|
133 |
+
gr.Slider(
|
134 |
+
label="Top-p (nucleus sampling)",
|
135 |
+
minimum=0.05,
|
136 |
+
maximum=1.0,
|
137 |
+
step=0.05,
|
138 |
+
value=0.9,
|
139 |
+
),
|
140 |
+
gr.Slider(
|
141 |
+
label="Top-k",
|
142 |
+
minimum=1,
|
143 |
+
maximum=1000,
|
144 |
+
step=1,
|
145 |
+
value=50,
|
146 |
+
),
|
147 |
+
gr.Slider(
|
148 |
+
label="Repetition penalty",
|
149 |
+
minimum=1.0,
|
150 |
+
maximum=2.0,
|
151 |
+
step=0.05,
|
152 |
+
value=1.1,
|
153 |
+
),
|
154 |
+
],
|
155 |
+
stop_btn=None,
|
156 |
+
examples=[
|
157 |
+
["What is the trolley problem and what are its main ethical implications?"],
|
158 |
+
["Can you explain Plato's Theory of Forms?"],
|
159 |
+
["What is the difference between analytic and continental philosophy?"],
|
160 |
+
["How does Kant's Categorical Imperative work?"],
|
161 |
+
["What is the problem of consciousness in philosophy of mind?"],
|
162 |
+
],
|
163 |
+
chatbot=gr.Chatbot(
|
164 |
+
show_label=False,
|
165 |
+
avatar_images=(None, None),
|
166 |
),
|
167 |
+
autofocus=True,
|
168 |
+
retry_btn=None,
|
169 |
+
undo_btn=None,
|
170 |
+
clear_btn=None,
|
171 |
+
)
|
172 |
+
|
173 |
+
gr.Markdown(LICENSE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
+
return demo
|
176 |
|
177 |
if __name__ == "__main__":
|
178 |
+
demo = create_demo()
|
179 |
demo.queue(max_size=20).launch()
|