Update app.py
Browse files
app.py
CHANGED
@@ -53,11 +53,13 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
53 |
return f"Error: {e}"
|
54 |
|
55 |
def clear_context():
|
56 |
-
|
|
|
|
|
57 |
|
58 |
# Gradio Interface
|
59 |
with gr.Blocks() as demo:
|
60 |
-
gr.HTML("<div class='header-text'>AstroSage-LLAMA-3.1-8B</div><div class='subheader'>
|
61 |
|
62 |
chatbot = gr.Chatbot(height=400)
|
63 |
msg = gr.Textbox(placeholder="Ask about astronomy, astrophysics, or cosmology...", show_label=False)
|
@@ -85,7 +87,7 @@ with gr.Blocks() as demo:
|
|
85 |
queue=False
|
86 |
)
|
87 |
|
88 |
-
# Automatically clear context on reload
|
89 |
demo.load(lambda: clear_context(), None, [chatbot, msg])
|
90 |
|
91 |
if __name__ == "__main__":
|
|
|
53 |
return f"Error: {e}"
|
54 |
|
55 |
def clear_context():
|
56 |
+
# Initialize chat history with a greeting from the assistant
|
57 |
+
greeting_message = get_random_greeting()
|
58 |
+
return [("", greeting_message)], ""
|
59 |
|
60 |
# Gradio Interface
|
61 |
with gr.Blocks() as demo:
|
62 |
+
gr.HTML("<div class='header-text'>AstroSage-LLAMA-3.1-8B</div><div class='subheader'>Astronomy-Specialized Chatbot</div>")
|
63 |
|
64 |
chatbot = gr.Chatbot(height=400)
|
65 |
msg = gr.Textbox(placeholder="Ask about astronomy, astrophysics, or cosmology...", show_label=False)
|
|
|
87 |
queue=False
|
88 |
)
|
89 |
|
90 |
+
# Automatically clear context on reload with a greeting
|
91 |
demo.load(lambda: clear_context(), None, [chatbot, msg])
|
92 |
|
93 |
if __name__ == "__main__":
|