Spaces:
Runtime error
Runtime error
Johnny Lee
commited on
Commit
·
6dd083e
1
Parent(s):
fdd8c3c
updates
Browse files
app.py
CHANGED
@@ -54,8 +54,8 @@ You will start an conversation with me in the following form:
|
|
54 |
6. The discussion should be informative and very rigorous. Do not agree with my arguments easily. Pursue a Socratic method of questioning and reasoning.
|
55 |
"""
|
56 |
|
57 |
-
|
58 |
-
CASES = {case["name"]: case["template"] for case in json.load(
|
59 |
|
60 |
|
61 |
def get_case_template(template_name: str) -> str:
|
@@ -302,50 +302,48 @@ theme = gr.themes.Soft()
|
|
302 |
creds = [(os.getenv("CHAT_USERNAME"), os.getenv("CHAT_PASSWORD"))]
|
303 |
|
304 |
# gradio_flagger = gr.HuggingFaceDatasetSaver(HF_TOKEN, "chats")
|
305 |
-
title = "
|
306 |
-
|
307 |
with gr.Blocks(
|
308 |
theme=theme,
|
309 |
analytics_enabled=False,
|
310 |
title=title,
|
311 |
) as demo:
|
312 |
state = gr.State()
|
313 |
-
gr.Markdown(f"### {title}")
|
314 |
-
with gr.Tab("
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
label="Case",
|
324 |
-
choices=CASES.keys(),
|
325 |
-
value="Netflix",
|
326 |
-
multiselect=False,
|
327 |
-
)
|
328 |
-
system_prompt_input = gr.Textbox(
|
329 |
-
label="System Prompt", value=SYSTEM_MESSAGE
|
330 |
-
)
|
331 |
-
update_system_button = gr.Button(value="Update Prompt & Reset")
|
332 |
-
status_markdown = gr.Markdown()
|
333 |
-
with gr.Tab("Chatbot"):
|
334 |
-
with gr.Column():
|
335 |
-
chatbot = gr.Chatbot(label="ChatBot")
|
336 |
input_message = gr.Textbox(
|
337 |
placeholder="Send a message.",
|
338 |
label="Type an input and press Enter",
|
|
|
339 |
)
|
340 |
b1 = gr.Button(value="Submit")
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
# gradio_flagger.setup([chatbot], "chats")
|
344 |
|
345 |
chat_bot_submit_params = dict(
|
346 |
fn=respond, inputs=[input_message, state], outputs=[chatbot, state, share_link]
|
347 |
)
|
348 |
-
|
349 |
input_message.submit(**chat_bot_submit_params)
|
350 |
b1.click(**chat_bot_submit_params)
|
351 |
update_system_button.click(
|
@@ -353,9 +351,16 @@ with gr.Blocks(
|
|
353 |
[system_prompt_input, llm_input, case_input],
|
354 |
[status_markdown, state],
|
355 |
)
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
update_system_button.click(reset_textbox, [], [input_message])
|
358 |
update_system_button.click(reset_textbox, [], [chatbot])
|
|
|
|
|
359 |
b1.click(reset_textbox, [], [input_message])
|
360 |
input_message.submit(reset_textbox, [], [input_message])
|
361 |
|
|
|
54 |
6. The discussion should be informative and very rigorous. Do not agree with my arguments easily. Pursue a Socratic method of questioning and reasoning.
|
55 |
"""
|
56 |
|
57 |
+
with open("templates.json") as json_f:
|
58 |
+
CASES = {case["name"]: case["template"] for case in json.load(json_f)}
|
59 |
|
60 |
|
61 |
def get_case_template(template_name: str) -> str:
|
|
|
302 |
creds = [(os.getenv("CHAT_USERNAME"), os.getenv("CHAT_PASSWORD"))]
|
303 |
|
304 |
# gradio_flagger = gr.HuggingFaceDatasetSaver(HF_TOKEN, "chats")
|
305 |
+
title = "CBS Technology Strategy - Fall 2023"
|
306 |
+
image_url = ""
|
307 |
with gr.Blocks(
|
308 |
theme=theme,
|
309 |
analytics_enabled=False,
|
310 |
title=title,
|
311 |
) as demo:
|
312 |
state = gr.State()
|
313 |
+
gr.Markdown(f"""### {title}""")
|
314 |
+
with gr.Tab("Debate Partner"):
|
315 |
+
case_input = gr.Dropdown(
|
316 |
+
label="Case",
|
317 |
+
choices=CASES.keys(),
|
318 |
+
value="Netflix",
|
319 |
+
multiselect=False,
|
320 |
+
)
|
321 |
+
chatbot = gr.Chatbot(label="ChatBot")
|
322 |
+
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
input_message = gr.Textbox(
|
324 |
placeholder="Send a message.",
|
325 |
label="Type an input and press Enter",
|
326 |
+
scale=5,
|
327 |
)
|
328 |
b1 = gr.Button(value="Submit")
|
329 |
+
share_link = gr.Markdown()
|
330 |
+
with gr.Tab("Setup"):
|
331 |
+
llm_input = gr.Dropdown(
|
332 |
+
label="LLM",
|
333 |
+
choices=["Claude 2", "GPT-4"],
|
334 |
+
value="GPT-4",
|
335 |
+
multiselect=False,
|
336 |
+
)
|
337 |
+
system_prompt_input = gr.TextArea(
|
338 |
+
label="System Prompt", value=SYSTEM_MESSAGE, lines=10
|
339 |
+
)
|
340 |
+
update_system_button = gr.Button(value="Update Prompt & Reset")
|
341 |
+
status_markdown = gr.Markdown()
|
342 |
# gradio_flagger.setup([chatbot], "chats")
|
343 |
|
344 |
chat_bot_submit_params = dict(
|
345 |
fn=respond, inputs=[input_message, state], outputs=[chatbot, state, share_link]
|
346 |
)
|
|
|
347 |
input_message.submit(**chat_bot_submit_params)
|
348 |
b1.click(**chat_bot_submit_params)
|
349 |
update_system_button.click(
|
|
|
351 |
[system_prompt_input, llm_input, case_input],
|
352 |
[status_markdown, state],
|
353 |
)
|
354 |
+
case_input.change(
|
355 |
+
update_system_prompt,
|
356 |
+
[system_prompt_input, llm_input, case_input],
|
357 |
+
[status_markdown, state],
|
358 |
+
)
|
359 |
|
360 |
update_system_button.click(reset_textbox, [], [input_message])
|
361 |
update_system_button.click(reset_textbox, [], [chatbot])
|
362 |
+
case_input.change(reset_textbox, [], [input_message])
|
363 |
+
case_input.change(reset_textbox, [], [chatbot])
|
364 |
b1.click(reset_textbox, [], [input_message])
|
365 |
input_message.submit(reset_textbox, [], [input_message])
|
366 |
|