Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -66,9 +66,32 @@ def respond(
|
|
66 |
except Exception as e:
|
67 |
yield f"**Error:** {str(e)}"
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
# Define the Gradio interface with the Blocks context
|
71 |
-
with gr.Blocks() as demo:
|
72 |
chat_interface = gr.ChatInterface(
|
73 |
fn=respond,
|
74 |
additional_inputs=[
|
@@ -94,16 +117,15 @@ with gr.Blocks() as demo:
|
|
94 |
# Add the "Show Updates" button and output area
|
95 |
with gr.Row():
|
96 |
updates_button = gr.Button("Show Latest Updates")
|
97 |
-
updates_output = gr.Markdown(visible=False)
|
98 |
|
99 |
# Define the button's click event (now inside the Blocks context)
|
100 |
updates_button.click(
|
101 |
-
fn=
|
102 |
-
|
103 |
-
|
104 |
)
|
105 |
|
106 |
|
107 |
-
# Launch the Gradio interface
|
108 |
if __name__ == "__main__":
|
109 |
-
demo.launch()
|
|
|
66 |
except Exception as e:
|
67 |
yield f"**Error:** {str(e)}"
|
68 |
|
69 |
+
def show_updates_and_respond(history, system_message, max_tokens, temperature, top_p):
|
70 |
+
"""
|
71 |
+
Shows the latest updates and then generates a response from the model based on the updates.
|
72 |
+
"""
|
73 |
+
history.append(("User: ", "Show me the latest updates"))
|
74 |
+
yield from respond(
|
75 |
+
message="Show me the latest updates",
|
76 |
+
history=history,
|
77 |
+
system_message=system_message,
|
78 |
+
max_tokens=max_tokens,
|
79 |
+
temperature=temperature,
|
80 |
+
top_p=top_p,
|
81 |
+
)
|
82 |
+
history[-1] = ("User: ", "Show me the latest updates")
|
83 |
+
history.append(("Assistant:", latest_updates))
|
84 |
+
yield from respond(
|
85 |
+
message="What are the latest updates?",
|
86 |
+
history=history,
|
87 |
+
system_message=system_message,
|
88 |
+
max_tokens=max_tokens,
|
89 |
+
temperature=temperature,
|
90 |
+
top_p=top_p,
|
91 |
+
)
|
92 |
|
93 |
# Define the Gradio interface with the Blocks context
|
94 |
+
with gr.Blocks(css=".gradio-container {border: none;}") as demo:
|
95 |
chat_interface = gr.ChatInterface(
|
96 |
fn=respond,
|
97 |
additional_inputs=[
|
|
|
117 |
# Add the "Show Updates" button and output area
|
118 |
with gr.Row():
|
119 |
updates_button = gr.Button("Show Latest Updates")
|
|
|
120 |
|
121 |
# Define the button's click event (now inside the Blocks context)
|
122 |
updates_button.click(
|
123 |
+
fn=show_updates_and_respond,
|
124 |
+
inputs=[chat_interface.chat_history, chat_interface.textbox, gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"), gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"), gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")],
|
125 |
+
outputs=chat_interface.chat_history
|
126 |
)
|
127 |
|
128 |
|
129 |
+
# Launch the Gradio interface in full screen
|
130 |
if __name__ == "__main__":
|
131 |
+
demo.launch(share=True, fullscreen=True)
|