This repository contains fixes and improvements for the repository "generative_agents" that accompanies the paper "Generative Agents: Interactive Simulacra of Human Behavior."
Since the project is no longer officially supported, I decided to develop some new features:
- Easy configuration + Azure support
- Cost tracking using openai-cost-logger
- Set cost upperbound and stop the experiment when it is reached
- New models and OpenAI API support
- Added skip-morning-s-14: a simulation based on
base_the_ville_n25
that starts after 3000 steps (~8:00am). That permits us to save time and see interactions and actions earlier.
Do not change the env name to be able to use the bash scripts later.
conda create -n simulacra python=3.9.12 pip
conda activate simulacra
pip install -r requirements.txt
Create a file called openai_config.json
in the root directory.
Azure example:
{
"client": "azure",
"model": "gpt-35-turbo-0125",
"model-key": "<MODEL-KEY>",
"model-endpoint": "<MODEL-ENDPOINT>",
"model-api-version": "<API-VERSION>",
"model-costs": {
"input": 0.5,
"output": 1.5
},
"embeddings-client": "azure",
"embeddings": "text-embedding-3-small",
"embeddings-key": "<EMBEDDING-KEY>",
"embeddings-endpoint": "<EMBEDDING-MODEL-ENDPOINT>",
"embeddings-api-version": "<API-VERSION>",
"embeddings-costs": {
"input": 0.02,
"output": 0.0
},
"experiment-name": "simulacra-test",
"cost-upperbound": 10
}
OpenAI example:
{
"client": "openai",
"model": "gpt-3.5-turbo-0125",
"model-key": "<MODEL-KEY>",
"model-costs": {
"input": 0.5,
"output": 1.5
},
"embeddings-client": "openai",
"embeddings": "text-embedding-3-small",
"embeddings-key": "<EMBEDDING-KEY>",
"embeddings-costs": {
"input": 0.02,
"output": 0.0
},
"experiment-name": "simulacra-test",
"cost-upperbound": 10
}
Feel free to change and test also other models (and change accordingly the input and output costs).
Be aware that the only supported clients are azure and openai.
The generation and the embedding models are configured separately to be able to use different clients.
Change also the cost-upperbound
according to your needs (the cost computation is done using "openai-cost-logger" and the costs are specified per million tokens).
./run_frontend.sh
./run_backend.sh <ORIGIN> <TARGET>
Example:
./run_backend.sh base_the_ville_isabella_maria_klaus simulation-test
- http://localhost:8000/ - check if the server is running
- http://localhost:8000/simulator_home - watch the live simulation
http://localhost:8000/replay/<simulation-name>/<starting-time-step>
- replay a simulation
For a more detailed explanation see the original readme.
For the cost tracking is used the package "openai-cost-logger". Given the possible high cost of a simulation, you can set a cost upperbound in the config file to be able to raise an exception and stop the execution when it is reached.
See all the details of your expenses using the notebook "cost_viz.ipynb."
- Model: "gpt-3.5-turbo-0125"
- Embeddings: "text-embedding-3-small"
- N. Agents: 3
- Steps: ~5000
- Final Cost: ~0.31 USD
- See the simulation saved: skip-morning-s-14
- Model: "gpt-3.5-turbo-0125"
- Embeddings: "text-embedding-3-small"
- N. Agents: 25
- Steps: ~3000 (until ~8 a.m.)
- Final Cost: ~1.3 USD
- Model: "gpt-3.5-turbo-0125"
- Embeddings: "text-embedding-3-small"
- N. Agents: 25
- Steps: ~8650 (full day)
- Final Cost: ~18.5 USD
Although this repo contains numerous fixes, here are some problems that have not yet been resolved or new features I would like to add:
- joonspk-research#111: Still have to understand when it happens (in my case it happens after lots of steps like 4/5000) - screen
- joonspk-research#27: Add zoom in/out