Commit 291b379
authored
feat(component,ai,gemini): add multimedia support with unified format… (#1114)
Because
- The Gemini component only supported text and image inputs, limiting
its capabilities for audio, video, and document processing
- Format validation logic was scattered and repetitive across different
media types
- Error messages for unsupported formats were not helpful in guiding
users toward conversion solutions
- The component didn't leverage Gemini API's native support for remote
file URIs, causing unnecessary data transfer
- Test coverage was incomplete for multimedia processing functions
This commit
- Adds comprehensive audio and video support to the Gemini chat
component, enabling multimedia understanding capabilities
- Implements unified format validation system using `formatSupport`
struct to centralize Gemini API and Instill Core format definitions
- Enhances error messages to provide specific conversion guidance (e.g.,
`:png`, `:wav`, `:mp4` syntax) for unsupported formats
- Refactors `buildReqParts` function into focused helper functions
(`processImageParts`, `processAudioParts`, `processVideoParts`,
`processDocumentParts`) for better maintainability
- Optimizes remote file handling by using `genai.NewPartFromURI` for
HTTP/HTTPS URLs and `external.BinaryFetcher` for data URIs
- Adds comprehensive unit tests for all processing functions, including
streaming/non-streaming logic and edge cases
- Aligns format support lists with actual constants defined in
`pkg/data` packages while maintaining complete Gemini API format
coverage
- Implements document processing modes (visual for PDF, text for plain
text formats, conversion guidance for office documents)1 parent 793bd1d commit 291b379
File tree
5 files changed
+1130
-808
lines changed- pkg/component/ai/gemini/v0
- config
5 files changed
+1130
-808
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1513 | 1513 | | |
1514 | 1514 | | |
1515 | 1515 | | |
1516 | | - | |
| 1516 | + | |
1517 | 1517 | | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
1518 | 1532 | | |
1519 | 1533 | | |
1520 | 1534 | | |
| |||
1523 | 1537 | | |
1524 | 1538 | | |
1525 | 1539 | | |
1526 | | - | |
| 1540 | + | |
1527 | 1541 | | |
1528 | 1542 | | |
1529 | 1543 | | |
1530 | 1544 | | |
1531 | | - | |
| 1545 | + | |
1532 | 1546 | | |
1533 | 1547 | | |
1534 | 1548 | | |
1535 | 1549 | | |
1536 | 1550 | | |
1537 | 1551 | | |
1538 | | - | |
| 1552 | + | |
1539 | 1553 | | |
1540 | 1554 | | |
1541 | 1555 | | |
1542 | 1556 | | |
1543 | | - | |
| 1557 | + | |
1544 | 1558 | | |
1545 | 1559 | | |
1546 | 1560 | | |
1547 | 1561 | | |
1548 | 1562 | | |
1549 | 1563 | | |
1550 | 1564 | | |
1551 | | - | |
| 1565 | + | |
1552 | 1566 | | |
1553 | 1567 | | |
1554 | 1568 | | |
| |||
1568 | 1582 | | |
1569 | 1583 | | |
1570 | 1584 | | |
1571 | | - | |
| 1585 | + | |
1572 | 1586 | | |
1573 | 1587 | | |
1574 | 1588 | | |
1575 | 1589 | | |
1576 | | - | |
| 1590 | + | |
1577 | 1591 | | |
1578 | 1592 | | |
1579 | 1593 | | |
1580 | 1594 | | |
1581 | 1595 | | |
1582 | 1596 | | |
1583 | | - | |
| 1597 | + | |
1584 | 1598 | | |
1585 | 1599 | | |
1586 | 1600 | | |
1587 | 1601 | | |
1588 | 1602 | | |
1589 | 1603 | | |
1590 | | - | |
| 1604 | + | |
1591 | 1605 | | |
1592 | 1606 | | |
1593 | | - | |
| 1607 | + | |
1594 | 1608 | | |
1595 | 1609 | | |
1596 | 1610 | | |
1597 | 1611 | | |
1598 | 1612 | | |
1599 | 1613 | | |
1600 | | - | |
| 1614 | + | |
1601 | 1615 | | |
1602 | 1616 | | |
1603 | 1617 | | |
1604 | 1618 | | |
1605 | | - | |
| 1619 | + | |
1606 | 1620 | | |
1607 | 1621 | | |
1608 | | - | |
| 1622 | + | |
1609 | 1623 | | |
1610 | 1624 | | |
1611 | 1625 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
0 commit comments