Skip to content

Commit

Permalink
Merge branch 'main' into show-agent-info
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefeu authored Apr 1, 2024
2 parents 3512254 + ad5e14e commit f410c5a
Show file tree
Hide file tree
Showing 28 changed files with 1,024 additions and 419 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,18 @@ When working on the main engine, often times we can shut off all llm calls, in
* make all cognitive modules flags work on a user basis
* normalize flag names
* hybrid fast llm action / continue to destination and only act when needed
* maybe make it gym compatible


# changes over time

* moving objects
* tool usage
weapons
move refrigerator
door open/close/lock

* scribblenauts style object interactions
* information spreading
* building stuff
* people dead/people born
Expand All @@ -231,5 +239,3 @@ When working on the main engine, often times we can shut off all llm calls, in
* things getting destroyed
* discover actions
* environmental changes


87 changes: 87 additions & 0 deletions configs/bus_stop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"background": "Six agents gather outside at a bus stop to chat with each other. They talk about their interests and anything they come up with.",
"actions_blacklist": [ "move" ],
"agents": [
{
"name": "Natasha",
"description": "Natasha is friendly, outgoing, and effortlessly strikes up conversations. She likes to talk.",
"goal": "Natasha wants to talk about her recent experience with love. She wants to ask the opinions of other agents regarding the relationship. She is also concerned of the other agents and asks them if they are doing good. She talks about anything with the other agents..",
"connections": [
"Sherlock",
"Viktor",
"Lily",
"James"
],
"x": 25,
"y": 10
},
{
"name": "James",
"description": "James is shy, reserved, and observes from the sidelines.",
"goal": "James joins the conversation and shares his special skills and hidden talent in singing. He talks about his favorite songs and music genre. He also asks the other agents about their taste in music. He talks about anything with the other agents.",
"connections": [
"Sherlock",
"Viktor",
"Lily",
"Natasha"
],
"x": 25,
"y": 15
},
{
"name": "Sherlock",
"description": "Sherlock is funny, lighthearted, and turns moments into laughter. He is quick-witted and charming.",
"goal": "Sherlock tells a joke everytime he gets the chance to. He loves making everyone happy by being silly. He also shares some of his embarassing moments and also asks the other agents about their funny moments. He talks about anything with the other agents.",
"connections": [
"Natasha",
"Viktor",
"James",
"Paul"
],
"x": 25,
"y": 20
},
{
"name": "Viktor",
"description": "Viktor likes to take photographs and capture moments. He likes to share his collection of memories from pictures. He likes engaging in a conversation.",
"goal": "Viktor tells the other agents about his love of photography and capturing random sweet moments. He also willingly participates in every conversation with the other agents. He talks about anything with the other agents.",
"connections": [
"James",
"Natasha",
"Sherlock",
"Paul"
],
"x": 25,
"y": 25
},
{
"name": "Lily",
"description": "Lily likes to cook and eat delicious foods. She likes sweets the most. She is friendly and talkative.",
"goal": "Lily talks about her interest in cooking and eating sweet foods. She shares some of her favorite recipes and experience cooking them. She also asks the other agents about their favorite foods. She talks about anything with the other agents.",
"connections": [
"Natasha",
"Viktor",
"Sherlock",
"Paul"
],
"x": 25,
"y": 30
},
{
"name": "Paul",
"description": "Paul likes to read books especially poems. He is great at words and He is also quick witted.",
"goal": "Paul wants to tell the other agents about his favorite books and poems. He shares his some of the lines of poem he likes. He also tells a silly joke when he has a chance. He talks about anything with the other agents.",
"connections": [
"Natasha",
"Viktor",
"James",
"Lily"
],
"x": 25,
"y": 35
}
],
"steps": 50,
"allow_movement": 0,
"perception_range": 50
}
65 changes: 65 additions & 0 deletions daemon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import os
import redis
import json
import requests
from dotenv import load_dotenv
from engine import Matrix

load_dotenv()

REDIS_URL = os.getenv('REDIS_URL', 'redis://localhost:6379')
QUEUE_NAME = os.getenv('QUEUE_NAME', 'simulation_jobs')
DISCORD_URL = os.getenv('DISCORD_URL')

