I experimented with creating an intelligent conversational NPC powered by a large language model. It has a distinct character identity, responds to natural-language input from the user, and plays animations that match the emotion of its reply. The NPC also has a memory system: it can remember personal information about the user and answer accurately when asked about those specific details.
For this project, I built the backend with Python's FastAPI library and used LangChain to call the language model. Memories are stored in a local vector database. Unity serves as the frontend, handling user input and 3D rendering.
Below are some key code excerpts and demonstrations running in Unity:
Calling DeepSeek-V3.2 through its API.

The system prompt gives the language model its character identity.

Building the local vector database with ChromaDB.

The system prompt strictly requires the model to include an "emotion tag" with every response. The C# code in Unity reads this tag and plays the corresponding animation.
The Unity Animator.

The Unity frontend code.

Demonstration.

Testing the memory system.
