feat: Integrate Kokoro TTS with WebGPU and fallback
This commit is contained in:
Vendored
+34
-34
@@ -115,26 +115,26 @@ class OpenRouterProvider {
|
||||
* Build the system and user prompts for action translation
|
||||
*/
|
||||
buildActionPrompt(request) {
|
||||
const systemPrompt = `You are an AI assistant that translates natural language input into structured action commands for an interactive fiction game.
|
||||
Your task is to convert player input into a JSON object representing an action that can be understood by the game engine.
|
||||
|
||||
The player is currently in the "${request.currentRoom}" room.
|
||||
Visible objects: ${request.visibleObjects.join(', ')}
|
||||
Visible characters: ${request.visibleCharacters.join(', ')}
|
||||
Inventory: ${request.inventory.join(', ')}
|
||||
Available actions: ${request.possibleActions.join(', ')}
|
||||
|
||||
Game context: ${request.gameContext}
|
||||
|
||||
Respond ONLY with a JSON object that follows this structure:
|
||||
{
|
||||
"action": "string", // Name of the action (e.g., "take", "examine", "go", "talk", etc.)
|
||||
"object": "string", // Optional: Primary object of the action
|
||||
"target": "string", // Optional: Secondary object/target of the action
|
||||
"parameters": {}, // Optional: Additional parameters as key-value pairs
|
||||
"confidence": number // How confident you are in this interpretation (0.0-1.0)
|
||||
}
|
||||
|
||||
const systemPrompt = `You are an AI assistant that translates natural language input into structured action commands for an interactive fiction game.
|
||||
Your task is to convert player input into a JSON object representing an action that can be understood by the game engine.
|
||||
|
||||
The player is currently in the "${request.currentRoom}" room.
|
||||
Visible objects: ${request.visibleObjects.join(', ')}
|
||||
Visible characters: ${request.visibleCharacters.join(', ')}
|
||||
Inventory: ${request.inventory.join(', ')}
|
||||
Available actions: ${request.possibleActions.join(', ')}
|
||||
|
||||
Game context: ${request.gameContext}
|
||||
|
||||
Respond ONLY with a JSON object that follows this structure:
|
||||
{
|
||||
"action": "string", // Name of the action (e.g., "take", "examine", "go", "talk", etc.)
|
||||
"object": "string", // Optional: Primary object of the action
|
||||
"target": "string", // Optional: Secondary object/target of the action
|
||||
"parameters": {}, // Optional: Additional parameters as key-value pairs
|
||||
"confidence": number // How confident you are in this interpretation (0.0-1.0)
|
||||
}
|
||||
|
||||
Choose the action from the list of available actions. If the player's input is ambiguous or doesn't map well to an available action, choose the closest match and set a lower confidence score.`;
|
||||
const userPrompt = request.playerInput;
|
||||
return {
|
||||
@@ -147,21 +147,21 @@ Choose the action from the list of available actions. If the player's input is a
|
||||
*/
|
||||
buildNarrativePrompt(request) {
|
||||
const tone = request.tone || 'descriptive';
|
||||
const systemPrompt = `You are an AI assistant that generates engaging narrative prose for an interactive fiction game.
|
||||
Your task is to describe what happens when a player performs an action in the game world.
|
||||
|
||||
Craft a vivid, ${tone} description that tells the player what happened as a result of their action. Make your prose engaging and atmospheric.
|
||||
|
||||
Current room description: "${request.roomDescription}"
|
||||
Visible objects: ${request.visibleObjects.join(', ')}
|
||||
Visible characters: ${request.visibleCharacters.join(', ')}
|
||||
|
||||
${request.previousContext ? `Previous context: ${request.previousContext}` : ''}
|
||||
|
||||
Respond with engaging prose that describes the outcome of the player's action.
|
||||
const systemPrompt = `You are an AI assistant that generates engaging narrative prose for an interactive fiction game.
|
||||
Your task is to describe what happens when a player performs an action in the game world.
|
||||
|
||||
Craft a vivid, ${tone} description that tells the player what happened as a result of their action. Make your prose engaging and atmospheric.
|
||||
|
||||
Current room description: "${request.roomDescription}"
|
||||
Visible objects: ${request.visibleObjects.join(', ')}
|
||||
Visible characters: ${request.visibleCharacters.join(', ')}
|
||||
|
||||
${request.previousContext ? `Previous context: ${request.previousContext}` : ''}
|
||||
|
||||
Respond with engaging prose that describes the outcome of the player's action.
|
||||
You can optionally include 1-3 subtle hints about interesting things to try next.`;
|
||||
const userPrompt = `The player has performed this action: "${request.action}".
|
||||
The result of the action is: "${request.result}".
|
||||
const userPrompt = `The player has performed this action: "${request.action}".
|
||||
The result of the action is: "${request.result}".
|
||||
Please describe what happens in an engaging, narrative way.`;
|
||||
return {
|
||||
system: systemPrompt,
|
||||
|
||||
Reference in New Issue
Block a user