File size: 2,570 Bytes
5cfb870
8fc1a61
 
5c46e89
 
31bcc97
b1ec1ee
 
5c46e89
 
8b4d250
baa423c
 
75cadaa
8c4fb17
3da8b1b
8c4fb17
baa423c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75cadaa
5c46e89
ddaf69f
 
5c46e89
75cadaa
 
 
 
ddaf69f
 
 
 
 
5c46e89
 
baa423c
5c46e89
 
 
 
 
 
 
 
 
 
5cfb870
baa423c
5c46e89
5cfb870
5c46e89
75cadaa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import streamlit as st
import pandas as pd
import plotly.express as px
import random
import time

st.set_page_config(layout="wide")

# Specify the radius within which the dots should appear
radius = 5

# Create two columns in the Streamlit app
left_column, right_column = st.columns(2)

# In the left column, allow the user to input a common goal for all agents
common_goal = left_column.text_area("Common Goal for the Agents", "Enter a goal")

# In the left column, allow the user to input the number of dots, agent names, tasks, and backstories
num_dots = left_column.number_input('Number of dots', min_value=1, max_value=10, value=5)

# Initialize lists to hold agent names, tasks, and backstories
agent_names = []
tasks = []
backstories = []

# For each dot, get the agent name, task, and backstory
for i in range(num_dots):
    agent_names.append(left_column.text_input(f"Agent {i+1} Name", key=f"name_{i}"))
    tasks.append(left_column.text_input(f"Agent {i+1} Task", key=f"task_{i}"))
    backstories.append(left_column.text_area(f"Agent {i+1} Backstory", key=f"backstory_{i}"))

# Placeholder for the Plotly chart in the right column
chart_placeholder = right_column.empty()

while True:  # This loop will simulate real-time data updates
    # Create a list to hold the new data points
    new_data_points = []
    
    # Generate random x and y positions within the specified radius for the specified number of dots
    for _ in range(num_dots):
        new_x = random.uniform(-radius, radius)
        new_y = random.uniform(-radius, radius)
        # Append the new data point as a dictionary to the list
        new_data_points.append({'x': new_x, 'y': new_y})
    
    # Create a new DataFrame from the list of new data points
    new_data = pd.DataFrame(new_data_points)
    
    # Create a new Plotly figure for the scatter plot
    fig = px.scatter(new_data, x='x', y='y', title="Random Dots with Assigned Agents")
    
    # Update the figure layout to better visualize the dots
    fig.update_layout(xaxis_title='X Axis',
                      yaxis_title='Y Axis',
                      autosize=True,
                      xaxis=dict(range=[-radius, radius]),
                      yaxis=dict(range=[-radius, radius]))
    
    # Update traces to adjust the appearance of the dots
    fig.update_traces(marker=dict(size=12))  # Adjust the size as needed

    # Display the figure in the right column
    chart_placeholder.plotly_chart(fig, use_container_width=True)

    # Pause for a moment before updating the chart with new dots
    time.sleep(1)