-
Notifications
You must be signed in to change notification settings - Fork 116
2‐Deployment instructions
We have provided some brief guidance on the trial process of our project in the readme.md. For more detailed deployment, we will supplement the details on this page.
In order to provide an easy-to-use infrastructure, we used a relatively universal game architecture to handle the logic of the entire project, see our arXiv paper.
We use MySQL to store server data, so before using it, you must first configure the correct version of MySQL for your computing environment.
MySQL: 8.0.31
We recommend you look for MySQL installation and configuration tutorials corresponding to your system on the internet, if you have never learned about MySQL before.
After you have correctly configured and entered the MySQL command line interface, input the following commands to create a database for storing backend server related information:
use mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
flush privileges;
create database `llm_account` default character set utf8mb4 collate utf8mb4_unicode_ci;
create database `llm_game` default character set utf8mb4 collate utf8mb4_unicode_ci;
create database `llm_game0001` default character set utf8mb4 collate utf8mb4_unicode_ci;
create database `llm_game0002` default character set utf8mb4 collate utf8mb4_unicode_ci;
Since the information stored in MySQL contains various information about the town in each round of simulation, the database needs to be reset every time the town needs to be restarted.
sudo mysql
drop database llm_account;
drop database llm_game0001;
create database `llm_game0001` default character set utf8mb4 collate utf8mb4_unicode_ci;
create database `llm_account` default character set utf8mb4 collate utf8mb4_unicode_ci;
Our server is written in Python. For a more stable experience, we recommend
Python: 3.9.x
pip install mysql-connector-python
For communication between the server and client, we use the websocket protocol and tornado for asynchronous processing. Tornado integrates websocket and utilizes the websocket server for connections.
pip install tornado
pip install websockets
pip install openai_async
We use Unity for client development. At the same time, we use webGL to provide a web version of the client. Considering that the Unity project source files are large, and the core of our project is not on the convenience of client modification, we have not yet open sourced the client modification mechanism. In later versions, we will provide a map editor to facilitate customized processing of visual presentation of frontend maps. For more details, please contact us.
git clone https://github.com/py499372727/AgentSims.git
Before configuring the parameters, create the folders as follows:
mkdir snapshot
mkdir logs
For the security of your API Key, we have not included the parameter file in git. Please create the following file
config/api_key.json
yourself and remember not to push it to git.
The file parameter example is:
{"gpt-4": "xxxx", "gpt-3.5": "xxxx"}
If you want to deploy your own model, see in 3-Task Instructions.
agent.json carries the relevant attributes of the agent, both the server and client will call it. The main focus here is that the LLM you newly added and the agent system you added need to be registered here.
app.json defines related parameters for server runtime. The key parameters that need attention are the following ones, which need custom adjustment for local deployment.
"tick_count_limit": XXX,
"mayor_count_limit": XXX,
Count_limit represents stopping the simulation after looping XXX times after starting a tick or mayor command. Of course, if the server is not reset, continuing the simulation does not affect the original state.
"tick_cooldown": 30000,
"mayor_cooldown": 30000,
Cool_down represents the time interval required between two commands.
These are task-specific parameters. If you want to customize your own task, see in 3-Task Instructions.
You need a terminal to start server:
./restart.sh
When you see
--------Server Started--------
in Server Terminal, the server has been started successfully.
Once the server has started successfully, please launch the client. In the current version, we provide a web-based client. Please open client/index.html in your browser.
Note: Sometimes the web client fails to open correctly. We recommend right-clicking the index.html in your python IDE and select open in browser. If you are familiar with nginx, that is also a great choice.
When you see
somebody linked.
in Server Terminal, the client has been started successfully.
You can create agents and buildings at this point. For creation, please refer to the 3-Task Instructions in the wiki or Section 4.1 User Mode in our arXiv paper.
Note:
- If you enter the client and find no operation buttons on the left and right sides, please scale the browser appropriately for your system. For example, "command" + "+" or "-" on MacOS. If there are buttons but only the mayor or one person on the screen, try scaling the map using the button on the right side.
- If you enter the client and find no default agent info (Alan and pH) in the agent list on the left side, and no default building info, please check the Server Terminal for any error messages.
- If you enter the client and click on tick or mayor with no response, please check logs/tick.log for any related error messages. Also check if the cooldown parameter in app.json has been modified to a suitable value. For any other issues not mentioned, please contact us.
You can start tick or mayor with the buttons on the web client. You can also start in another terminal with:
python -u tick.py
python -u mayor.py
If you are using our system for research purposes, the introduction in this chapter is indispensable.
We have logged all data from server interactions in
~/nohup.log
This data is quite comprehensive, but the data volume is large. We recommend researchers who want to develop their own evaluation metrics to find the information you need from here.
We have logged the input and output texts between Agents and large language models. They are stored in
~/logs/agent_name_prompt.txt
We also provide some general metrics built into our system. See 3-Task Instructions for details.