nsarrazin HF Staff commited on
Commit
0c29e99
·
unverified ·
1 Parent(s): 439b391

fix(tools): tool call name must be a valid python variable name (#1466)

Browse files
Files changed (1) hide show
  1. src/lib/server/tools/index.ts +5 -1
src/lib/server/tools/index.ts CHANGED
@@ -69,7 +69,11 @@ const toolInputSchema = toolInputBaseSchema.and(
69
 
70
  export const editableToolSchema = z
71
  .object({
72
- name: z.string().min(1).max(40),
 
 
 
 
73
  // only allow huggingface spaces either through namespace or direct URLs
74
  baseUrl: z.union([
75
  z.string().regex(/^[^/]+\/[^/]+$/),
 
69
 
70
  export const editableToolSchema = z
71
  .object({
72
+ name: z
73
+ .string()
74
+ .regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/) // only allow letters, numbers, and underscores, and start with a letter or underscore
75
+ .min(1)
76
+ .max(40),
77
  // only allow huggingface spaces either through namespace or direct URLs
78
  baseUrl: z.union([
79
  z.string().regex(/^[^/]+\/[^/]+$/),