# Connect to Redis
redis_conn = redis.from_url(REDIS_URL)

def notify_discord(msg):
if DISCORD_URL:
requests.post(DISCORD_URL,json={'content':msg})

# get this out of here or refactor with engine
def update_from_env(config):
for key, value in config.items():
env_var = os.getenv(key)
if env_var is not None:
# Update the value from the environment variable
config[key] = type(value)(env_var) if value is not None else env_var
return config

def load_config():
filename = "configs/defaults.json"
with open(filename, 'r') as file:
config = json.load(file)
config = update_from_env(config)
return config

def process_simulation(data):
config = load_config()
config['scenario'] = data
config['environment'] = "configs/largev2.tmj"
notify_discord(f"starting simulation: #{config}")
matrix = Matrix(config)
matrix.boot()
matrix.run_singlethread()
notify_discord(f"finished simulation: #{config}")


print(f'Simulation {simulation_id} completed.')

def main():
print('Starting simulation job daemon...')
while True:
# Fetch a job from the Redis queue
_, job = redis_conn.blpop(QUEUE_NAME)
job_data = json.loads(job)

# Process the simulation
try:
process_simulation(job_data)
except Exception as e:
print(f'Error processing simulation: {e}')

if __name__ == '__main__':
main()

9 changes: 0 additions & 9 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,8 @@ def main():
if args.id:
config['id'] = args.id
matrix = Matrix(config)

# matrix.send_matrix_to_redis()

pd(f"model:#{MODEL}")
pd("Initial Agents Positions:")
#redis_connection.set(f"{matrix.id}:matrix_state", json.dumps(matrix.get_arr_2D()))

# Clear convos
#matrix.clear_redis()

# Run
start_time = datetime.now()
Expand All @@ -67,7 +60,6 @@ def main():

# Log Runtime
matrix.simulation_runtime = end_time - start_time
matrix.send_matrix_to_redis()

# Save the environment state to a file for inspection
if matrix.id is not None and matrix.id != '' and RUN_REPORTS != 0:
Expand All @@ -91,7 +83,6 @@ def signal_handler(signum, frame):
pd("stopping matrix, please wait for current step to finish")
pd("*"*50)
matrix.status = "stop"
matrix.send_matrix_to_redis()
last_interrupt_time = current_time

ctrl_c_count = 0
Expand Down
99 changes: 0 additions & 99 deletions frontend.py

This file was deleted.

6 changes: 3 additions & 3 deletions prompts/general/summarize_conversation.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Your name is {{agent}}
You are talking with {{other_agent}}
You just spoke with {{other_agent}}

{{conversation_string}}

Summarize the conversation above in {{agent}}'s point of view.
List all important outcomes of the conversation:
Summarize the conversation in the first person point of view as {{agent}}.
Write it as a thought {{agent}} says to theirselves.
15 changes: 6 additions & 9 deletions prompts/general/talk.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
roleplay as {{agent}}
{{selfContext}}
{{relevant_memories}}
roleplay as {{agent}} talking to {% if other_agent == "stranger" %} a stranger you know nothing about. {% else %} {{other_agent}} {% endif %}


{% if other_agent == "stranger" %}
This is your first time talking to this stranger.
{{selfContext}}
{{agent}}'s previous memories:
{{relevant_memories}}

{% else %}

{% if primer %}
{% if other_agent != "stranger" and primer %}
prime your thoughts but dont mention: "{{primer}}".
{% endif %}

{{selfContext}}
Below is the current chat history between {{agent}} and {{other_agent}}.

{{previous_conversations}}
Expand Down Expand Up @@ -41,5 +37,6 @@ Maybe you could discuss the topic of "{{topic}}"

keep responses to under 3 sentences.
Craft an informal spoken response.
Do not discuss topics for things that you don't perceive or are not in your recent memories.
Only write the response from {{agent}} and nothing else.

3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ python-Levenshtein
jsonlines
nltk
Pillow
groq
sshtunnel
psycopg2
Loading

0 comments on commit f410c5a

Please sign in to comment.