xiongzhu 2 tahun lalu
induk
melakukan
702afcc164
1 mengubah file dengan 10 tambahan dan 8 penghapusan
  1. 10 8
      src/game/game.service.ts

+ 10 - 8
src/game/game.service.ts

@@ -412,9 +412,13 @@ export class GameService implements OnModuleInit {
         const charactorsAlive = charactors.filter((i) => i.dead === false)
         const charactorsWillDead = charactorsAlive.filter((i) => !i.dead && i.hp <= 0)
 
+        const vars = {
+            days: Math.floor(differenceInDays(date, history[0].date)),
+            charactors: charactors
+        }
         let summary = this.formatSummary(history)
         let prompt = new PromptTemplate({
-            template: await this.promptService.getPromptByName(PromptName.NextPlot, game.type),
+            template: this.evalPrompt(vars, await this.promptService.getPromptByName(PromptName.NextPlot, game.type)),
             inputVariables: ['background', 'charactors', 'datetime', 'summary', 'choice', 'death', 'newCharactor']
         })
         const formatedCharactors = this.formatCharactors(charactors)
@@ -452,12 +456,7 @@ export class GameService implements OnModuleInit {
                 : ''
         })
 
-        const vars = {
-            days: Math.floor(differenceInDays(date, history[0].date)),
-            charactors: charactors
-        }
-
-        const response = await this.callLLM([new HumanMessage(this.evalPrompt(vars, input))])
+        const response = await this.callLLM([new HumanMessage(input)])
         plot = response.content
 
         this.send(`${id}`, {
@@ -796,7 +795,10 @@ export class GameService implements OnModuleInit {
                 )
                 const formatInstructions = parser.getFormatInstructions()
                 const prompt = new PromptTemplate({
-                    template: await this.promptService.getPromptByName(PromptName.GenChoice, type),
+                    template: this.evalPrompt(
+                        vars,
+                        await this.promptService.getPromptByName(PromptName.GenChoice, type)
+                    ),
                     inputVariables: ['charactorsAlive', 'charactorsDead', 'summary'],
                     partialVariables: { format_instructions: formatInstructions }
                 })