Back

Version 66

5/30/2024
import { ModelProvider, modelProvider } from "https://esm.town/v/yawnxyz/ai";
import { KV } from "https://esm.town/v/yawnxyz/blobManager";

class Nighthawks {
constructor(scope = "") {
this.characters = [];
this.kv = new KV(scope);
}

async createCharacter({ characterName, characterDescription } = {}) {
const characterModel = new ModelProvider({
id: `${characterName}`,
provider: 'groq',
model: 'mixtral-8x7b-32768',
system: [
"You are an NPC in a game and the following conversation is a simulation within the game with the user.",
"Speak in a way that's natural and not too eager of a personality",
"In responses and your memory generation, write it as role play and remain in character",
"Only write messages in FIRST PERSON. This is the character dialogue; don't describe character in 3rd person, don't describe the situation or step out of character, but you can do things like `*frowns* no, I don't think I'd like that`; there's another system to describe the situation"
].join("\n"),
useMessages: true,
useMemory: true,
memories: [],
memoryPrompt: "Create a ~100 character internal running monology used as MEMORY for the future, to yourself thinking about what just happened, stay in character of NPC game. w/ respect to your character sheet, personality, and motivations. Keep it short. Can compress it into one string, no newlines. Only for yourself to use in future",
useChars: true,
getUpdatedChars: true,
chars: {},
charsPrompt: "Based on the current conversation, describe how the characters state, emotions, inventory, or ideas might change. Update the JSON in <chars></chars> and output the new JSON, with only the changed object/keys. Output in JSON, don't explain your answer, do start/end with brackets: {}",
});

let exampleCharJson = JSON.stringify({
id: 'kurt-model',
chars: {
name: "Kurt",
personality: "Respond to user with hesitation like you don't believe them",
occupation: "Star Comedian",
Updated: May 31, 2024