Spaces:
Sleeping
Sleeping
Download app.py from Kumardba224/Multitool-Agent-bot: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/spaces/Kumardba224/Multitool-Agent-bot/resolve/main/app.py
- Command line
-
hf download hf://spaces/Kumardba224/Multitool-Agent-bot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Kumardba224/Multitool-Agent-bot/resolve/main/app.py
1.86 kB
| import streamlit as st | |
| from agent_backend import ask_agent | |
| # ----------------------------------- | |
| # Page config | |
| # ----------------------------------- | |
| st.set_page_config( | |
| page_title="Day 7 AI Agent", | |
| page_icon="🤖", | |
| layout="wide" | |
| ) | |
| # ----------------------------------- | |
| # Title | |
| # ----------------------------------- | |
| st.title("🤖 Day 7 - AI Agent Assistant") | |
| st.markdown(""" | |
| This AI Agent can: | |
| - 🧮 Perform calculations | |
| - 🌐 Search the web | |
| - 🧠 Reason using tools | |
| """) | |
| # ----------------------------------- | |
| # Sidebar | |
| # ----------------------------------- | |
| with st.sidebar: | |
| st.header("⚙️ Controls") | |
| if st.button("🗑️ Clear Chat"): | |
| st.session_state.messages = [] | |
| st.rerun() | |
| # ----------------------------------- | |
| # Session State | |
| # ----------------------------------- | |
| if "messages" not in st.session_state: | |
| st.session_state.messages = [] | |
| # ----------------------------------- | |
| # Display chat history | |
| # ----------------------------------- | |
| for msg in st.session_state.messages: | |
| with st.chat_message(msg["role"]): | |
| st.write(msg["content"]) | |
| # ----------------------------------- | |
| # User input | |
| # ----------------------------------- | |
| user_input = st.chat_input( | |
| "Ask anything..." | |
| ) | |
| if user_input: | |
| # save user message | |
| st.session_state.messages.append( | |
| { | |
| "role": "user", | |
| "content": user_input | |
| } | |
| ) | |
| # display user message | |
| with st.chat_message("user"): | |
| st.write(user_input) | |
| # assistant response | |
| with st.chat_message("assistant"): | |
| with st.spinner("Thinking..."): | |
| response = ask_agent(user_input) | |
| st.write(response) | |
| # save assistant response | |
| st.session_state.messages.append( | |
| { | |
| "role": "assistant", | |
| "content": response | |
| } | |
| ) |