Skip to content

Commit 2b3ac73

Browse files
Merge pull request #8 from IQAIcom/fix-add-timeout-to-env-for-sampling-messages
add timeout to env for sampling messages
2 parents df3cf17 + 463321c commit 2b3ac73

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

.changeset/happy-suits-say.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@iqai/mcp-discord": patch
3+
---
4+
5+
Adds timeout setting in env for sampling messages

src/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ const envSchema = z.object({
3232
.optional()
3333
.default(true)
3434
.describe('Only respond to messages that mention the bot'),
35+
SAMPLING_DEFAULT_TIMEOUT: z
36+
.number()
37+
.optional()
38+
.describe('A timeout (in milliseconds) for this request'),
39+
SAMPLING_REACTION_TIMEOUT: z
40+
.number()
41+
.optional()
42+
.describe('A timeout for sending reactions to discord'),
3543
BLOCK_DMS: z
3644
.stringbool()
3745
.optional()

src/sampling.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ export class SamplingHandler {
187187
maxTokens: 10,
188188
},
189189
},
190-
z.any()
190+
z.any(),
191+
{
192+
timeout: env.SAMPLING_REACTION_TIMEOUT,
193+
}
191194
);
192195

193196
const response =
@@ -225,7 +228,8 @@ export class SamplingHandler {
225228
maxTokens: 200,
226229
},
227230
},
228-
z.any()
231+
z.any(),
232+
{ timeout: env.SAMPLING_DEFAULT_TIMEOUT }
229233
);
230234
}
231235

0 commit comments

Comments
 (0)