mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-09 16:55:34 +02:00
Improve the relevance of docs to !newAction("task")
This commit is contained in:
parent
e15c516475
commit
c8302c27ac
2 changed files with 16 additions and 5 deletions
|
@ -133,7 +133,7 @@ export class ActionManager {
|
||||||
First outputs:\n${output.substring(0, MAX_OUT / 2)}\n...skipping many lines.\nFinal outputs:\n ${output.substring(output.length - MAX_OUT / 2)}`;
|
First outputs:\n${output.substring(0, MAX_OUT / 2)}\n...skipping many lines.\nFinal outputs:\n ${output.substring(output.length - MAX_OUT / 2)}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
output = 'Code output:\n' + output;
|
output = 'Code output:\n' + output.toString();
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ export class Prompter {
|
||||||
this.coding_examples.load(this.profile.coding_examples),
|
this.coding_examples.load(this.profile.coding_examples),
|
||||||
...getSkillDocs().map(async (doc) => {
|
...getSkillDocs().map(async (doc) => {
|
||||||
let func_name_desc = doc.split('\n').slice(0, 2).join('');
|
let func_name_desc = doc.split('\n').slice(0, 2).join('');
|
||||||
this.skill_docs_embeddings[doc] = await this.embedding_model.embed([func_name_desc]);
|
this.skill_docs_embeddings[doc] = await this.embedding_model.embed(func_name_desc);
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -199,9 +199,20 @@ export class Prompter {
|
||||||
}
|
}
|
||||||
if (prompt.includes('$COMMAND_DOCS'))
|
if (prompt.includes('$COMMAND_DOCS'))
|
||||||
prompt = prompt.replaceAll('$COMMAND_DOCS', getCommandDocs());
|
prompt = prompt.replaceAll('$COMMAND_DOCS', getCommandDocs());
|
||||||
if (prompt.includes('$CODE_DOCS')){
|
if (prompt.includes('$CODE_DOCS')) {
|
||||||
let latest_message_content = messages.slice().reverse().find(msg => msg.role !== 'system')?.content || '';
|
// Find the most recent non-system message containing '!newAction('
|
||||||
prompt = prompt.replaceAll('$CODE_DOCS', await this.getRelevantSkillDocs(latest_message_content, 5));
|
let code_task_content = messages.slice().reverse().find(msg =>
|
||||||
|
msg.role !== 'system' && msg.content.includes('!newAction(')
|
||||||
|
)?.content || '';
|
||||||
|
|
||||||
|
// Extract content between '!newAction(' and ')'
|
||||||
|
const match = code_task_content.match(/!newAction\((.*?)\)/);
|
||||||
|
code_task_content = match ? match[1] : '';
|
||||||
|
|
||||||
|
prompt = prompt.replaceAll(
|
||||||
|
'$CODE_DOCS',
|
||||||
|
await this.getRelevantSkillDocs(code_task_content, 5)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (prompt.includes('$EXAMPLES') && examples !== null)
|
if (prompt.includes('$EXAMPLES') && examples !== null)
|
||||||
prompt = prompt.replaceAll('$EXAMPLES', await examples.createExampleMessage(messages));
|
prompt = prompt.replaceAll('$EXAMPLES', await examples.createExampleMessage(messages));
|
||||||
|
|
Loading…
Add table
Reference in a new issue