https://github.com/bigbuildbench/mluogh_eastworld

https://github.com/bigbuildbench/mluogh_eastworld

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.2%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: BigBuildBench
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Size: 4.77 MB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 1 year ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md

eastworld

💬 Get help on discord

eastworld is an open-source, language-agnostic framework for adding Generative Agents to your video games, visual novels, and other forms of interactive media.

This framework has two goals

  • To abstract away the complexities of prompt-engineering detailed Agents and elaborate Storylines using an easy to use no-code dashboard

  • To enable a variety of user-agent interactions out of the box beyond just chat - Agent Actions, Emotion Queries, Player Guardrails, etc. - and expose it in a simple small API

https://github.com/mluogh/eastworld/assets/8098155/6ed272f0-64d2-458e-bb8a-27a1e0741a9b

A playable murder mystery game whose Agents were made with eastworld

See how you can add an agent to your game in ~5 minutes

Features

Agents

  • Agents can perform user-defined actions, not just chat:
    • e.g. Player: "I'm going to attack you!" -> Agent: RunAway(speed=fast)
  • includes guardrails to ask players to stay in character
    • i.e. block players trying to jailbreak or from anachronistic behaviour like asking for a phone in a medieval game
  • query agent's inner thoughts and emotions mid-conversation
    • e.g. (to agent) "How suspicious are you that {player} suspects you as the murderer?" -> very
    • can trigger events in your game based off of this
  • set manner of speech, dialect, and accents
    • e.g. Peasant: "Just workin', yer Majesty. Fields ain't gonna plow 'emselves, are they?"
  • selective memory to cut down on LLM inference costs
    • i.e. vector embedding based retrieval of memories
  • and more!

Agent Studio

No-code tool to simplify Agent and Story prompt-engineering.

  • construct characters' biographies, core beliefs, dialects, etc
  • manage who knows which aspects of your world's Shared Lore to keep storylines consistent
  • define Actions (function completions) that Agents can take
  • use the chatbox with built-in debugging tools to quickly iterate on Agents

Server

NOTE: not prod ready yet - lacks client authentication

  • exposes OpenAPI spec so high quality clients can be autogenerated in any language
  • blazing fast with FastAPI and async LLM completions
  • supports local models out of the box with LocalAI
  • simple deploy - only requires redis

Installation

Prerequisites

The framework and server requires Python 3.10+, PDM package manager, and Redis.

The Agent Studio tool requires Node 19+.

MacOS

brew install redis pdm node

If later on you get SSL certification issues with OpenAI, see this

Linux

  1. Install Redis, if you don't already have it. Most distros should come with it.
  2. Install our package manager PDM
  3. Install Node

Windows

  1. Install Redis
  2. Install our package manager PDM
  3. Install Node for Windows

Install packages

Enter the repo and run:

pdm install

Install the frontend tooling:

cd app && npm install

Run

IMPORTANT: Copy the example configuration file to config.ini

In main folder:

cp example_config.ini config.ini

Set up your LLM

(Easier) Setting up an OpenAI model:

In config.ini, make sure the the following is set (especially the openai_api_key!):

``` [llm] uselocalllm = false openaiapikey = sk-myopenaikey

# Takes either {gpt-3.5-turbo, gpt-4} (or timestamped versions thereof) # gpt-3.5-turbo is enough to produce very believable characters # gpt-4 is amazing, but extremely expensive right now chat_model = gpt-3.5-turbo

# text-embedding-ada-002 embedding_size = 1536 ```

(Harder) To connect to a locally running model, see below.

Start

For the backend, in separate terminal windows, run:

redis-server

pdm run uvicorn server.main:app --reload

By default, the server runs on http://localhost:8000

For the Agent Studio tool:

cd app && npm start

This runs by default on http://localhost:8000

Play Example Game

We have an example game that you can play to get your bearings and see what the framework is capable of.

nob hill noir

Create

Creating games

There is a demo game included with the Agent Studio when you run it for the first time. You can look through it and mess around with it to understand the framework.

We recommend looking at this video to understand Agent Studio workflow.

Using agents in your games

  • Generate a client for your language. You can install OpenAPI generator or language-specific generator

    • The language specific ones seem to generate more idiomatic clients
    • e.g. We used this one for python, this one for TypeScript
    • point the generator to http://localhost:8000/openapi.json
  • Direct the client's to your server (during development this should be http://localhost:8000)

  • The core API consists of:

