Skip to content

Commit

Permalink
Fix prompting bugs (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
miku448 authored Sep 22, 2023
1 parent 69aabb5 commit dae3e29
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/bot-utils/src/lib/MikuCardValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function validateMikuCard(card: MikuCard): string[] {
if (!scenarios.has(child_scenario))
errors.push(`${scenario.id}: ${child_scenario} not found in children_scenarios`);

if (!sounds.has(scenario.music || '') && !DEFAULT_MUSIC.includes(scenario.music || '')) {
if (scenario.music && !sounds.has(scenario.music || '') && !DEFAULT_MUSIC.includes(scenario.music || '')) {
errors.push(`${scenario.id}: ${scenario.music} not found in mikugg.sounds`)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export class AphroditePromptCompleter extends Core.ChatPromptCompleters
memory: Core.Memory.ShortTermMemory
): Promise<Core.ChatPromptCompleters.ChatPromptResponse> {
let result = "";
let isParsedResultSmall = false;
let isParsedResultSmall = true;
let tries = 0;

while (
(isParsedResultSmall || !hasTextStop(result, memory.getSubjects())) &&
(isParsedResultSmall && !hasTextStop(result, memory.getSubjects())) &&
tries++ < 2
) {
if (isParsedResultSmall) result = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export class OobaboogaPromptCompleter extends Core.ChatPromptCompleters
): Promise<Core.ChatPromptCompleters.ChatPromptResponse> {
const prompt = memory.buildMemoryPrompt();
let result = "";
let isParsedResultSmall = false;
let isParsedResultSmall = true;
let tries = 0;

while (
(isParsedResultSmall || !hasTextStop(result, memory.getSubjects())) &&
(isParsedResultSmall && !hasTextStop(result, memory.getSubjects())) &&
tries++ < 2
) {
if (isParsedResultSmall) result = "";
Expand Down
39 changes: 11 additions & 28 deletions packages/extensions/src/memory/strategies/AlpacaStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
/*
Below is an instruction that describes a task. Write a response that appropriately completes the request.
Write Ayumi's next reply in a fictional roleplay chat between You and Ayumi.
Ayumi's Persona: (character card here)
This is how Ayumi should talk:
(example conversation here)
Then the roleplay chat between You and Ayumi begins.
### Response:
Ayumi: (conversation setting described here)
### Instruction:
You: *you do ...* Can you...?
### Response:
Ayumi:
You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.\n\nAvoid repetition, don't loop. Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions.\n\n### Input:
### Input:
*/

import * as MikuCore from '@mikugg/core';
Expand All @@ -30,28 +14,27 @@ export class AlpacaStrategy implements ContextPromptBuildStrategy {
.map(([key, value]) => `${key}: ${value}`)
.join('\n');

let prompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n';
prompt += `Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n\n`;
prompt += `{{char}}'s persona: ${persona}. ${formattedAttributes}\n`;
prompt += `This is how {{char}} should talk:\n`;
let prompt = `You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.`;
prompt += `\n\nAvoid repetition, don't loop. Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions.`
prompt += `\n\n### Input:\n${persona}.\n${formattedAttributes}\n`;
prompt += `This is how {{char}} should talk\n`;
for (const example of sampleChat) {
prompt += example + '\n';
}
prompt += `${scenario}\n`;
// prompt += `<START>\n`;
return prompt;
}

buildInitiatorPrompt(parts: ContextPromptParts): string {
const { greeting } = parts;
let prompt = '\nThen the roleplay chat between {{user}} and {{char}} begins.\n';
const { greeting, scenario } = parts;
let prompt = '\nThen the roleplay chat between {{user}} and {{char}} begins.\n\n';
prompt += "### Response\n";
prompt += `${scenario}\n`;
prompt += greeting + '\n';
return prompt;
}

getResponseAskLine(): string {
return '### Response\n{{char}}: ';
return '### Response (one paragraph, engaging, natural, authentic, descriptive, creative):\n{{char}}: ';
}

getBotSubject(parts: ContextPromptParts): string {
Expand All @@ -60,7 +43,7 @@ export class AlpacaStrategy implements ContextPromptBuildStrategy {

getMemoryLinePrompt(memoryLine: MikuCore.Memory.MemoryLine, isBot: boolean): string {
return isBot ?
`### Response:\n{{char}}: ${memoryLine.text}\n` :
`### Response (one paragraph, engaging, natural, authentic, descriptive, creative):\n{{char}}: ${memoryLine.text}\n` :
memoryLine.type === MikuCore.Commands.CommandType.CONTEXT ?
`### Instruction:\n${memoryLine.text}\n` :
`### Instruction:\n{{user}}: ${memoryLine.text}\n`;
Expand Down

0 comments on commit dae3e29

Please sign in to comment.