Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,46 +1,52 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from agent import multi_agent_framework
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
# Define the multi agent framework
|
| 6 |
-
model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 7 |
-
agent = multi_agent_framework(model_id)
|
| 8 |
-
|
| 9 |
-
# Function to log agent actions
|
| 10 |
-
def log_agent_action(prompt, result):
|
| 11 |
-
st.write(f"### Agent Activity")
|
| 12 |
-
st.write("**Prompt Sent to Agent:**")
|
| 13 |
-
st.code(prompt, language="text")
|
| 14 |
-
|
| 15 |
-
st.code(
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
st.caption("Powered by SmolAgents, DuckDuckGo, black-forest-labs and Streamlit")
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from agent import multi_agent_framework
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
# Define the multi agent framework
|
| 6 |
+
model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 7 |
+
agent = multi_agent_framework(model_id)
|
| 8 |
+
|
| 9 |
+
# Function to log agent actions
|
| 10 |
+
def log_agent_action(prompt, activity, result):
|
| 11 |
+
st.write(f"### Agent Activity")
|
| 12 |
+
st.write("**Prompt Sent to Agent:**")
|
| 13 |
+
st.code(prompt, language="text")
|
| 14 |
+
at.write("**Agent Activity:**")
|
| 15 |
+
st.code(activity, language="text")
|
| 16 |
+
st.write("**Agent Output:**")
|
| 17 |
+
st.code(result, language="text")
|
| 18 |
+
|
| 19 |
+
# Streamlit app title
|
| 20 |
+
st.title("Multi Agent GPT")
|
| 21 |
+
|
| 22 |
+
# App description
|
| 23 |
+
st.write("Generate creative content, search the web and generate images enriched with the power of MultiAgent framework")
|
| 24 |
+
|
| 25 |
+
# Input blog topic or prompt
|
| 26 |
+
user_prompt = st.text_area("How may I help you?:", placeholder="E.g., Generate me a picture of cute puppy")
|
| 27 |
+
|
| 28 |
+
# Button to generate content
|
| 29 |
+
if st.button("Generate"):
|
| 30 |
+
if user_prompt:
|
| 31 |
+
with st.spinner("Generating content with our Multi agents"):
|
| 32 |
+
try:
|
| 33 |
+
# Run the agent with the given prompt
|
| 34 |
+
buffer = io.StringIO()
|
| 35 |
+
sys.stdout = buffer
|
| 36 |
+
result = agent.run(user_prompt)
|
| 37 |
+
# Display the generated content
|
| 38 |
+
st.subheader("Generated Content:")
|
| 39 |
+
st.write(result)
|
| 40 |
+
|
| 41 |
+
# Log backend activity
|
| 42 |
+
sys.stdout = sys.__stdout__
|
| 43 |
+
activity = buffer.getvalue()
|
| 44 |
+
log_agent_action(user_prompt, activity, result)
|
| 45 |
+
except Exception as e:
|
| 46 |
+
st.error(f"An error occurred: {e}")
|
| 47 |
+
else:
|
| 48 |
+
st.warning("Please enter a prompt to proceed.")
|
| 49 |
+
|
| 50 |
+
# Footer
|
| 51 |
+
st.markdown("---")
|
| 52 |
st.caption("Powered by SmolAgents, DuckDuckGo, black-forest-labs and Streamlit")
|