Skip to content

Commit 30749b8

Browse files
committed
fix(markdown): possibilité de customiser le RAGprompt dans la directive !RAG
1 parent ee51012 commit 30749b8

5 files changed

Lines changed: 12 additions & 4 deletions

File tree

app/js/ai/getAnswerFromLLM.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { encodeString } from "../utils/strings.mjs";
77
// Fonction pour récupérer une réponse d'un LLM à partir d'un prompt
88
export function getAnswerFromLLM(chatbot, userPrompt, options) {
99
let RAGinformations = options && options.RAG;
10+
const RAGprompt = options.RAGprompt
11+
? options.RAGprompt
12+
: yaml.useLLM.RAGprompt;
1013
let messageElement = options && options.messageElement;
1114
let container = options && options.container;
1215
const inline = options && options.inline;
@@ -21,7 +24,7 @@ export function getAnswerFromLLM(chatbot, userPrompt, options) {
2124
temperature: 0.7,
2225
};
2326
if (RAGinformations.length > 0) {
24-
RAGinformations = yaml.useLLM.RAGprompt + RAGinformations;
27+
RAGinformations = RAGprompt + RAGinformations;
2528
}
2629
const APIurl = yaml.useLLM.url;
2730
let APItype;

app/js/markdown/custom/directives/useLLM/processMessageWithPrompt.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ export async function processMessageWithPrompt(
2222
appendMessageToContainer(sectionElement, messageElement);
2323
}
2424
let RAGinformations = "";
25+
let RAGprompt = "";
2526
if (content.includes("!RAG: ")) {
2627
const promptWithRag = await processPromptWithRAG(chatbot, content);
2728
content = promptWithRag.content;
2829
RAGinformations = promptWithRag.RAGinformations;
30+
RAGprompt = promptWithRag.RAGprompt;
2931
}
3032
// Gestion du contenu qui fait appel à un LLM
3133
await getAnswerFromLLM(chatbot, content, {
3234
RAG: RAGinformations,
35+
RAGprompt: RAGprompt,
3336
messageElement: sectionElement,
3437
container: messageElement,
3538
inline: true,

app/js/markdown/custom/directives/useLLM/processPromptWithRAG.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export async function processPromptWithRAG(chatbot, content) {
1212

1313
const { question, optionsList } = RAGdirective;
1414
const options = parseOptions(optionsList);
15+
const RAGprompt = options.prompt ? options.prompt : "";
1516

1617
const RAGinformations = options.url
1718
? await getRAGcontent(options.url, {
@@ -27,5 +28,6 @@ export async function processPromptWithRAG(chatbot, content) {
2728
return {
2829
content: content.replace(RAGdirective.RAGline, ""),
2930
RAGinformations: topRAGinformations,
31+
RAGprompt: RAGprompt,
3032
};
3133
}

app/script.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/script.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)