|
|
@@ -758,14 +758,15 @@ export class GameService implements OnModuleInit {
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
try {
|
|
|
if (i > 0) await setTimeout(1000)
|
|
|
+ const jsonDesc = JSON.parse(await this.promptService.getPromptByName(PromptName.JsonDescription, type))
|
|
|
const parser = StructuredOutputParser.fromZodSchema(
|
|
|
z.array(
|
|
|
z.object({
|
|
|
- content: z.string().describe('剧情发展选项'),
|
|
|
+ content: z.string().describe(jsonDesc.createOptions.content),
|
|
|
modifyHp: z.array(
|
|
|
z.object({
|
|
|
- name: z.string().describe('角色名称'),
|
|
|
- changeValue: z.number().describe('HP值变化')
|
|
|
+ name: z.string().describe(jsonDesc.createOptions.modifyHp.name),
|
|
|
+ changeValue: z.number().describe(jsonDesc.createOptions.modifyHp.changeValue)
|
|
|
})
|
|
|
)
|
|
|
})
|
|
|
@@ -774,11 +775,15 @@ export class GameService implements OnModuleInit {
|
|
|
const formatInstructions = parser.getFormatInstructions()
|
|
|
const prompt = new PromptTemplate({
|
|
|
template: await this.promptService.getPromptByName(PromptName.GenChoice, type),
|
|
|
- inputVariables: ['charactors', 'summary'],
|
|
|
+ inputVariables: ['charactorsAlive', 'charactorsDead', 'summary'],
|
|
|
partialVariables: { format_instructions: formatInstructions }
|
|
|
})
|
|
|
const input = await prompt.format({
|
|
|
- charactors: this.formatCharactors(charactors),
|
|
|
+ charactorsAlive: this.formatCharactors(charactors.filter((i) => !i.dead)),
|
|
|
+ charactorsDead: charactors
|
|
|
+ .filter((i) => i.dead)
|
|
|
+ .map((i) => '- ' + i.name)
|
|
|
+ .join('\n'),
|
|
|
summary
|
|
|
})
|
|
|
const response = await this.callLLM([new HumanMessage(input)])
|