added num_examples

This commit is contained in:
MaxRobinsonTheGreat 2025-01-09 15:16:35 -06:00
parent 6167aeeec4
commit 7eef805395
3 changed files with 11 additions and 3 deletions

View file

@ -35,7 +35,8 @@ export default
"code_timeout_mins": 10, // minutes code is allowed to run. -1 for no timeout
"max_messages": 15, // max number of messages to keep in context
"max_commands": -1, // max number of commands to use in a response. -1 for no limit
"num_examples": 2, // number of examples to give to the model
"max_commands": -1, // max number of commands that can be used in consecutive responses. -1 for no limit
"verbose_commands": true, // show full command syntax
"narrate_behavior": true, // chat simple automatic actions ('Picking up item!')
"chat_bot_messages": true, // publicly chat messages to other bots

View file

@ -4,6 +4,7 @@ import { getCommandDocs } from './commands/index.js';
import { getSkillDocs } from './library/index.js';
import { stringifyTurns } from '../utils/text.js';
import { getCommand } from './commands/index.js';
import settings from '../../settings.js';
import { Gemini } from '../models/gemini.js';
import { GPT } from '../models/gpt.js';
@ -155,8 +156,8 @@ export class Prompter {
async initExamples() {
try {
this.convo_examples = new Examples(this.embedding_model);
this.coding_examples = new Examples(this.embedding_model);
this.convo_examples = new Examples(this.embedding_model, settings.num_examples);
this.coding_examples = new Examples(this.embedding_model, settings.num_examples);
// Wait for both examples to load before proceeding
await Promise.all([

View file

@ -33,6 +33,9 @@ export class Examples {
this.examples = examples;
if (!this.model) return; // Early return if no embedding model
if (this.select_num === 0)
return;
try {
// Create array of promises first
const embeddingPromises = examples.map(example => {
@ -52,6 +55,9 @@ export class Examples {
}
async getRelevant(turns) {
if (this.select_num === 0)
return [];
let turn_text = this.turnsToText(turns);
if (this.model !== null) {
let embedding = await this.model.embed(turn_text);