I want to create a GPT that can edit a document, but I have no idea how.
The goal is to have the user interact with the GPT, then the GPT updates the document, adding some information to its long-term memory.
For example, if I’m making a text-based RPG game, the document would keep track of items the user picks up, experience it gains, and where it is in the quest. The GPT could then refer to the document.
You can then describe these simplistic functions to GPT using the function calling schema.
So when GPT determines that it’s appropriate it will create the function for you (fill in the blanks), pass it off to you, and you will run it on your database.
I don’t think realistically you would want GPT to be the one to add experience, but it’s just an easy example
I’m trying to build a GPT that acts like a Dungeon Master, guiding someone through a text-based role-playing game.
I can make a document (like a Google Doc) with all of the rules and instructions, outlining all the encounters, monsters, stats, and adding elements of randomness and procedural generation. That all works great. I instruct the GPT to check the document for the information it needs. During combat, it looks at the Combat section. When the character rests, it looks at the Rest section.
I can get it to randomly generate a character, too, with its own unique name, stats, and items.
The problem is that the GPT can only keep track of so much context at once. That’s okay for the stuff I’ve built in the doc. It can refer to the doc. But it will gradually forget anything specific to te conversation, such as an item the user picks up, or experience they gain, or which monsters they’ve slain.
I’m looking for a way for it to store this information in a document. That way, it can reference the document at the beginning of every encounter to see the character’s stats, inventory, experience and so on. After the encounter, it can update that document with any new stats, items, experience, etc.
The idea is for me to make it, then to let others play the game by interacting with the GPT.
What I believe you may want to do is first create the database and logic handlers. So as above you want functions to modifyExperience, you want the functions to make an attack, a function to move a character. You’re basically creating an API service that manages your DnD session.
Then you would want to use GPT to structure the unstructured. To convert something like (this is very simplified and definitely lacking)
User: I will cast Level 2 Fireball at Goblin"->
GPT: { createAction({ spell: Spells.Fireball, level: 2, target: Creatures.Goblin }) } →
API: { results: [ { lightAt: {Character: 1, goblin_kfjko435oi4: 1}}, {goblin_kfjko435oi4: { hp: 4, diff: -4 } ] →
GPT ( I actually ran this through )
Clutching a well-worn spellbook, the mage’s eyes burn with determination. With a flourish, they invoke the powerful incantation for a Level 2 Fireball spell. The air crackles with arcane energy, and a bright orb of roaring flame materializes in their outstretched hand.
Across the battlefield, a goblin, wiry and green-skinned with a look of surprise and fear, braces for impact. The fireball streaks across the space between them, leaving a trail of scorching heat and flickering embers. It strikes the goblin squarely, engulfing it in a blazing inferno. The goblin writhes and yelps, caught in the fiery embrace.
As the flames recede, the goblin stands, scorched and singed, its leather armor smoldering. Despite the ferocity of the attack, the goblin is not yet vanquished. It has endured the fiery onslaught, though its vitality is significantly diminished, evidenced by the charred and smoking wounds on its body. The mage looks on, poised to continue the battle, as the goblin, resilient yet visibly weakened, prepares for its next move in this high-stakes encounter.
So the idea here is that you have basically created a full DND experience via API. You are simply using GPT to convert unstructured text (What the person says) into structured (The appropriate API call), and then vice versa (API result → Some epic text)
Riffing on your example, I can define what a goblin and fireball are in a doc. The GPT can read the doc. It can play out the scenario. I could do this for 50 spells and monsters. No problem there. The GPT will look at my guide for the rules.
My issue is getting the GPT to record what it’s doing, not in its own limited context memory, but recording it into a document that it can reference later. For example, if the user kills the goblin, gains 10 experience, and picks up the goblin’s sword, I need it to amend the character sheet (adding the experience to his experience, adding the sword to his inventory). That way the GPT will remember. That way it can refer back to the character sheet.
Can you explain the API part? That means the GPT will need to interact with some external site or document that logs the info according to the GPT’s instructions, right? But how?
You would create your schema. You can probably use an already existing DnD API. A quick Google search and I found this:
Acid Arrow
{
"index": "acid-arrow",
"name": "Acid Arrow",
"desc": [
"A shimmering green arrow streaks toward a target within range and bursts in a spray of acid. Make a ranged spell attack against the target. On a hit, the target takes 4d4 acid damage immediately and 2d4 acid damage at the end of its next turn. On a miss, the arrow splashes the target with acid for half as much of the initial damage and no damage at the end of its next turn."
],
"higher_level": [
"When you cast this spell using a spell slot of 3rd level or higher, the damage (both initial and later) increases by 1d4 for each slot level above 2nd."
],
"range": "90 feet",
"components": [
"V",
"S",
"M"
],
"material": "Powdered rhubarb leaf and an adder's stomach.",
"ritual": false,
"duration": "Instantaneous",
"concentration": false,
"casting_time": "1 action",
"level": 2,
"attack_type": "ranged",
"damage": {
damage_type: {
name: "Acid",
url: "/api/damage-types/acid",
},
damage_at_slot_level: {
2: "4d4",
3: "5d4",
4: "6d4",
5: "7d4",
6: "8d4",
7: "9d4",
8: "10d4",
9: "11d4",
},
},
"school": {
"name": "Evocation",
"url": "/api/magic-schools/evocation"
},
"classes": [
{
"name": "Wizard",
"url": "/api/classes/wizard"
}
],
"subclasses": [
{
"name": "Lore",
"url": "/api/subclasses/lore"
},
{
"name": "Land",
"url": "/api/subclasses/land"
}
],
"url": "/api/spells/acid-arrow"
}
This would be a good start. Then you can extend it with the logic.
Then you would need to tell GPT when to use the different functions:
If I upload a simple Google Doc, I can tell GPT everything I need to know about the world and skills and rules. I can have a section on acid arrows. Retrieving information is no problem.
The problem is storing information. Let’s say the character loses health or gains experience. GPT won’t be able to remember that. It can only remember so much context. I need a way for GPT to store that information somewhere, like writing it down in a Google Doc or txt file.