configurable timeout
This commit is contained in:
parent
2d4f3e91a6
commit
4c93d96ae9
1 changed files with 13 additions and 3 deletions
16
index.js
16
index.js
|
|
@ -76,7 +76,12 @@ async function buildMessageHistory(message, maxDepth = 10) {
|
|||
return history;
|
||||
}
|
||||
|
||||
async function generateResponse(prompt, username, messageHistory = []) {
|
||||
async function generateResponse(
|
||||
prompt,
|
||||
username,
|
||||
messageHistory = [],
|
||||
timeout,
|
||||
) {
|
||||
try {
|
||||
const systemPrompt = config.assistant.system_prompt
|
||||
.replace("${name}", config.assistant.name)
|
||||
|
|
@ -106,7 +111,7 @@ async function generateResponse(prompt, username, messageHistory = []) {
|
|||
},
|
||||
},
|
||||
{
|
||||
timeout: 60000,
|
||||
timeout: config.advanced.timeout,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -203,7 +208,12 @@ client.on(Events.MessageCreate, async (message) => {
|
|||
);
|
||||
}
|
||||
|
||||
const response = await generateResponse(prompt, username, messageHistory);
|
||||
const response = await generateResponse(
|
||||
prompt,
|
||||
username,
|
||||
messageHistory,
|
||||
config.advanced.timeout,
|
||||
);
|
||||
|
||||
if (response.length > 2000) {
|
||||
const chunks = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue