ositamiles commited on
Commit
f67e636
·
verified ·
1 Parent(s): 13f988d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ # API Configuration
5
+ API_URL = "https://startrz-proagents.hf.space/api/v1/prediction/7fae8aea-4e25-4feb-8af3-f08e2cd0c020"
6
+
7
+ def query_agent(agent_id, task):
8
+ """
9
+ Query the API with a specific agent and task.
10
+ """
11
+ payload = {"agent_id": agent_id, "task": task}
12
+ try:
13
+ response = requests.post(API_URL, json=payload)
14
+ response.raise_for_status()
15
+ return response.json()
16
+ except requests.exceptions.RequestException as e:
17
+ return {"error": str(e)}
18
+
19
+ # Streamlit App
20
+ st.title("Agent Task Delegation Interface")
21
+ st.markdown("""
22
+ This application allows you to interact with different agents by assigning them tasks and viewing their responses.
23
+ """)
24
+
25
+ # Sidebar: Agent Selection
26
+ with st.sidebar:
27
+ st.header("Agent Configuration")
28
+ st.markdown("Select an agent to assign tasks:")
29
+ agent_id = st.selectbox("Agent ID", ["Agent-1", "Agent-2", "Agent-3"], help="Choose the agent to interact with.")
30
+ st.markdown("---")
31
+ st.info("Ensure the agent selected aligns with your desired task context.")
32
+
33
+ # Task Input
34
+ st.header("Assign a Task")
35
+ task_input = st.text_area("Task Description", help="Describe the task you want the agent to perform.")
36
+
37
+ if st.button("Submit Task"):
38
+ if task_input.strip():
39
+ st.markdown(f"**Assigned to Agent {agent_id}:** {task_input}")
40
+ response = query_agent(agent_id, task_input)
41
+
42
+ # Display Response
43
+ if "error" in response:
44
+ st.error(f"Error: {response['error']}")
45
+ else:
46
+ result = response.get("result", "No result returned.")
47
+ st.success("Response received:")
48
+ st.markdown(f"**Result:** {result}")
49
+ else:
50
+ st.warning("Please enter a task before submitting.")
51
+
52
+ # Footer
53
+ st.markdown("---")
54
+ st.markdown("Built with ❤️ using [Streamlit](https://streamlit.io).")