mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-10 01:05:33 +02:00
Add select_num exception range judgment
This commit is contained in:
parent
90df61d2be
commit
f264b23ccc
1 changed files with 8 additions and 6 deletions
|
@ -136,17 +136,19 @@ export class Prompter {
|
|||
}))
|
||||
.sort((a, b) => b.similarity_score - a.similarity_score);
|
||||
|
||||
// select_num = -1 means select all
|
||||
let selected_docs = skill_doc_similarities.slice(0, select_num === -1 ? skill_doc_similarities.length : select_num);
|
||||
let length = skill_doc_similarities.length;
|
||||
if (typeof select_num !== 'number' || isNaN(select_num) || select_num <= 0) {
|
||||
select_num = length;
|
||||
} else {
|
||||
select_num = Math.min(Math.floor(select_num), length);
|
||||
}
|
||||
let selected_docs = skill_doc_similarities.slice(0, select_num);
|
||||
let message = '\nThe following recommended functions are listed in descending order of task relevance.\nSkillDocs:\n';
|
||||
message += selected_docs.map(doc => `${doc.doc_key}`).join('\n');
|
||||
console.log(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async replaceStrings(prompt, messages, examples=null, to_summarize=[], last_goals=null) {
|
||||
prompt = prompt.replaceAll('$NAME', this.agent.name);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue