Giter VIP home page Giter VIP logo

generative-agents's Introduction

Generative Agents ๐Ÿ”ฎ

A Simple Framework for working with Generative Agents powered by LLMs.

License: MITTwitter Follow

basic demo

What are Generative Agents? โšก๏ธ

These agents act as drop-in replacement for humans in online sandbox environments.

You can use them to:

  • simulate complex social behavior in a sandbox environment
  • create Dynamic NPCs for your games
  • create Autonomous Agents that acquire new skills while interacting with the environment like Minecraft

See it in the wild ๐Ÿช

basic demo We created a sandbox simulation based on the alpha version of the agent architecture. Check out the live demo.

Or check out the demo video on Youtube.

โš ๏ธ OpenAI APIs can be slow and unstable at times. Check the network tab to see if the requests are failing or getting rate-limited. We are currently working on a more stable solution.

Usage โš™๏ธ

We have started with a Typescript implementation of the agent architecture and plan to add more languages in the future.

You can create a sample agent with the following code:

import { Agent, AgentEngine } from "generative-agents";

// create an engine that manages the network requests and overall state of the world
const engine = new AgentEngine(openaiKey);

// create an agent
const agent = new Agent(
  engine,
  "thomas_miller", // agent id
  "Thomas Miller", // agent's name
  42, // agent's age
  {
    background:
      "Runs Taiki seafood restaurant with his wife Susan. Has a daughter Lucy and a son Mike.",
    currentGoal:
      "Creating a new speciality dish for restaurant and getting a new chef.",
    innateTendency: ["Curious", "Adventurous", "Optimistic"],
    learnedTendency: ["Hardworking", "Responsible", "Diligent"],
    lifestyle:
      "goes to work, comes home, spends time with family, goes to bed early",
    values: ["Family", "Honesty", "Integrity"],
  }
);

Once created the agent has following methods available:

// stream relevant observations to the agents to make the world believable
observe: (description: string) => Promise<void>;
// agents auto reflect on their observations and update their internal state after crossing certain thresholds
reflect: () => Promise<void>;
// at initialization agents create a plan for the day
createPlan(testing?: boolean): Promise<void>;
// execute the current task in the plan
executeCurrentTask: () => Promise<void>;
// agents can chat with each other and external users like humans
replyWithContext: (message: string, participants: string[]) => Promise<string>;

Repo structure ๐Ÿ“š

The repository is divided into two parts -

/core/[language]
/examples/[type]

/core contains the core implementation of the agent architecture. It is divided into language specific folders. Currently, we only have a Typescript implementation.

/examples contains examples of how to use the core implementation. Currently, we have an example of a React + Phaser implementation of the agent architecture in a 2d top down pixelart game.

We look forward to adding more examples in the future. Contributions are welcome!

Contributing ๐Ÿค ๐Ÿ’ช

Yes! We need you! The current implementation is experimental. If you are interested, we would love to plan the future of this project and build with you all. It will be interesting to see what we all can build with it.

Next up on the roadmap is to add more languages and examples. We are also working on a more stable solution for the OpenAI API. We also are planning to work on generic Minecraft agent that can acquire new skills while interacting with the environment. Help us build it!

Join the development on Discord.

If you have any ideas or suggestions, please open an issue or a pull request.

Twitter DMs open here.

We are so back! Let's build the matrix together!

Notice

For the ease of access, we have put our OpenAI key in the code. Hopefully, we will not see any abuse. If you are planning to use this code for your own project, we request you to create your own OpenAI key and use it instead.

generative-agents's People

Contributors

toughyear avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.