| title | emoji | colorFrom | colorTo | sdk | python_version | sdk_version | app_file | pinned | short_description | tags | |
|---|---|---|---|---|---|---|---|---|---|---|---|
Aware NPC chat |
💬💡 |
indigo |
gray |
gradio |
3.13 |
5.31.0 |
src/app.py |
false |
A chat interface with an NPC aware of the world it lives in |
|
I love roleplaying and AI Agent may bring a whole new experience to chatting in games.
I want to build an AI Agent system that takes allow NPCs (Non Player Characters) to talk with you according to their own knowledge of the world they live in.
-
Prerequisites:
- Build a knowledge base (characters, places, events, objects)
- Build a simple and effective chat interface
- Basic agents to retrieve useful information and converse
-
Iterate to improve quality:
- Improve the agent system, allow for personalization of the responses
- Provide a PersonalizedAgent over the CodeAgent and MultiStepAgent to allow more flexibility in initial state variables and system prompt templating
- Remarkable changes on the prompts to fit the thinking process of a character and not a robotic agent
- Integrate an emotional dimension into the responses
- Through the planning template
- Integrate a notion of willingness to answer
- Through the planning template
- Grade the level of accessible knowledge
- Improve the agent system, allow for personalization of the responses
-
Bonus, not everything can be done:
- Generate alternative images translating the character's emotions with each response
- An interface "behind the scenes of the chat," to visualize the work of the agents in the background
- Generalize the process of building the knowledge base
Requires Python 3.13 or higher.
Install steps, run refers to command lines in your terminal :
- Clone the GitHub project
- You might need to download Git LFS in order to access the static large files. Then run
git lfs installand finallygit lfs pull. - Create a virtual environment (recommended)
- Install
uvdependency manager e.g. runpip install pipxthenpipx install uvin a terminal - Run
uv syncthenuv pip install -e . - Set up your secrets (like HF_read_token), see example list in the
.example.envfile. - Run the app with
uv run src/app.py
Download the XML file of the Fandom website :
from knowledge_base.utils.downloader import download_file, fetch_page_content, get_xml_dump_url
from knowledge_base.utils.url import get_fandom_statistics_page_url
XML_PATH = r"....\asimov_fandom_dump.xml"
fandom_url = "https://asimov.fandom.com/wiki/"
statistics_url = get_fandom_statistics_page_url(fandom_url)
statistics_page_content = fetch_page_content(statistics_url)
xml_dump_url = get_xml_dump_url(statistics_page_content)
xml_file = download_file(xml_dump_url, output_path=XML_PATH)From xml dump to knowledge base :
from knowledge_base.models.knowledge_base import KnowledgeBase
from knowledge_base.parser.fandom.bridge_site_to_kb import populate_entities, populate_relationships
from knowledge_base.parser.fandom.parse_dump import fandom_xml_parse
XML_PATH = r"....\asimov_fandom_dump.xml" # <= Same as previous code blob
KB_PATH = r"....\kb_asimov.json"
fandom_site_content = fandom_xml_parse(XML_PATH)
kb = KnowledgeBase()
populate_entities(fandom_site_content, kb)
populate_relationships(fandom_site_content, kb)
kb.save_kb(KB_PATH, compress=True) # <= Compressing automatically add the .gz extension