Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -516,40 +516,7 @@ agent = smolagents.CodeAgent(
|
|
| 516 |
verbosity_level=2, # show steps in logs for class demo
|
| 517 |
)
|
| 518 |
|
| 519 |
-
"""
|
| 520 |
-
# --- Sidebar --
|
| 521 |
-
import gradio as gr
|
| 522 |
-
|
| 523 |
-
# Minimal Gradio chat
|
| 524 |
-
with gr.Blocks(title="TechSpark Agent") as demo:
|
| 525 |
-
gr.Markdown("## Beam Agent — Custom Tool Selection (smolagents + llama.cpp)")
|
| 526 |
-
chat = gr.Chatbot(height=420)
|
| 527 |
-
inp = gr.Textbox(placeholder="Ask your question in natural language.", label="Your question")
|
| 528 |
-
|
| 529 |
-
# No gr.State for agent — just close over `agent`
|
| 530 |
-
def respond(message, history):
|
| 531 |
-
try:
|
| 532 |
-
# 1. Use agent.chat() to maintain internal history
|
| 533 |
-
out = str(agent.run(message))
|
| 534 |
-
except Exception as e:
|
| 535 |
-
out = f"[Error] {e}"
|
| 536 |
-
|
| 537 |
-
# This just updates the Gradio UI history
|
| 538 |
-
history = (history or []) + [(message, out)]
|
| 539 |
-
return "", history
|
| 540 |
-
|
| 541 |
-
gr.Examples(
|
| 542 |
-
fn=respond,
|
| 543 |
-
examples=[
|
| 544 |
-
"Who is Ed?",
|
| 545 |
-
"Who to talk to to create a wooden table?",
|
| 546 |
-
"how to access laser cutter"
|
| 547 |
-
],
|
| 548 |
-
inputs=[inp]
|
| 549 |
-
)
|
| 550 |
|
| 551 |
-
inp.submit(respond, [inp, chat], [inp, chat])
|
| 552 |
-
"""
|
| 553 |
|
| 554 |
# --- Page config ---
|
| 555 |
st.set_page_config(page_title="TechSpark AI Assistant", layout="wide")
|
|
@@ -568,8 +535,6 @@ with st.sidebar:
|
|
| 568 |
add_vertical_space(3)
|
| 569 |
|
| 570 |
|
| 571 |
-
|
| 572 |
-
|
| 573 |
# --- CSS FIXES: SIDEBAR WIDER + CHAT TEXT MUCH BIGGER ---
|
| 574 |
st.markdown("""
|
| 575 |
<style>
|
|
@@ -693,5 +658,3 @@ with response_container:
|
|
| 693 |
message(st.session_state['past'][i], is_user=True, key=f"{i}_user")
|
| 694 |
message(st.session_state['generated'][i], key=f"{i}_assistant")
|
| 695 |
|
| 696 |
-
|
| 697 |
-
demo.launch(debug=True)
|
|
|
|
| 516 |
verbosity_level=2, # show steps in logs for class demo
|
| 517 |
)
|
| 518 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
|
|
|
|
|
|
|
| 520 |
|
| 521 |
# --- Page config ---
|
| 522 |
st.set_page_config(page_title="TechSpark AI Assistant", layout="wide")
|
|
|
|
| 535 |
add_vertical_space(3)
|
| 536 |
|
| 537 |
|
|
|
|
|
|
|
| 538 |
# --- CSS FIXES: SIDEBAR WIDER + CHAT TEXT MUCH BIGGER ---
|
| 539 |
st.markdown("""
|
| 540 |
<style>
|
|
|
|
| 658 |
message(st.session_state['past'][i], is_user=True, key=f"{i}_user")
|
| 659 |
message(st.session_state['generated'][i], key=f"{i}_assistant")
|
| 660 |
|
|
|
|
|
|