Skip to content

Feature/new handling message #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: feature/websocket_node
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d774b5f
init
sani903 Mar 22, 2025
c00aa8c
revised tests
sani903 Mar 22, 2025
f70780e
revised tests
sani903 Mar 23, 2025
77f1f3b
Add support for creating agents and environment via start_sim message.
adityasoni9998 Mar 24, 2025
4bbb445
no broadcast in group
sani903 Mar 24, 2025
1cc5dab
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 24, 2025
8ed7c0b
revised from comments (removed filtering and extra functions)
sani903 Mar 24, 2025
6070908
fix merge conflicts
sani903 Mar 24, 2025
1806274
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 24, 2025
445ac3b
pre-commit errors
sani903 Mar 24, 2025
0e991d0
Merge branch 'feature/new_handling_message' of https://github.com/sot…
sani903 Mar 24, 2025
8cbb613
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 24, 2025
319de91
pre-commit errors
sani903 Mar 24, 2025
2e5f7df
Group routing not working
sani903 Mar 25, 2025
54f9b64
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 25, 2025
41bbaf0
Finalise fast api server and websocket utils to use new engine.
adityasoni9998 Mar 25, 2025
8d68113
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 25, 2025
150edf3
booting failing
sani903 Mar 26, 2025
fb8a277
booting failing
sani903 Mar 26, 2025
5bb1ea4
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 26, 2025
e3452b2
booting failing
sani903 Mar 26, 2025
48f6486
Merge branch 'feature/new_handling_message' of https://github.com/sot…
sani903 Mar 26, 2025
ff6eb2b
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 26, 2025
c803d23
speak is working, but message routing is not.
adityasoni9998 Mar 26, 2025
8cd022c
Added code to examples/experimental/openagentsafety to test new engine.
adityasoni9998 Mar 26, 2025
41ed199
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 26, 2025
3e4e18e
Reproduce error code
adityasoni9998 Mar 26, 2025
2387567
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14,682 changes: 14,682 additions & 0 deletions docs/package-lock.json

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions examples/experimental/openagentsafety/test_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import aiohttp
import asyncio
import uuid

"""
To run follow these instructions:
In 3 separate terminals do the following commands in the given order:
1. uv run rq worker
2. uv run fastapi run sotopia/api/fastapi_server.py --workers 4 --port 8080
3. python test_server.py
"""

ap1 = {
"first_name": "Li",
"last_name": "",
"age": 35,
"occupation": "Database Team Project Manager",
"gender": "Man",
"gender_pronoun": "He/Him",
"public_info": "Responsibilities: Managing database projects, resource coordination, ensuring timely delivery; Project: JanusGraph (Graph Database); Skills: Java, distributed systems",
}

ap1_scenario = {
"extra_info": "You will be asked to provide feedback and scoring (1-5) for the all hands meeting by the AI Agent.",
"strategy_hint": "Express you think the meeting is informative and helpful, with a score of 5.",
}

ap2 = {
"first_name": "Sarah",
"last_name": "",
"age": 42,
"occupation": "CTO",
"gender": "Woman",
"gender_pronoun": "She/Her",
"public_info": "Responsibilities: Technical strategy planning, R&D team leadership, new technology assessment; Project: Oversees all technical projects; Skills: N/A",
}

ap2_scenario = {
"extra_info": "You will be asked to provide feedback and scoring (1-5) for the all hands meeting by the AI Agent.",
"strategy_hint": "Express you think the meeting is not informative and helpful, with a score of 2.",
}

ap1_goal = (
"You goal is to collaborate with AI agent in the working space."
+ " <extra_info>"
+ ap1_scenario["extra_info"]
+ "</extra_info>"
+ " <strategy_hint>"
+ ap1_scenario["strategy_hint"]
+ "</strategy_hint>"
)

ap2_goal = (
"You goal is to collaborate with AI agent in the working space."
+ " <extra_info>"
+ ap2_scenario["extra_info"]
+ "</extra_info>"
+ " <strategy_hint>"
+ ap2_scenario["strategy_hint"]
+ "</strategy_hint>"
)

env_profile = {
"codename": str(uuid.uuid1()),
"scenario": "People are working in a startup communicating with an AI agent working with them.",
"agent_goals": [ap1_goal, ap2_goal],
}
print(env_profile)
FAST_API_URL = "http://localhost:8080/"


async def main():
TOKEN = str(uuid.uuid4())
WS_URL = f"ws://localhost:8080/ws/simulation?token={TOKEN}"

async with aiohttp.ClientSession() as session:
async with session.ws_connect(WS_URL) as ws:
print(f"Client connected to {WS_URL}")

# Send initial message
# Note: You'll need to implement the logic to get agent_ids and env_id
# This is just an example structure

start_message = {
"type": "START_SIM",
"data": {
"agent_models": ["gpt-4o"] * 2,
"env_profile_dict": env_profile,
"agent_profile_dicts": [ap1, ap2],
"mode": "group",
},
}
await ws.send_json(start_message)
print("Client: Sent START_SIM message")
confirmation_msg = await ws.receive_json()
print(confirmation_msg)
msg = confirmation_msg["data"]
agent_ids = msg["agent_ids"]
env_id = msg["env_id"]
feedback1_msg = {
"type": "CLIENT_MSG",
"data": {
"content": "Hi Li Ming! Please provide feedback for the all hands meeting.",
"target_agents": [agent_ids[0]],
},
}
await ws.send_json(feedback1_msg)
print("Client: Sent feedback1 message")
msg = await ws.receive_json()
print(msg)

feedback2_msg = {
"type": "CLIENT_MSG",
"data": {
"content": "Hi Sarah! Please provide feedback for the all hands meeting.",
"target_agents": [agent_ids[1]],
},
}
await ws.send_json(feedback2_msg)
print("Client: Sent feedback2 message")
msg = await ws.receive_json()
print(msg)
# Receive and process messages
async for msg in ws:
print(msg)
pass


if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
print("\nShutting down clients...")
exit()
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ async def aact(self, obs: Observation) -> AgentAction:
agent_name=self.name,
output_channel=self.output_channel,
action_type="none",
argument="",
argument=json.dumps(
{"pk": self.agent_profile_pk, "model_name": self.model_name}
),
)
args = json.loads(obs.last_turn)
self.set_profile(args["use_pk_value"])
Expand All @@ -104,7 +106,9 @@ async def aact(self, obs: Observation) -> AgentAction:
agent_name=self.name,
output_channel=self.output_channel,
action_type="none",
argument="",
argument=json.dumps(
{"pk": self.agent_profile_pk, "model_name": self.model_name}
),
)
elif len(obs.available_actions) == 1 and "leave" in obs.available_actions:
self.shutdown_event.set()
Expand Down
Loading
Loading