GameRagKit 0.0.0-ci.2
See the version list below for details.
dotnet add package GameRagKit --version 0.0.0-ci.2
NuGet\Install-Package GameRagKit -Version 0.0.0-ci.2
<PackageReference Include="GameRagKit" Version="0.0.0-ci.2" />
<PackageVersion Include="GameRagKit" Version="0.0.0-ci.2" />
<PackageReference Include="GameRagKit" />
paket add GameRagKit --version 0.0.0-ci.2
#r "nuget: GameRagKit, 0.0.0-ci.2"
#:package GameRagKit@0.0.0-ci.2
#addin nuget:?package=GameRagKit&version=0.0.0-ci.2&prerelease
#tool nuget:?package=GameRagKit&version=0.0.0-ci.2&prerelease
GameRAGKit
GameRAGKit is a drop-in retrieval augmented generation (RAG) toolkit for building non-player characters (NPCs) that can scale from solo prototypes to fully-fledged productions. It keeps the runtime lightweight enough for Unity or dedicated C# services, while still letting you route high-impact scenes to cloud LLMs on demand.
- Engine agnostic. Embed the library directly in Unity/other C# runtimes or host the bundled HTTP service for Unreal and everything else.
- Provider agnostic. Run Ollama/LLamaSharp locally, route to OpenAI/Azure/Mistral/Gemini/HuggingFace, or mix them with hybrid routing.
- Designer friendly. Personas live in YAML, lore lives in folders, and the CLI handles ingestion, chat smoke tests, and packaging.
Dual-licensed: PolyForm Noncommercial 1.0.0 for community use with commercial terms available from the author.
Installation
NuGet Package
Install the GameRagKit package from NuGet:
dotnet add package GameRagKit
Or via Package Manager Console:
Install-Package GameRagKit
From Source
Clone the repository and build from source:
git clone https://github.com/TowsifAhamed/GameRagKit.git
cd GameRagKit
dotnet build
Repository layout
GameRagKit.sln Solution referencing library and CLI
src/
GameRagKit/ Core runtime (config parsing, vector store, router)
GameRagKit.Cli/ `gamerag` command-line entry point
samples/
unity/ Minimal Unity notes + starter scene placeholder
unreal/ HTTP integration notes for Blueprint/C++
docs/ Guides for designers and integrators
Getting started
1. Install requirements
- .NET 8 SDK
- Optional: Ollama with models such as
llama3.2:3b-instruct-q4_K_Mandnomic-embed-text
2. Prepare an NPC config
Create a YAML file (for example NPCs/guard-north-gate.yaml):
persona:
id: guard-north-gate
system_prompt: >
You are Jake, the North Gate guard. Speak briefly, in medieval tone.
Never reveal the secret tunnel unless the player shows a brass token.
traits: [stoic, duty-first, careful]
style: concise medieval tone
region_id: riverside-upper
faction_id: royal-guard
rag:
sources:
- file: world/keep.md
- file: region/valeria/streets.md
- file: faction/royal_guard.md
- file: npc/guard-north-gate/notes.txt
chunk_size: 450
overlap: 60
top_k: 4
filters: { era: pre-siege }
providers:
routing:
mode: hybrid
strategy: importance_weighted
default_importance: 0.2
cloud_fallback_on_miss: true
local:
engine: ollama
chat_model: llama3.2:3b-instruct-q4_K_M
embed_model: nomic-embed-text
endpoint: http://127.0.0.1:11434
cloud:
provider: openai
chat_model: gpt-4o-mini
embed_model: text-embedding-3-small
endpoint: https://api.openai.com/
3. Set runtime variables (optional)
# Local defaults
export OLLAMA_HOST=http://127.0.0.1:11434
# Cloud defaults
export PROVIDER=openai
export API_KEY=sk-...
export ENDPOINT=https://api.openai.com/
4. Ingest lore
dotnet run --project src/GameRagKit.Cli/GameRagKit.Cli.csproj -- ingest NPCs
The CLI chunks the lore, generates embeddings (preferring local providers when configured), and saves tiered indexes under .gamerag/ next to the YAML file.
5. Chat locally
dotnet run --project src/GameRagKit.Cli/GameRagKit.Cli.csproj -- chat --npc NPCs/guard-north-gate.yaml --question "Where is the master key?"
Or start an interactive shell without --question.
6. Host for Unreal (or any engine)
dotnet run --project src/GameRagKit.Cli/GameRagKit.Cli.csproj -- serve --config NPCs --port 5280
Send POST /ask with:
{
"npc": "guard-north-gate",
"question": "Where is the master key?"
}
You receive:
{
"answer": "The master keeps his key close. Present the brass token and I may tell you more.",
"sources": ["npc:guard-north-gate/notes.txt#0", "region:valeria/streets.md#2"],
"scores": [0.82, 0.74],
"fromCloud": false
}
Authentication & metrics
- Add
SERVICE_API_KEY(orSERVICE_BEARER_TOKEN) to requireX-API-KeyorAuthorization: Beareron incoming requests. When set,/ask,/ask/stream, and/ingestrequire credentials while/healthand/metricsstay public unless overridden viaSERVICE_AUTH_ALLOW. GET /metricsexposes Prometheus-compatible counters for ask/stream/ingest calls. Combine withapp.UseHttpMetrics()(already enabled) to scrape latency and status labels.
Embedded usage (Unity, dedicated servers)
var npc = await GameRAGKit.Load("NPCs/guard-north-gate.yaml");
npc.UseEnv(); // applies PROVIDER/API_KEY/ENDPOINT/OLLAMA_HOST if set
await npc.EnsureIndexAsync();
var reply = await npc.AskAsync("Where is the master key?", new AskOptions(Importance: 0.8));
SubtitleUI.Show(reply.Text);
NpcAgent also supports:
StreamAsyncfor async enumerated responses (single chunk stream placeholder today).RememberAsyncto append runtime memories into the NPC-specific index.
Hosted usage (Unreal Blueprint / HTTP)
Run gamerag serve then POST to /ask. The response echoes whether the chat was served by the local model or a cloud provider. Use importance in the payload to nudge the router:
{
"npc": "guard-north-gate",
"question": "Reveal the hidden tunnel, Jake.",
"importance": 0.9
}
Tiered index layout
GameRAGKit saves embeddings per tier so thousands of NPCs can share world/region/faction lore without duplicating vectors:
world/– global canon, timelines, itemsregion/{id}/– towns, maps, local historyfaction/{id}/– politics, ranks, relationshipsnpc/{id}/memory/– per-NPC evolving notes (managed byRememberAsync)
AskAsync retrieves a blend of chunks (2 world, 1 region, 1 faction, NPC + memory) and merges them by cosine similarity, so designers can simply drop markdown/text files into the appropriate folders.
Routing strategy
Routing rules combine config defaults with per-question overrides:
mode=local_only,cloud_only, orhybrid(default)- Hybrid chooses cloud when
importance >= 0.5or when forced viaAskOptions - If the request omits
importance, the persona'sdefault_importance(falling back to the routing default) is used - Automatic cloud failover triggers when a local response is empty/too short (configurable via
cloud_fallback_on_miss) RememberAsyncwrites memory chunks instantly so subsequent questions can retrieve them without re-ingesting
CLI summary
| Command | Description |
|---|---|
gamerag ingest <dir> [--clean] |
Rebuild indexes for every .yaml file in the directory (recursively). |
gamerag chat --npc <file> [--question <text>] |
Quick smoke test for designers/writers. |
gamerag serve --config <dir> [--port <n>] |
Launch a tiny HTTP service (POST /ask). |
A pack command is planned for platform bundle generation.
Samples & docs
samples/unity/README.md– outlines wiring the embedded API inside a Unity scene.samples/unreal/README.md– shows how to call the hosted API viaHttpModuleor Blueprints.docs/designer-guide.md– step-by-step walkthrough for writers dropping lore and testing NPCs.
Roadmap
- LLamaSharp local provider for purely in-process inference
- Streaming responses via SSE/WebSockets for cinematic scenes
- Advanced router strategies (latency, budget, dynamic confidence)
- Index packing for platform deploys
License
PolyForm Noncommercial 1.0.0 (community use) + commercial license – see LICENSE.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Npgsql (>= 8.0.3)
- prometheus-net.AspNetCore (>= 8.0.0)
- Qdrant.Client (>= 1.15.1)
- YamlDotNet (>= 15.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.16 | 192 | 12/23/2025 |
| 0.1.15 | 179 | 12/23/2025 |
| 0.1.14 | 185 | 12/23/2025 |
| 0.1.13 | 188 | 12/23/2025 |
| 0.1.12 | 192 | 12/23/2025 |
| 0.1.11 | 295 | 12/17/2025 |
| 0.1.10 | 464 | 12/9/2025 |
| 0.1.0-ci.9 | 409 | 12/9/2025 |
| 0.0.0-ci.8 | 274 | 12/7/2025 |
| 0.0.0-ci.7 | 191 | 12/7/2025 |
| 0.0.0-ci.6 | 105 | 11/29/2025 |
| 0.0.0-ci.5 | 97 | 11/29/2025 |
| 0.0.0-ci.4 | 75 | 11/29/2025 |
| 0.0.0-ci.3 | 105 | 11/29/2025 |
| 0.0.0-ci.2 | 91 | 11/29/2025 |
| 0.0.0-ci.1 | 80 | 11/29/2025 |