Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,16 +15,16 @@ left_column, right_column = st.columns(2)
|
|
| 15 |
# In the left column, allow the user to input a common goal for all agents
|
| 16 |
common_goal = left_column.text_area("Common Goal for the Agents", "Enter a goal")
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
num_dots =
|
| 20 |
|
| 21 |
-
# Initialize lists to hold agent names, tasks, and backstories
|
| 22 |
agent_names = []
|
| 23 |
tasks = []
|
| 24 |
backstories = []
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
for i in range(
|
| 28 |
agent_names.append(left_column.text_input(f"Agent {i+1} Name", key=f"name_{i}"))
|
| 29 |
tasks.append(left_column.text_input(f"Agent {i+1} Task", key=f"task_{i}"))
|
| 30 |
backstories.append(left_column.text_area(f"Agent {i+1} Backstory", key=f"backstory_{i}"))
|
|
@@ -32,22 +32,25 @@ for i in range(num_dots):
|
|
| 32 |
# Placeholder for the Plotly chart in the right column
|
| 33 |
chart_placeholder = right_column.empty()
|
| 34 |
|
|
|
|
|
|
|
|
|
|
| 35 |
while True: # This loop will simulate real-time data updates
|
| 36 |
# Create a list to hold the new data points
|
| 37 |
new_data_points = []
|
| 38 |
|
| 39 |
-
# Generate random x and y positions within the specified radius for
|
| 40 |
-
for
|
| 41 |
new_x = random.uniform(-radius, radius)
|
| 42 |
new_y = random.uniform(-radius, radius)
|
| 43 |
# Append the new data point as a dictionary to the list
|
| 44 |
-
new_data_points.append({'x': new_x, 'y': new_y})
|
| 45 |
|
| 46 |
# Create a new DataFrame from the list of new data points
|
| 47 |
new_data = pd.DataFrame(new_data_points)
|
| 48 |
|
| 49 |
# Create a new Plotly figure for the scatter plot
|
| 50 |
-
fig = px.scatter(new_data, x='x', y='y', title="Random Dots with Assigned Agents")
|
| 51 |
|
| 52 |
# Update the figure layout to better visualize the dots
|
| 53 |
fig.update_layout(xaxis_title='X Axis',
|
|
@@ -56,8 +59,8 @@ while True: # This loop will simulate real-time data updates
|
|
| 56 |
xaxis=dict(range=[-radius, radius]),
|
| 57 |
yaxis=dict(range=[-radius, radius]))
|
| 58 |
|
| 59 |
-
# Update traces to adjust the appearance of the dots
|
| 60 |
-
fig.update_traces(marker=dict(size=
|
| 61 |
|
| 62 |
# Display the figure in the right column
|
| 63 |
chart_placeholder.plotly_chart(fig, use_container_width=True)
|
|
|
|
| 15 |
# In the left column, allow the user to input a common goal for all agents
|
| 16 |
common_goal = left_column.text_area("Common Goal for the Agents", "Enter a goal")
|
| 17 |
|
| 18 |
+
# Number of dots is set to 4
|
| 19 |
+
num_dots = 4
|
| 20 |
|
| 21 |
+
# Initialize lists to hold agent names, tasks, and backstories. Limited to 4 agents.
|
| 22 |
agent_names = []
|
| 23 |
tasks = []
|
| 24 |
backstories = []
|
| 25 |
|
| 26 |
+
# Loop fixed to 4 for the four agents
|
| 27 |
+
for i in range(4):
|
| 28 |
agent_names.append(left_column.text_input(f"Agent {i+1} Name", key=f"name_{i}"))
|
| 29 |
tasks.append(left_column.text_input(f"Agent {i+1} Task", key=f"task_{i}"))
|
| 30 |
backstories.append(left_column.text_area(f"Agent {i+1} Backstory", key=f"backstory_{i}"))
|
|
|
|
| 32 |
# Placeholder for the Plotly chart in the right column
|
| 33 |
chart_placeholder = right_column.empty()
|
| 34 |
|
| 35 |
+
# Define colors for the dots
|
| 36 |
+
colors = ['red', 'green', 'blue', 'purple']
|
| 37 |
+
|
| 38 |
while True: # This loop will simulate real-time data updates
|
| 39 |
# Create a list to hold the new data points
|
| 40 |
new_data_points = []
|
| 41 |
|
| 42 |
+
# Generate random x and y positions within the specified radius for 4 dots
|
| 43 |
+
for i in range(num_dots):
|
| 44 |
new_x = random.uniform(-radius, radius)
|
| 45 |
new_y = random.uniform(-radius, radius)
|
| 46 |
# Append the new data point as a dictionary to the list
|
| 47 |
+
new_data_points.append({'x': new_x, 'y': new_y, 'color': colors[i]})
|
| 48 |
|
| 49 |
# Create a new DataFrame from the list of new data points
|
| 50 |
new_data = pd.DataFrame(new_data_points)
|
| 51 |
|
| 52 |
# Create a new Plotly figure for the scatter plot
|
| 53 |
+
fig = px.scatter(new_data, x='x', y='y', color='color', title="Random Dots with Assigned Agents", color_discrete_sequence=colors)
|
| 54 |
|
| 55 |
# Update the figure layout to better visualize the dots
|
| 56 |
fig.update_layout(xaxis_title='X Axis',
|
|
|
|
| 59 |
xaxis=dict(range=[-radius, radius]),
|
| 60 |
yaxis=dict(range=[-radius, radius]))
|
| 61 |
|
| 62 |
+
# Update traces to adjust the appearance of the dots, setting radius to 10
|
| 63 |
+
fig.update_traces(marker=dict(size=20)) # Size adjusted for radius of 10
|
| 64 |
|
| 65 |
# Display the figure in the right column
|
| 66 |
chart_placeholder.plotly_chart(fig, use_container_width=True)
|