Skip to content

Commit

Permalink
bot: avoid llm response, training data is likely of low quality (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser authored Feb 20, 2024
1 parent 027d8bd commit 7df6587
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion llm/src/routes/llm/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const PromptWithContext = async (request: Request, env: Env, ctx: Executi
const providedContext = reqBody.context;

const systemPrompt =
'Your job is to help provide an answer using the provided context from similar questions in the past. 1. Do not make any statements related to obtaining ISOs, do not explain to the user that you cannot help them with this as well. 2. Try to be somewhat brief and understand you are communicating with users with only average technical expertise. 3. Do not speak in first-person. 4. Your answer can be formatted with markdown.';
'Your job is to help provide an answer using the provided context from similar questions in the past. 1. Do not make any statements related to obtaining ISOs, do not explain to the user that you cannot help them with this as well. 2. Try to be brief with 240 words or less and understand you are communicating with users with only average technical expertise. 3. Do not speak in first-person. 4. Your answer can be formatted with markdown.';

const contextMessage = `Context:\n${providedContext.map((context: String) => `- ${context}`).join('\n')}`;
const { response: answer } = await ai.run('@hf/thebloke/openhermes-2.5-mistral-7b-awq', {
Expand Down
31 changes: 19 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,28 @@ async function llmRespondToThread(thread, threadAuthor, threadMessages) {
context.push(embedding.answers);
}
// Get the final response
const response = await fetch("https://api.opengoal.dev/llm/promptWithContext", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.OPENGOAL_API_KEY,
},
body: JSON.stringify({ prompt: question, context: context }),
});
answer = await response.text();
answer += "\n\n";
answer += "_The above response was based on the following previous similar questions:_\n";
// TODO - disabled as I'm not impressed with the accuracy of responses, probably not enough training
// and/or the quality of the trained responses is garbage
// Just point to similar questions for now.
answer = "Your question appears to be similar to the following questions in the past, check to see if they may help you while you wait for a response:\n";
for (const embedding of questionEmbeddings) {
answer += `- https://discord.com/channels/756287461377703987/${embedding}\n`;
}
answer += "\n\n_This is an automated response and there may be inaccuracies or statements that don't adhere to our rules (ie. obtaining ISOs). Don't attempt to reply to this message, the bot will not respond._"
// const response = await fetch("https://api.opengoal.dev/llm/promptWithContext", {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// "x-api-key": process.env.OPENGOAL_API_KEY,
// },
// body: JSON.stringify({ prompt: question, context: context }),
// });
// answer = await response.text();
// answer += "\n\n";
// answer += "_The above response was based on the following previous similar questions:_\n";
// for (const embedding of questionEmbeddings) {
// answer += `- https://discord.com/channels/756287461377703987/${embedding}\n`;
// }
// answer += "\n\n_This is an automated response and there may be inaccuracies or statements that don't adhere to our rules (ie. obtaining ISOs). Don't attempt to reply to this message, the bot will not respond._"
} else {
answer = "Your question does not seem to be similar to any questions in the past, so no automated help could be provided. Please wait for someone to respond when they are free.\n\nIf your question was related to issues with the game, you might find our installation documentation helpful https://opengoal.dev/docs/usage/installation/";
}
Expand Down

0 comments on commit 7df6587

Please sign in to comment.