Author: Andrew Zhu (andrz@seas.upenn.edu)
In this homework, we’ll use Kani to build a simple Game Master (GM) for the Mausritter TTRPG. Your GM will help walk you through creating a mouse and rolling dice to overcome challenges in the game. Along the way, you’ll learn the basics of the Kani library, function calling with LLMs, and how a LLM can use structured information to act as a game state manager.
We won’t implement more complex systems like combat or spellcasting in this homework, but extending this system to make a more comprehensive GM (e.g. adding inventory tracking, combat, spellcasting, structured tracking of NPCs, …) would make for a great class final project.
This assignment will have 3 main parts:
We have provided a Python Notebook for HW4. I recommend using Visual Studio Code
for this homework. You’ll be making changes to the HW4.ipynb
file. You should read through the whole Python Notebook
carefully, and add your code to all places marked TODO.
To run this code in your Python IDE, you’ll need to install a couple python packages via pip
, and you’ll need to set
the OPENAI_API_KEY
environment variable to your Helicone key.
First download the notebook, then create a virtual environment and install the dependencies. Here’s how I recommend that you set up your environment:
$ mkdir hw4
$ cd hw4
$ python3.10 -m venv venv
$ source venv/bin/activate
(venv) $ pip install jupyter 'kani[openai]' d20
If you’re using VS code then you can send your OPENAI_API_KEY to it when you launch it from the command line:
$ cd path/to/hw4
$ source venv/bin/activate
(venv) $ HELICONE_API_KEY=sk-helicone-XXXXXXX-XXXXXX code .
You should replace sk-helicone-XXXXXXX-XXXXXX
with your Helicone key which you can
find here.
Please submit the following:
hw4.ipynb
creator-TIME.json
, gm-TIME.json
,
and gm-structureless-TIME.json
dalle/
folder)README.md
that describes your high-level implementation of each part of the homework and any interesting findingsYou should submit your completed homework to Gradescope. You can work in teams. Only one team member should submit - be sure to specify who your partner was when you make your submission. If your group is >2 students, you should do one extension per additional teammate and describe what you did in the homework writeup. The extensions are up to you!
Kani: A Lightweight and Highly Hackable Framework for Building Language Model Applications - Andrew Zhu, Liam Dugan, Alyssa Hwang, Chris Callison-Burch. NLP-OSS @ EMNLP 2024. |