Views
No views yet
say <player1> "Hello Adventurer, care to join me on a quest?greet <player1>attack <player1><action> <param> you add to the prompt! (We call these "skills"!)1from outlines import models
2from gigax.step import NPCStepper
3from llama_cpp import Llama
4
5# Download model from the Hugging Face Gigax Hub before run this code
6
7# Our stepper takes in a Outlines model to enable guided generation
8# This forces the model to follow our output format
9llm = Llama.from_pretrained(
10 repo_id="Gigax/NPC-LLM-3_8B-GGUF",
11 filename="npc-llm-3_8B.gguf"
12 # n_gpu_layers=-1, # Uncomment to use GPU acceleration
13 # seed=1337, # Uncomment to set a specific seed
14 # n_ctx=2048, # Uncomment to increase the context window
15)
16
17model = models.LlamaCpp(llm)
18
19
20# Instantiate a stepper: handles prompting + output parsing
21stepper = NPCStepper(model=model)1from gigax.parse import CharacterAction
2from gigax.scene import (
3 Character,
4 Item,
5 Location,
6 ProtagonistCharacter,
7 ProtagonistCharacter,
8 Skill,
9 ParameterType,
10)
11
12# Use sample data
13context = "Medieval world"
14current_location = Location(name="Old Town", description="A quiet and peaceful town.")
15locations = [current_location] # you can add more locations to the scene
16NPCs = [
17 Character(
18 name="John the Brave",
19 description="A fearless warrior",
20 current_location=current_location,
21 )
22]
23protagonist = ProtagonistCharacter(
24 name="Aldren",
25 description="Brave and curious",
26 current_location=current_location,
27 memories=["Saved the village", "Lost a friend"],
28 quests=["Find the ancient artifact", "Defeat the evil warlock"],
29 skills=[
30 Skill(
31 name="Attack",
32 description="Deliver a powerful blow",
33 parameter_types=[ParameterType.character],
34 )
35 ],
36 psychological_profile="Determined and compassionate",
37)
38items = [Item(name="Sword", description="A sharp blade")]
39events = [
40 CharacterAction(
41 command="Say",
42 protagonist=protagonist,
43 parameters=[items[0], "What a fine sword!"],
44 )
45]
46
47action = stepper.get_action(
48 context=context,
49 locations=locations,
50 NPCs=NPCs,
51 protagonist=protagonist,
52 items=items,
53 events=events,
54)1- WORLD KNOWLEDGE: A vast open world full of mystery and adventure.
2- KNOWN LOCATIONS: Old Town
3- NPCS: John the Brave
4- CURRENT LOCATION: Old Town: A quiet and peaceful town.
5- CURRENT LOCATION ITEMS: Sword
6- LAST EVENTS:
7Aldren: Say Sword What a fine sword!
8- PROTAGONIST NAME: Aldren
9- PROTAGONIST PSYCHOLOGICAL PROFILE: Brave and curious
10- PROTAGONIST MEMORIES:
11Saved the village
12Lost a friend
13- PROTAGONIST PENDING QUESTS:
14Find the ancient artifact
15Defeat the evil warlock
16- PROTAGONIST ALLOWED ACTIONS:
17Attack <character> : Deliver a powerful blow
18Aldren:1@misc{NPC-LLM-3_8B-GGUF,
2 url={[https://huggingface.co/Gigax/NPC-LLM-3_8B-GGUF-](https://huggingface.co/Gigax/NPC-LLM-3_8B-GGUF)},
3 title={NPC-LLM-3_8B-GGUF},
4 author={Gigax team}
5}