mirror of
https://github.com/upstash/context7.git
synced 2025-11-10 06:47:35 +00:00
feat: string-to-number conversion for tokens parameter
This commit is contained in:
parent
c1a4a1a21c
commit
ae1a7c44fa
@ -80,8 +80,10 @@ server.tool(
|
||||
.optional()
|
||||
.describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),
|
||||
tokens: z
|
||||
.number()
|
||||
.min(DEFAULT_MINIMUM_TOKENS)
|
||||
.preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())
|
||||
.refine((val) => typeof val === "number" && val >= DEFAULT_MINIMUM_TOKENS, {
|
||||
message: `Must be a number >= ${DEFAULT_MINIMUM_TOKENS}`,
|
||||
})
|
||||
.optional()
|
||||
.describe(
|
||||
`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user