victor HF Staff commited on
Commit
f7bf463
·
1 Parent(s): 20982ca

Expand image field support in tool prompts and rules

Browse files
src/lib/server/textGeneration/mcp/fileRefs.ts CHANGED
@@ -91,7 +91,7 @@ const DEFAULT_FIELD_RULES: FieldRule[] = [
91
  allowedPrefixes: ["image"],
92
  },
93
  {
94
- keys: ["input_image"],
95
  action: "replaceWithDataUrl",
96
  allowedPrefixes: ["image"],
97
  },
 
91
  allowedPrefixes: ["image"],
92
  },
93
  {
94
+ keys: ["input_image", "image", "image_url"],
95
  action: "replaceWithDataUrl",
96
  allowedPrefixes: ["image"],
97
  },
src/lib/server/textGeneration/utils/toolPrompt.ts CHANGED
@@ -15,7 +15,7 @@ export function buildToolPreprompt(tools: OpenAiTool[]): string {
15
  `You can use the following tools if helpful: ${names.join(", ")}.`,
16
  `Today's date: ${currentDate}.`,
17
  `If a tool generates an image, you can inline it directly: ![alt text](image_url).`,
18
- `If a tool needs to operate on an image, set its image input parameter (for example, "input_image") to an image reference string.`,
19
- `Use "image_1", "image_2", etc. where the number equals the chronological order of user-uploaded images in this conversation (image_1 = first image uploaded, image_2 = second, and so on). You can also reuse a direct image URL from a prior tool result instead of pasting new base64 data.`,
20
  ].join(" ");
21
  }
 
15
  `You can use the following tools if helpful: ${names.join(", ")}.`,
16
  `Today's date: ${currentDate}.`,
17
  `If a tool generates an image, you can inline it directly: ![alt text](image_url).`,
18
+ `If a tool needs an image, set its image field ("input_image", "image", or "image_url") to a reference like "image_1", "image_2", etc. (ordered by when the user uploaded them).`,
19
+ `Default to image references; only use a full http(s) URL when the tool description explicitly asks for one, or reuse a URL a previous tool returned.`,
20
  ].join(" ");
21
  }