|
3 | 3 | CalculatorToolDefinition, |
4 | 4 | CodeExecutionToolDefinition, |
5 | 5 | } from '@librechat/agents'; |
| 6 | +import { geminiToolkit } from '~/tools/toolkits/gemini'; |
| 7 | +import { oaiToolkit } from '~/tools/toolkits/oai'; |
6 | 8 |
|
7 | 9 | /** Extended JSON Schema type that includes standard validation keywords */ |
8 | 10 | export type ExtendedJsonSchema = { |
@@ -352,128 +354,6 @@ export const fileSearchSchema: ExtendedJsonSchema = { |
352 | 354 | required: ['query'], |
353 | 355 | }; |
354 | 356 |
|
355 | | -/** OpenAI Image Generation tool JSON schema */ |
356 | | -export const imageGenOaiSchema: ExtendedJsonSchema = { |
357 | | - type: 'object', |
358 | | - properties: { |
359 | | - prompt: { |
360 | | - type: 'string', |
361 | | - maxLength: 32000, |
362 | | - description: `Describe the image you want in detail. |
363 | | - Be highly specific—break your idea into layers: |
364 | | - (1) main concept and subject, |
365 | | - (2) composition and position, |
366 | | - (3) lighting and mood, |
367 | | - (4) style, medium, or camera details, |
368 | | - (5) important features (age, expression, clothing, etc.), |
369 | | - (6) background. |
370 | | - Use positive, descriptive language and specify what should be included, not what to avoid. |
371 | | - List number and characteristics of people/objects, and mention style/technical requirements (e.g., "DSLR photo, 85mm lens, golden hour"). |
372 | | - Do not reference any uploaded images—use for new image creation from text only.`, |
373 | | - }, |
374 | | - background: { |
375 | | - type: 'string', |
376 | | - enum: ['transparent', 'opaque', 'auto'], |
377 | | - description: |
378 | | - 'Sets transparency for the background. Must be one of transparent, opaque or auto (default). When transparent, the output format should be png or webp.', |
379 | | - }, |
380 | | - quality: { |
381 | | - type: 'string', |
382 | | - enum: ['auto', 'high', 'medium', 'low'], |
383 | | - description: 'The quality of the image. One of auto (default), high, medium, or low.', |
384 | | - }, |
385 | | - size: { |
386 | | - type: 'string', |
387 | | - enum: ['auto', '1024x1024', '1536x1024', '1024x1536'], |
388 | | - description: |
389 | | - 'The size of the generated image. One of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default).', |
390 | | - }, |
391 | | - }, |
392 | | - required: ['prompt'], |
393 | | -}; |
394 | | - |
395 | | -/** OpenAI Image Edit tool JSON schema */ |
396 | | -export const imageEditOaiSchema: ExtendedJsonSchema = { |
397 | | - type: 'object', |
398 | | - properties: { |
399 | | - image_ids: { |
400 | | - type: 'array', |
401 | | - items: { type: 'string' }, |
402 | | - minItems: 1, |
403 | | - description: `IDs (image ID strings) of previously generated or uploaded images that should guide the edit. |
404 | | -
|
405 | | -Guidelines: |
406 | | -- If the user's request depends on any prior image(s), copy their image IDs into the \`image_ids\` array (in the same order the user refers to them). |
407 | | -- Never invent or hallucinate IDs; only use IDs that are still visible in the conversation context. |
408 | | -- If no earlier image is relevant, omit the field entirely.`, |
409 | | - }, |
410 | | - prompt: { |
411 | | - type: 'string', |
412 | | - maxLength: 32000, |
413 | | - description: `Describe the changes, enhancements, or new ideas to apply to the uploaded image(s). |
414 | | - Be highly specific—break your request into layers: |
415 | | - (1) main concept or transformation, |
416 | | - (2) specific edits/replacements or composition guidance, |
417 | | - (3) desired style, mood, or technique, |
418 | | - (4) features/items to keep, change, or add (such as objects, people, clothing, lighting, etc.). |
419 | | - Use positive, descriptive language and clarify what should be included or changed, not what to avoid. |
420 | | - Always base this prompt on the most recently uploaded reference images.`, |
421 | | - }, |
422 | | - quality: { |
423 | | - type: 'string', |
424 | | - enum: ['auto', 'high', 'medium', 'low'], |
425 | | - description: |
426 | | - 'The quality of the image. One of auto (default), high, medium, or low. High/medium/low only supported for gpt-image-1.', |
427 | | - }, |
428 | | - size: { |
429 | | - type: 'string', |
430 | | - enum: ['auto', '1024x1024', '1536x1024', '1024x1536', '256x256', '512x512'], |
431 | | - description: |
432 | | - 'The size of the generated images. For gpt-image-1: auto (default), 1024x1024, 1536x1024, 1024x1536. For dall-e-2: 256x256, 512x512, 1024x1024.', |
433 | | - }, |
434 | | - }, |
435 | | - required: ['image_ids', 'prompt'], |
436 | | -}; |
437 | | - |
438 | | -/** Gemini Image Generation tool JSON schema */ |
439 | | -export const geminiImageGenSchema: ExtendedJsonSchema = { |
440 | | - type: 'object', |
441 | | - properties: { |
442 | | - prompt: { |
443 | | - type: 'string', |
444 | | - maxLength: 32000, |
445 | | - description: |
446 | | - 'A detailed text description of the desired image, up to 32000 characters. For "editing" requests, describe the changes you want to make to the referenced image. Be specific about composition, style, lighting, and subject matter.', |
447 | | - }, |
448 | | - image_ids: { |
449 | | - type: 'array', |
450 | | - items: { type: 'string' }, |
451 | | - description: `Optional array of image IDs to use as visual context for generation. |
452 | | -
|
453 | | -Guidelines: |
454 | | -- For "editing" requests: ALWAYS include the image ID being "edited" |
455 | | -- For new generation with context: Include any relevant reference image IDs |
456 | | -- If the user's request references any prior images, include their image IDs in this array |
457 | | -- These images will be used as visual context/inspiration for the new generation |
458 | | -- Never invent or hallucinate IDs; only use IDs that are visible in the conversation |
459 | | -- If no images are relevant, omit this field entirely`, |
460 | | - }, |
461 | | - aspectRatio: { |
462 | | - type: 'string', |
463 | | - enum: ['1:1', '2:3', '3:2', '3:4', '4:3', '4:5', '5:4', '9:16', '16:9', '21:9'], |
464 | | - description: |
465 | | - 'The aspect ratio of the generated image. Use 16:9 or 3:2 for landscape, 9:16 or 2:3 for portrait, 21:9 for ultra-wide/cinematic, 1:1 for square. Defaults to 1:1 if not specified.', |
466 | | - }, |
467 | | - imageSize: { |
468 | | - type: 'string', |
469 | | - enum: ['1K', '2K', '4K'], |
470 | | - description: |
471 | | - 'The resolution of the generated image. Use 1K for standard, 2K for high, 4K for maximum quality. Defaults to 1K if not specified.', |
472 | | - }, |
473 | | - }, |
474 | | - required: ['prompt'], |
475 | | -}; |
476 | | - |
477 | 357 | /** Tool definitions registry - maps tool names to their definitions */ |
478 | 358 | export const toolDefinitions: Record<string, ToolRegistryDefinition> = { |
479 | 359 | google: { |
@@ -549,56 +429,25 @@ export const toolDefinitions: Record<string, ToolRegistryDefinition> = { |
549 | 429 | responseFormat: 'content_and_artifact', |
550 | 430 | }, |
551 | 431 | image_gen_oai: { |
552 | | - name: 'image_gen_oai', |
553 | | - description: `Generates high-quality, original images based solely on text, not using any uploaded reference images. |
554 | | -
|
555 | | -When to use \`image_gen_oai\`: |
556 | | -- To create entirely new images from detailed text descriptions that do NOT reference any image files. |
557 | | -
|
558 | | -When NOT to use \`image_gen_oai\`: |
559 | | -- If the user has uploaded any images and requests modifications, enhancements, or remixing based on those uploads → use \`image_edit_oai\` instead. |
560 | | -
|
561 | | -Generated image IDs will be returned in the response, so you can refer to them in future requests made to \`image_edit_oai\`.`, |
562 | | - schema: imageGenOaiSchema, |
| 432 | + name: oaiToolkit.image_gen_oai.name, |
| 433 | + description: oaiToolkit.image_gen_oai.description, |
| 434 | + schema: oaiToolkit.image_gen_oai.schema, |
563 | 435 | toolType: 'builtin', |
564 | | - responseFormat: 'content_and_artifact', |
| 436 | + responseFormat: oaiToolkit.image_gen_oai.responseFormat, |
565 | 437 | }, |
566 | 438 | image_edit_oai: { |
567 | | - name: 'image_edit_oai', |
568 | | - description: `Generates high-quality, original images based on text and one or more uploaded/referenced images. |
569 | | -
|
570 | | -When to use \`image_edit_oai\`: |
571 | | -- The user wants to modify, extend, or remix one **or more** uploaded images, either: |
572 | | -- Previously generated, or in the current request (both to be included in the \`image_ids\` array). |
573 | | -- Always when the user refers to uploaded images for editing, enhancement, remixing, style transfer, or combining elements. |
574 | | -- Any current or existing images are to be used as visual guides. |
575 | | -- If there are any files in the current request, they are more likely than not expected as references for image edit requests. |
576 | | -
|
577 | | -When NOT to use \`image_edit_oai\`: |
578 | | -- Brand-new generations that do not rely on an existing image → use \`image_gen_oai\` instead. |
579 | | -
|
580 | | -Both generated and referenced image IDs will be returned in the response, so you can refer to them in future requests made to \`image_edit_oai\`.`, |
581 | | - schema: imageEditOaiSchema, |
| 439 | + name: oaiToolkit.image_edit_oai.name, |
| 440 | + description: oaiToolkit.image_edit_oai.description, |
| 441 | + schema: oaiToolkit.image_edit_oai.schema, |
582 | 442 | toolType: 'builtin', |
583 | | - responseFormat: 'content_and_artifact', |
| 443 | + responseFormat: oaiToolkit.image_edit_oai.responseFormat, |
584 | 444 | }, |
585 | 445 | gemini_image_gen: { |
586 | | - name: 'gemini_image_gen', |
587 | | - description: `Generates high-quality, original images based on text prompts, with optional image context. |
588 | | -
|
589 | | -When to use \`gemini_image_gen\`: |
590 | | -- To create entirely new images from detailed text descriptions |
591 | | -- To generate images using existing images as context or inspiration |
592 | | -- When the user requests image generation, creation, or asks to "generate an image" |
593 | | -- When the user asks to "edit", "modify", "change", or "swap" elements in an image (generates new image with changes) |
594 | | -
|
595 | | -When NOT to use \`gemini_image_gen\`: |
596 | | -- For uploading or saving existing images without modification |
597 | | -
|
598 | | -Generated image IDs will be returned in the response, so you can refer to them in future requests.`, |
599 | | - schema: geminiImageGenSchema, |
| 446 | + name: geminiToolkit.gemini_image_gen.name, |
| 447 | + description: geminiToolkit.gemini_image_gen.description, |
| 448 | + schema: geminiToolkit.gemini_image_gen.schema, |
600 | 449 | toolType: 'builtin', |
601 | | - responseFormat: 'content_and_artifact', |
| 450 | + responseFormat: geminiToolkit.gemini_image_gen.responseFormat, |
602 | 451 | }, |
603 | 452 | }; |
604 | 453 |
|
|
0 commit comments