Responses context update.
This commit is contained in:
parent
0dba97890e
commit
fa13ae77af
@ -272,12 +272,29 @@ async function onMessage(client, cfg, message) {
|
|||||||
client.logger.error(`Error checking score: ${err.message}`);
|
client.logger.error(`Error checking score: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Build request body, prefixing with a mention of who spoke
|
// Build request body, including replied-to message context and mention of who spoke
|
||||||
|
let referencePrefix = '';
|
||||||
|
if (message.reference?.messageId) {
|
||||||
|
try {
|
||||||
|
const ref = await message.channel.messages.fetch(message.reference.messageId);
|
||||||
|
const refContent = ref.content || '';
|
||||||
|
if (ref.author.id === botId) {
|
||||||
|
referencePrefix = `You said: ${refContent}`;
|
||||||
|
} else {
|
||||||
|
referencePrefix = `<@${ref.author.id}> said: ${refContent}`;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// ignore fetch errors
|
||||||
|
}
|
||||||
|
}
|
||||||
const speakerMention = `<@${message.author.id}>`;
|
const speakerMention = `<@${message.author.id}>`;
|
||||||
|
const userInput = referencePrefix
|
||||||
|
? `${referencePrefix}\n${speakerMention} said to you: ${message.content}`
|
||||||
|
: `${speakerMention} said to you: ${message.content}`;
|
||||||
const body = {
|
const body = {
|
||||||
model: cfg.defaultModel,
|
model: cfg.defaultModel,
|
||||||
instructions: client.responsesPrompt,
|
instructions: client.responsesPrompt,
|
||||||
input: `${speakerMention} said to you: ${message.content}`,
|
input: userInput,
|
||||||
previous_response_id: prev,
|
previous_response_id: prev,
|
||||||
max_output_tokens: cfg.defaultMaxTokens,
|
max_output_tokens: cfg.defaultMaxTokens,
|
||||||
temperature: cfg.defaultTemperature,
|
temperature: cfg.defaultTemperature,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user