{"id":13711828,"url":"https://github.com/mluogh/eastworld","last_synced_at":"2025-05-06T21:32:26.922Z","repository":{"id":190414185,"uuid":"682570540","full_name":"mluogh/eastworld","owner":"mluogh","description":"Framework for Generative Agents in Games","archived":false,"fork":false,"pushed_at":"2023-11-13T13:40:26.000Z","size":5164,"stargazers_count":196,"open_issues_count":1,"forks_count":17,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-11-13T22:35:05.168Z","etag":null,"topics":["generative-agents"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mluogh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-24T13:06:29.000Z","updated_at":"2024-11-06T02:52:12.000Z","dependencies_parsed_at":"2024-11-14T00:15:16.690Z","dependency_job_id":null,"html_url":"https://github.com/mluogh/eastworld","commit_stats":null,"previous_names":["mluogh/eastworld"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mluogh%2Feastworld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mluogh%2Feastworld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mluogh%2Feastworld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mluogh%2Feastworld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mluogh","download_url":"https://codeload.github.com/mluogh/eastworld/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252772161,"owners_count":21801865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generative-agents"],"created_at":"2024-08-02T23:01:12.055Z","updated_at":"2025-05-06T21:32:24.602Z","avatar_url":"https://github.com/mluogh.png","language":"Python","funding_links":[],"categories":["AI NPC","Python"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  eastworld\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://discord.gg/9V5URE9f4T\"\u003e💬 Get help on discord\u003c/a\u003e\n\u003c/p\u003e\n\neastworld is an open-source, language-agnostic framework for adding Generative\nAgents to your video games, visual novels, and other forms of interactive media.\n\nThis framework has two goals\n\n- To abstract away the complexities of prompt-engineering detailed Agents and\n  elaborate Storylines using an easy to use no-code dashboard\n\n- To enable a variety of user-agent interactions out of the box beyond just\n  chat - Agent Actions, Emotion Queries, Player Guardrails, etc. - and expose it\n  in a simple small API\n\nhttps://github.com/mluogh/eastworld/assets/8098155/6ed272f0-64d2-458e-bb8a-27a1e0741a9b\n\n\u003cfigcaption align=\"center\"\u003e\n  \u003cp align=\"center\"\u003e\u003ci\u003eA \n    \u003ca href=\"https://github.com/mluogh/grontown\"\u003eplayable\u003c/a\u003e murder mystery game whose Agents were made with eastworld\u003c/i\u003e\n  \u003c/p\u003e\n\u003c/figcaption\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.youtube.com/watch?feature=player_embedded\u0026v=VSqIzjOk5p4\" target=\"_blank\"\u003e\n    \u003ci\u003eSee how you can add an agent to your game in ~5 minutes\u003c/i\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# Features\n\n### Agents\n\n- Agents can perform user-defined actions, not just chat:\n  - e.g. Player: \"I'm going to attack you!\" -\u003e Agent: RunAway(speed=fast)\n- includes guardrails to ask players to stay in character\n  - i.e. block players trying to jailbreak or from anachronistic behaviour like\n    asking for a phone in a medieval game\n- query agent's inner thoughts and emotions mid-conversation\n  - e.g. (to agent) \"How suspicious are you that {player} suspects you as the\n    murderer?\" -\u003e very\n    - can trigger events in your game based off of this\n- set manner of speech, dialect, and accents\n  - e.g. Peasant: \"Just workin', yer Majesty. Fields ain't gonna plow 'emselves,\n    are they?\"\n- selective memory to cut down on LLM inference costs\n  - i.e. vector embedding based retrieval of memories\n- and more!\n\n### Agent Studio\n\nNo-code tool to simplify Agent and Story prompt-engineering.\n\n- construct characters' biographies, core beliefs, dialects, etc\n- manage who knows which aspects of your world's Shared Lore to keep storylines\n  consistent\n- define Actions (function completions) that Agents can take\n- use the chatbox with built-in debugging tools to quickly iterate on Agents\n\n### Server\n\nNOTE: _not prod ready yet - lacks client authentication_\n\n- exposes OpenAPI spec so **high quality clients can be autogenerated in any\n  language**\n- blazing fast with [FastAPI](https://github.com/tiangolo/fastapi) and async LLM\n  completions\n- supports local models out of the box with\n  [LocalAI](https://github.com/go-skynet/LocalAI)\n- simple deploy - only requires redis\n\n# Installation\n\n## Prerequisites\n\nThe framework and server requires Python 3.10+,\n[PDM package manager](https://github.com/pdm-project/pdm), and Redis.\n\nThe Agent Studio tool requires Node 19+.\n\n##### MacOS\n\n```\nbrew install redis pdm node\n```\n\nIf later on you get SSL certification issues with OpenAI, see\n[this](https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error)\n\n### Linux\n\n1. [Install Redis](https://redis.io/docs/getting-started/installation/install-redis-on-linux/),\n   if you don't already have it. Most distros should come with it.\n2. Install our [package manager PDM](https://pdm.fming.dev/latest/)\n3. Install\n   [Node](https://nodejs.org/en/download/package-manager#debian-and-ubuntu-based-linux-distributions)\n\n### Windows\n\n1. [Install Redis](https://redis.io/docs/getting-started/installation/install-redis-on-windows/)\n2. Install our [package manager PDM](https://pdm.fming.dev/latest/)\n3. Install\n   [Node for Windows](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#windows-node-version-managers)\n\n## Install packages\n\nEnter the repo and run:\n\n```\npdm install\n```\n\nInstall the frontend tooling:\n\n```\ncd app \u0026\u0026 npm install\n```\n\n# Run\n\n**IMPORTANT: Copy the example configuration file to config.ini**\n\nIn main folder:\n\n```\ncp example_config.ini config.ini\n```\n\n### Set up your LLM\n\n_(Easier)_ Setting up an OpenAI model:\n\nIn `config.ini`, make sure the the following is set (especially the\n`openai_api_key`!):\n\n```\n  [llm]\n  use_local_llm = false\n  openai_api_key = sk-my_openai_key\n\n  # Takes either {gpt-3.5-turbo, gpt-4} (or timestamped versions thereof)\n  # gpt-3.5-turbo is enough to produce very believable characters\n  # gpt-4 is amazing, but extremely expensive right now\n  chat_model = gpt-3.5-turbo\n\n  # text-embedding-ada-002\n  embedding_size = 1536\n```\n\n_(Harder)_ To connect to a locally running model,\n[see below](#using-local-models).\n\n## Start\n\nFor the backend, in separate terminal windows, run:\n\n```\nredis-server\n```\n\n```\npdm run uvicorn server.main:app --reload\n```\n\nBy default, the server runs on `http://localhost:8000`\n\nFor the Agent Studio tool:\n\n```\ncd app \u0026\u0026 npm start\n```\n\nThis runs by default on `http://localhost:8000`\n\n# Play Example Game\n\nWe have an example game that you can play to get your bearings and see what the\nframework is capable of.\n\n[nob hill noir](https://github.com/mluogh/grontown)\n\n# Create\n\n### Creating games\n\nThere is a demo game included with the Agent Studio when you run it for the\nfirst time. You can look through it and mess around with it to understand the\nframework.\n\nWe recommend looking at\n[this video](https://www.youtube.com/watch?v=VSqIzjOk5p4) to understand Agent\nStudio workflow.\n\n### Using agents in your games\n\n- Generate a client for your language. You can\n  [install OpenAPI generator](https://github.com/OpenAPITools/openapi-generator)\n  or language-specific generator\n\n  - The language specific ones seem to generate more idiomatic clients\n    - e.g. We used\n      [this one](https://github.com/openapi-generators/openapi-python-client)\n      for python,\n      [this one](https://github.com/ferdikoomen/openapi-typescript-codegen) for\n      TypeScript\n  - point the generator to `http://localhost:8000/openapi.json`\n\n- Direct the client's to your server (during development this should be\n  `http://localhost:8000`)\n\n- The core API consists of:\n\n```\n  createSession() // call it to initiate an instance of the game\n  startChat() // starts a new chat and clears old conversation\n  chat() // Agent says something\n  interact() // Agent may chat or perform an Action\n  action() // ask Agent to perform an Action\n  query() // emotional queries into Agent's inner thoughts\n  guardrail() // make sure player respects tone/time period/etc of game\n```\n\n- Read the more detailed Swagger documentation at\n  http://localhost:8000/docs#/Game%20Sessions. The `Game Sessions` API is what\n  you need for your game.\n  - See [Recipes](#recipes) for examples.\n\n### Coming Soon: SDKs for Game \u0026 Visual Novel Engines:\n\nHave requests for one in particular? Ask in\n[the discord](https://discord.gg/9V5URE9f4T)\n\n# Misc\n\n### Contributing tips:\n\n- we use prettier and eslint for `app/`\n- we use ruff and black-formatter for python code\n- if you change a Pydantic schema, you need to\n  `cd app \u0026\u0026 npm run generate-client` to reflect those changes in the frontend\n  client.\n\n### Using local models:\n\nNote that as of writing, agents are of much higher quality using GPT-3.5 or\nGPT-4 than any other model we tested.\n\n- Install\n  [docker-compose (recommended)](https://docs.docker.com/compose/install) or\n  [docker](https://docs.docker.com/engine/install)\n\n- [Install LocalAI](https://localai.io/basics/getting_started) and follow the\n  instructions\n\n- You will need two models that are\n  [compatible with LocalAI](https://localai.io/model-compatibility/). Most GGML\n  models are compatible. If you want Agents to take actions, you need a\n  [function-calling compatible model](https://localai.io/features/openai-functions/index.html)\n\n  - you need a chat-tuned LLM - e.g.\n    [WizardLM 13b uncensored](https://huggingface.co/TheBloke/Wizard-Vicuna-13B-Uncensored-GGML)\n  - you need an [embedding model](https://localai.io/features/embeddings) -\n    follow the guide to create a config\n    - NOTE: follow the instructions to set `name: text-embedding-ada-002`.\n\n- Change `config.ini`\n\n```\n  [llm]\n  use_local_llm = true\n  openai_api_key = dummy_value\n\n  # I'm jealous of people with enough compute to run local models!\n  chat_model = my_local_model_name\n  embedding_size = dims_of_my_embedding_model\n```\n\n- Restart the server to test it out!\n\n### Recipes\n\n#### TypeScript\n\nUsing\n[this generator](https://github.com/ferdikoomen/openapi-typescript-codegen) for\nTypeScript.\n\n```typescript\n// in app.tsx\nimport { OpenAPI } from \"client\";\n...\nOpenAPI.BASE = \"http://localhost:8000\";\n\n// in interact.tsx\n\nconst sessUuid = await GameSessionsService.createSession(\n  params.gameUuid!,\n);\n...\nconst emptyChat = { conversation: { correspondent: MyCharacter } , history: [] };\nawait GameSessionsService.startChat(\n  sessionUuid!,\n  params.agentUuid!,\n  emptyChat,\n);\n\n...\n\nconst interact = await GameSessionsService.interact(\n  sessionUuid!,\n  params.agentUuid!,\n  text,\n);\n\nif (isAction(interact)) {\n  // Character.actions[...]()\n} else {\n  // render message\n}\n```\n\n#### Python\n\nWe used\n[this generator](https://github.com/openapi-generators/openapi-python-client)\nfor Python.\n\n```python\nfrom game_client import Client\n\napi_client = Client(base_url=\"http://localhost:8000\")\n\n# ...\n\nsession_uuid = create.sync(\n    game_uuid=game_uuid,\n    client=api_client\n)\n\n# ...\n\nresponse = chat.sync(\n            session_uuid=session_uuid,\n            client=client,\n            agent=\"Agent Name\",\n            message=message\n        )\n\n# do something with response\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmluogh%2Feastworld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmluogh%2Feastworld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmluogh%2Feastworld/lists"}