createSession() // call it to initiate an instance of the game startChat() // starts a new chat and clears old conversation chat() // Agent says something interact() // Agent may chat or perform an Action action() // ask Agent to perform an Action query() // emotional queries into Agent's inner thoughts guardrail() // make sure player respects tone/time period/etc of game

  • Read the more detailed Swagger documentation at http://localhost:8000/docs#/Game%20Sessions. The Game Sessions API is what you need for your game.

Coming Soon: SDKs for Game & Visual Novel Engines:

Have requests for one in particular? Ask in the discord

Misc

Contributing tips:

  • we use prettier and eslint for app/
  • we use ruff and black-formatter for python code
  • if you change a Pydantic schema, you need to cd app && npm run generate-client to reflect those changes in the frontend client.

Using local models:

Note that as of writing, agents are of much higher quality using GPT-3.5 or GPT-4 than any other model we tested.

``` [llm] uselocalllm = true openaiapikey = dummy_value

# I'm jealous of people with enough compute to run local models! chatmodel = mylocalmodelname embeddingsize = dimsofmyembedding_model ```

  • Restart the server to test it out!

Recipes

TypeScript

Using this generator for TypeScript.

```typescript // in app.tsx import { OpenAPI } from "client"; ... OpenAPI.BASE = "http://localhost:8000";

// in interact.tsx

const sessUuid = await GameSessionsService.createSession( params.gameUuid!, ); ... const emptyChat = { conversation: { correspondent: MyCharacter } , history: [] }; await GameSessionsService.startChat( sessionUuid!, params.agentUuid!, emptyChat, );

...

const interact = await GameSessionsService.interact( sessionUuid!, params.agentUuid!, text, );

if (isAction(interact)) { // Character.actions... } else { // render message } ```

Python

We used this generator for Python.

```python from game_client import Client

apiclient = Client(baseurl="http://localhost:8000")

...

sessionuuid = create.sync( gameuuid=gameuuid, client=apiclient )

...

response = chat.sync( sessionuuid=sessionuuid, client=client, agent="Agent Name", message=message )

do something with response

```

Owner

  • Name: BigBuildBench
  • Login: BigBuildBench
  • Kind: organization

abbr. B3, benchmarking the repo-level understanding capability of your LLMs by reconstructing project build-file.

GitHub Events

Total
  • Create event: 4
Last Year
  • Create event: 4

Dependencies

.github/workflows/main.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/setup-python v4 composite
  • chartboost/ruff-action v1 composite
  • jakebailey/pyright-action v1 composite
  • pdm-project/setup-pdm v3 composite
app/package-lock.json npm
  • 1434 dependencies
app/package.json npm
  • @babel/plugin-proposal-private-property-in-object ^7.21.11 development
  • eslint ^8.47.0 development
  • openapi-typescript-codegen ^0.25.0 development
  • prettier ^3.0.2 development
  • @chakra-ui/icons ^2.1.0
  • @chakra-ui/react ^2.8.0
  • @chatscope/chat-ui-kit-react ^1.10.1
  • @chatscope/chat-ui-kit-styles ^1.4.0
  • @emotion/react ^11.11.1
  • @emotion/styled ^11.11.0
  • @rjsf/chakra-ui ^5.12.0
  • @rjsf/core ^5.12.0
  • @rjsf/utils ^5.12.0
  • @rjsf/validator-ajv8 ^5.12.0
  • @testing-library/jest-dom ^5.17.0
  • @testing-library/react ^13.4.0
  • @testing-library/user-event ^13.5.0
  • @types/jest ^27.5.2
  • @types/node ^16.18.39
  • @types/react ^18.2.18
  • @types/react-dom ^18.2.7
  • axios ^1.4.0
  • chakra-react-select ^4.7.0
  • formik ^2.4.3
  • framer-motion ^10.15.0
  • http-proxy-middleware ^2.0.6
  • react ^18.2.0
  • react-dom ^18.2.0
  • react-router-dom ^6.14.2
  • react-scripts 5.0.1
  • sass ^1.64.2
  • styled-components ^6.0.7
  • typescript ^4.9.5
  • web-vitals ^2.1.4
  • yup ^1.2.0
pyproject.toml pypi