Skip to content

Commit

Permalink
chore: simThreshold from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Nov 6, 2024
1 parent 82bc1fe commit 4e38f02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/bot/features/commands/shared/ask-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ feature.command("ubiquityos", logHandle("command-ubiquityos"), chatAction("typin

const outputStyle = "Concise and coherent responses in paragraphs that directly address the user's question.";

const similarityThreshold = 0.9;
const question = ctx.message?.text.replace("/ubiquityos", "").trim();

if (!question) {
return ctx.reply("Please provide a question to ask UbiquityOS.");
}

const { similarityThreshold, model } = PluginContext.getInstance().config.aiConfig;

const similarText = await Promise.all([
embeddings.findSimilarComments(question, 1 - similarityThreshold),
embeddings.findSimilarIssues(question, 1 - similarityThreshold),
Expand All @@ -69,7 +70,7 @@ feature.command("ubiquityos", logHandle("command-ubiquityos"), chatAction("typin
embeddingsSearch: rerankedText,
additionalContext: [],
outputStyle,
model: PluginContext.getInstance().config.aiConfig.model,
model,
}),
{
parse_mode: "Markdown",
Expand Down
2 changes: 2 additions & 0 deletions src/types/plugin-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ export const pluginSettingsSchema = T.Object({
model: T.String({ default: "openai/o1-mini" }),
baseUrl: T.String({ default: "https://api.openai.com/v1" }),
maxCompletionTokens: T.Number({ default: 5000 }),
similarityThreshold: T.Number({ default: 0.9 }),
}),
T.Object({
kind: T.Literal("OpenRouter"),
model: T.String({ default: "openai/o1-mini" }),
baseUrl: T.String({ default: "https://openrouter.ai/api/v1" }),
maxCompletionTokens: T.Number({ default: 5000 }),
similarityThreshold: T.Number({ default: 0.9 }),
}),
],
{ default: { kind: "OpenAi", model: "openai/o1-mini", baseUrl: "https://api.openai.com/v1" }, maxCompletionTokens: 5000 }
Expand Down

0 comments on commit 4e38f02

Please sign in to comment.