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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024
// This file is @generated by prost-build.
/// A file uploaded to the API.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct File {
/// Immutable. Identifier. The `File` resource name. The ID (name excluding the
/// "files/" prefix) can contain up to 40 characters that are lowercase
/// alphanumeric or dashes (-). The ID cannot start or end with a dash. If the
/// name is empty on create, a unique name will be generated. Example:
/// `files/123-456`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. The human-readable display name for the `File`. The display name
/// must be no more than 512 characters in length, including spaces. Example:
/// "Welcome Image"
#[prost(string, tag = "2")]
pub display_name: ::prost::alloc::string::String,
/// Output only. MIME type of the file.
#[prost(string, tag = "3")]
pub mime_type: ::prost::alloc::string::String,
/// Output only. Size of the file in bytes.
#[prost(int64, tag = "4")]
pub size_bytes: i64,
/// Output only. The timestamp of when the `File` was created.
#[prost(message, optional, tag = "5")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. The timestamp of when the `File` was last updated.
#[prost(message, optional, tag = "6")]
pub update_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. The timestamp of when the `File` will be deleted. Only set if
/// the `File` is scheduled to expire.
#[prost(message, optional, tag = "7")]
pub expiration_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. SHA-256 hash of the uploaded bytes.
#[prost(bytes = "bytes", tag = "8")]
pub sha256_hash: ::prost::bytes::Bytes,
/// Output only. The uri of the `File`.
#[prost(string, tag = "9")]
pub uri: ::prost::alloc::string::String,
/// Output only. Processing state of the File.
#[prost(enumeration = "file::State", tag = "10")]
pub state: i32,
/// Output only. Error status if File processing failed.
#[prost(message, optional, tag = "11")]
pub error: ::core::option::Option<super::super::super::rpc::Status>,
/// Metadata for the File.
#[prost(oneof = "file::Metadata", tags = "12")]
pub metadata: ::core::option::Option<file::Metadata>,
}
/// Nested message and enum types in `File`.
pub mod file {
/// States for the lifecycle of a File.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum State {
/// The default value. This value is used if the state is omitted.
Unspecified = 0,
/// File is being processed and cannot be used for inference yet.
Processing = 1,
/// File is processed and available for inference.
Active = 2,
/// File failed processing.
Failed = 10,
}
impl State {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
State::Unspecified => "STATE_UNSPECIFIED",
State::Processing => "PROCESSING",
State::Active => "ACTIVE",
State::Failed => "FAILED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STATE_UNSPECIFIED" => Some(Self::Unspecified),
"PROCESSING" => Some(Self::Processing),
"ACTIVE" => Some(Self::Active),
"FAILED" => Some(Self::Failed),
_ => None,
}
}
}
/// Metadata for the File.
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum Metadata {
/// Output only. Metadata for a video.
#[prost(message, tag = "12")]
VideoMetadata(super::VideoMetadata),
}
}
/// Metadata for a video `File`.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct VideoMetadata {
/// Duration of the video.
#[prost(message, optional, tag = "1")]
pub video_duration: ::core::option::Option<::prost_types::Duration>,
}
/// Permission resource grants user, group or the rest of the world access to the
/// PaLM API resource (e.g. a tuned model, corpus).
///
/// A role is a collection of permitted operations that allows users to perform
/// specific actions on PaLM API resources. To make them available to users,
/// groups, or service accounts, you assign roles. When you assign a role, you
/// grant permissions that the role contains.
///
/// There are three concentric roles. Each role is a superset of the previous
/// role's permitted operations:
///
/// - reader can use the resource (e.g. tuned model, corpus) for inference
/// - writer has reader's permissions and additionally can edit and share
/// - owner has writer's permissions and additionally can delete
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Permission {
/// Output only. Identifier. The permission name. A unique name will be
/// generated on create. Examples:
/// tunedModels/{tuned_model}/permissions/{permission}
/// corpora/{corpus}/permissions/{permission}
/// Output only.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. Immutable. The type of the grantee.
#[prost(enumeration = "permission::GranteeType", optional, tag = "2")]
pub grantee_type: ::core::option::Option<i32>,
/// Optional. Immutable. The email address of the user of group which this
/// permission refers. Field is not set when permission's grantee type is
/// EVERYONE.
#[prost(string, optional, tag = "3")]
pub email_address: ::core::option::Option<::prost::alloc::string::String>,
/// Required. The role granted by this permission.
#[prost(enumeration = "permission::Role", optional, tag = "4")]
pub role: ::core::option::Option<i32>,
}
/// Nested message and enum types in `Permission`.
pub mod permission {
/// Defines types of the grantee of this permission.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum GranteeType {
/// The default value. This value is unused.
Unspecified = 0,
/// Represents a user. When set, you must provide email_address for the user.
User = 1,
/// Represents a group. When set, you must provide email_address for the
/// group.
Group = 2,
/// Represents access to everyone. No extra information is required.
Everyone = 3,
}
impl GranteeType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
GranteeType::Unspecified => "GRANTEE_TYPE_UNSPECIFIED",
GranteeType::User => "USER",
GranteeType::Group => "GROUP",
GranteeType::Everyone => "EVERYONE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"GRANTEE_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"USER" => Some(Self::User),
"GROUP" => Some(Self::Group),
"EVERYONE" => Some(Self::Everyone),
_ => None,
}
}
}
/// Defines the role granted by this permission.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Role {
/// The default value. This value is unused.
Unspecified = 0,
/// Owner can use, update, share and delete the resource.
Owner = 1,
/// Writer can use, update and share the resource.
Writer = 2,
/// Reader can use the resource.
Reader = 3,
}
impl Role {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Role::Unspecified => "ROLE_UNSPECIFIED",
Role::Owner => "OWNER",
Role::Writer => "WRITER",
Role::Reader => "READER",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ROLE_UNSPECIFIED" => Some(Self::Unspecified),
"OWNER" => Some(Self::Owner),
"WRITER" => Some(Self::Writer),
"READER" => Some(Self::Reader),
_ => None,
}
}
}
}
/// Request for `CreateFile`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateFileRequest {
/// Optional. Metadata for the file to create.
#[prost(message, optional, tag = "1")]
pub file: ::core::option::Option<File>,
}
/// Response for `CreateFile`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateFileResponse {
/// Metadata for the created file.
#[prost(message, optional, tag = "1")]
pub file: ::core::option::Option<File>,
}
/// Request for `ListFiles`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListFilesRequest {
/// Optional. Maximum number of `File`s to return per page.
/// If unspecified, defaults to 10. Maximum `page_size` is 100.
#[prost(int32, tag = "1")]
pub page_size: i32,
/// Optional. A page token from a previous `ListFiles` call.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response for `ListFiles`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListFilesResponse {
/// The list of `File`s.
#[prost(message, repeated, tag = "1")]
pub files: ::prost::alloc::vec::Vec<File>,
/// A token that can be sent as a `page_token` into a subsequent `ListFiles`
/// call.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request for `GetFile`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetFileRequest {
/// Required. The name of the `File` to get.
/// Example: `files/abc-123`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request for `DeleteFile`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteFileRequest {
/// Required. The name of the `File` to delete.
/// Example: `files/abc-123`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod file_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API for uploading and managing files.
#[derive(Debug, Clone)]
pub struct FileServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> FileServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> FileServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
FileServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Creates a `File`.
pub async fn create_file(
&mut self,
request: impl tonic::IntoRequest<super::CreateFileRequest>,
) -> std::result::Result<
tonic::Response<super::CreateFileResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.FileService/CreateFile",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.FileService",
"CreateFile",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists the metadata for `File`s owned by the requesting project.
pub async fn list_files(
&mut self,
request: impl tonic::IntoRequest<super::ListFilesRequest>,
) -> std::result::Result<
tonic::Response<super::ListFilesResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.FileService/ListFiles",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.FileService",
"ListFiles",
),
);
self.inner.unary(req, path, codec).await
}
/// Gets the metadata for the given `File`.
pub async fn get_file(
&mut self,
request: impl tonic::IntoRequest<super::GetFileRequest>,
) -> std::result::Result<tonic::Response<super::File>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.FileService/GetFile",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.FileService",
"GetFile",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes the `File`.
pub async fn delete_file(
&mut self,
request: impl tonic::IntoRequest<super::DeleteFileRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.FileService/DeleteFile",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.FileService",
"DeleteFile",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Information about a Generative Language Model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Model {
/// Required. The resource name of the `Model`. Refer to [Model
/// variants](<https://ai.google.dev/gemini-api/docs/models/gemini#model-variations>)
/// for all allowed values.
///
/// Format: `models/{model}` with a `{model}` naming convention of:
///
/// * "{base_model_id}-{version}"
///
/// Examples:
///
/// * `models/gemini-1.5-flash-001`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. The name of the base model, pass this to the generation request.
///
/// Examples:
///
/// * `gemini-1.5-flash`
#[prost(string, tag = "2")]
pub base_model_id: ::prost::alloc::string::String,
/// Required. The version number of the model.
///
/// This represents the major version (`1.0` or `1.5`)
#[prost(string, tag = "3")]
pub version: ::prost::alloc::string::String,
/// The human-readable name of the model. E.g. "Gemini 1.5 Flash".
///
/// The name can be up to 128 characters long and can consist of any UTF-8
/// characters.
#[prost(string, tag = "4")]
pub display_name: ::prost::alloc::string::String,
/// A short description of the model.
#[prost(string, tag = "5")]
pub description: ::prost::alloc::string::String,
/// Maximum number of input tokens allowed for this model.
#[prost(int32, tag = "6")]
pub input_token_limit: i32,
/// Maximum number of output tokens available for this model.
#[prost(int32, tag = "7")]
pub output_token_limit: i32,
/// The model's supported generation methods.
///
/// The corresponding API method names are defined as Pascal case
/// strings, such as `generateMessage` and `generateContent`.
#[prost(string, repeated, tag = "8")]
pub supported_generation_methods: ::prost::alloc::vec::Vec<
::prost::alloc::string::String,
>,
/// Controls the randomness of the output.
///
/// Values can range over `\[0.0,max_temperature\]`, inclusive. A higher value
/// will produce responses that are more varied, while a value closer to `0.0`
/// will typically result in less surprising responses from the model.
/// This value specifies default to be used by the backend while making the
/// call to the model.
#[prost(float, optional, tag = "9")]
pub temperature: ::core::option::Option<f32>,
/// The maximum temperature this model can use.
#[prost(float, optional, tag = "13")]
pub max_temperature: ::core::option::Option<f32>,
/// For [Nucleus
/// sampling](<https://ai.google.dev/gemini-api/docs/prompting-strategies#top-p>).
///
/// Nucleus sampling considers the smallest set of tokens whose probability
/// sum is at least `top_p`.
/// This value specifies default to be used by the backend while making the
/// call to the model.
#[prost(float, optional, tag = "10")]
pub top_p: ::core::option::Option<f32>,
/// For Top-k sampling.
///
/// Top-k sampling considers the set of `top_k` most probable tokens.
/// This value specifies default to be used by the backend while making the
/// call to the model.
/// If empty, indicates the model doesn't use top-k sampling, and `top_k` isn't
/// allowed as a generation parameter.
#[prost(int32, optional, tag = "11")]
pub top_k: ::core::option::Option<i32>,
}
/// The base structured datatype containing multi-part content of a message.
///
/// A `Content` includes a `role` field designating the producer of the `Content`
/// and a `parts` field containing multi-part data that contains the content of
/// the message turn.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Content {
/// Ordered `Parts` that constitute a single message. Parts may have different
/// MIME types.
#[prost(message, repeated, tag = "1")]
pub parts: ::prost::alloc::vec::Vec<Part>,
/// Optional. The producer of the content. Must be either 'user' or 'model'.
///
/// Useful to set for multi-turn conversations, otherwise can be left blank
/// or unset.
#[prost(string, tag = "2")]
pub role: ::prost::alloc::string::String,
}
/// A datatype containing media that is part of a multi-part `Content` message.
///
/// A `Part` consists of data which has an associated datatype. A `Part` can only
/// contain one of the accepted types in `Part.data`.
///
/// A `Part` must have a fixed IANA MIME type identifying the type and subtype
/// of the media if the `inline_data` field is filled with raw bytes.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Part {
#[prost(oneof = "part::Data", tags = "2, 3, 4, 5, 6, 9, 10")]
pub data: ::core::option::Option<part::Data>,
}
/// Nested message and enum types in `Part`.
pub mod part {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Data {
/// Inline text.
#[prost(string, tag = "2")]
Text(::prost::alloc::string::String),
/// Inline media bytes.
#[prost(message, tag = "3")]
InlineData(super::Blob),
/// A predicted `FunctionCall` returned from the model that contains
/// a string representing the `FunctionDeclaration.name` with the
/// arguments and their values.
#[prost(message, tag = "4")]
FunctionCall(super::FunctionCall),
/// The result output of a `FunctionCall` that contains a string
/// representing the `FunctionDeclaration.name` and a structured JSON
/// object containing any output from the function is used as context to
/// the model.
#[prost(message, tag = "5")]
FunctionResponse(super::FunctionResponse),
/// URI based data.
#[prost(message, tag = "6")]
FileData(super::FileData),
/// Code generated by the model that is meant to be executed.
#[prost(message, tag = "9")]
ExecutableCode(super::ExecutableCode),
/// Result of executing the `ExecutableCode`.
#[prost(message, tag = "10")]
CodeExecutionResult(super::CodeExecutionResult),
}
}
/// Raw media bytes.
///
/// Text should not be sent as raw bytes, use the 'text' field.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Blob {
/// The IANA standard MIME type of the source data.
/// Examples:
/// - image/png
/// - image/jpeg
/// If an unsupported MIME type is provided, an error will be returned. For a
/// complete list of supported types, see [Supported file
/// formats](<https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats>).
#[prost(string, tag = "1")]
pub mime_type: ::prost::alloc::string::String,
/// Raw bytes for media formats.
#[prost(bytes = "bytes", tag = "2")]
pub data: ::prost::bytes::Bytes,
}
/// URI based data.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FileData {
/// Optional. The IANA standard MIME type of the source data.
#[prost(string, tag = "1")]
pub mime_type: ::prost::alloc::string::String,
/// Required. URI.
#[prost(string, tag = "2")]
pub file_uri: ::prost::alloc::string::String,
}
/// Code generated by the model that is meant to be executed, and the result
/// returned to the model.
///
/// Only generated when using the `CodeExecution` tool, in which the code will
/// be automatically executed, and a corresponding `CodeExecutionResult` will
/// also be generated.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecutableCode {
/// Required. Programming language of the `code`.
#[prost(enumeration = "executable_code::Language", tag = "1")]
pub language: i32,
/// Required. The code to be executed.
#[prost(string, tag = "2")]
pub code: ::prost::alloc::string::String,
}
/// Nested message and enum types in `ExecutableCode`.
pub mod executable_code {
/// Supported programming languages for the generated code.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Language {
/// Unspecified language. This value should not be used.
Unspecified = 0,
/// Python >= 3.10, with numpy and simpy available.
Python = 1,
}
impl Language {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Language::Unspecified => "LANGUAGE_UNSPECIFIED",
Language::Python => "PYTHON",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"LANGUAGE_UNSPECIFIED" => Some(Self::Unspecified),
"PYTHON" => Some(Self::Python),
_ => None,
}
}
}
}
/// Result of executing the `ExecutableCode`.
///
/// Only generated when using the `CodeExecution`, and always follows a `part`
/// containing the `ExecutableCode`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CodeExecutionResult {
/// Required. Outcome of the code execution.
#[prost(enumeration = "code_execution_result::Outcome", tag = "1")]
pub outcome: i32,
/// Optional. Contains stdout when code execution is successful, stderr or
/// other description otherwise.
#[prost(string, tag = "2")]
pub output: ::prost::alloc::string::String,
}
/// Nested message and enum types in `CodeExecutionResult`.
pub mod code_execution_result {
/// Enumeration of possible outcomes of the code execution.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Outcome {
/// Unspecified status. This value should not be used.
Unspecified = 0,
/// Code execution completed successfully.
Ok = 1,
/// Code execution finished but with a failure. `stderr` should contain the
/// reason.
Failed = 2,
/// Code execution ran for too long, and was cancelled. There may or may not
/// be a partial output present.
DeadlineExceeded = 3,
}
impl Outcome {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Outcome::Unspecified => "OUTCOME_UNSPECIFIED",
Outcome::Ok => "OUTCOME_OK",
Outcome::Failed => "OUTCOME_FAILED",
Outcome::DeadlineExceeded => "OUTCOME_DEADLINE_EXCEEDED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OUTCOME_UNSPECIFIED" => Some(Self::Unspecified),
"OUTCOME_OK" => Some(Self::Ok),
"OUTCOME_FAILED" => Some(Self::Failed),
"OUTCOME_DEADLINE_EXCEEDED" => Some(Self::DeadlineExceeded),
_ => None,
}
}
}
}
/// Tool details that the model may use to generate response.
///
/// A `Tool` is a piece of code that enables the system to interact with
/// external systems to perform an action, or set of actions, outside of
/// knowledge and scope of the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Tool {
/// Optional. A list of `FunctionDeclarations` available to the model that can
/// be used for function calling.
///
/// The model or system does not execute the function. Instead the defined
/// function may be returned as a [FunctionCall][content.part.function_call]
/// with arguments to the client side for execution. The model may decide to
/// call a subset of these functions by populating
/// [FunctionCall][content.part.function_call] in the response. The next
/// conversation turn may contain a
/// [FunctionResponse][content.part.function_response]
/// with the \[content.role\] "function" generation context for the next model
/// turn.
#[prost(message, repeated, tag = "1")]
pub function_declarations: ::prost::alloc::vec::Vec<FunctionDeclaration>,
/// Optional. Enables the model to execute code as part of generation.
#[prost(message, optional, tag = "3")]
pub code_execution: ::core::option::Option<CodeExecution>,
}
/// Tool that executes code generated by the model, and automatically returns
/// the result to the model.
///
/// See also `ExecutableCode` and `CodeExecutionResult` which are only generated
/// when using this tool.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CodeExecution {}
/// The Tool configuration containing parameters for specifying `Tool` use
/// in the request.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ToolConfig {
/// Optional. Function calling config.
#[prost(message, optional, tag = "1")]
pub function_calling_config: ::core::option::Option<FunctionCallingConfig>,
}
/// Configuration for specifying function calling behavior.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FunctionCallingConfig {
/// Optional. Specifies the mode in which function calling should execute. If
/// unspecified, the default value will be set to AUTO.
#[prost(enumeration = "function_calling_config::Mode", tag = "1")]
pub mode: i32,
/// Optional. A set of function names that, when provided, limits the functions
/// the model will call.
///
/// This should only be set when the Mode is ANY. Function names
/// should match \[FunctionDeclaration.name\]. With mode set to ANY, model will
/// predict a function call from the set of function names provided.
#[prost(string, repeated, tag = "2")]
pub allowed_function_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Nested message and enum types in `FunctionCallingConfig`.
pub mod function_calling_config {
/// Defines the execution behavior for function calling by defining the
/// execution mode.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Mode {
/// Unspecified function calling mode. This value should not be used.
Unspecified = 0,
/// Default model behavior, model decides to predict either a function call
/// or a natural language response.
Auto = 1,
/// Model is constrained to always predicting a function call only.
/// If "allowed_function_names" are set, the predicted function call will be
/// limited to any one of "allowed_function_names", else the predicted
/// function call will be any one of the provided "function_declarations".
Any = 2,
/// Model will not predict any function call. Model behavior is same as when
/// not passing any function declarations.
None = 3,
}
impl Mode {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Mode::Unspecified => "MODE_UNSPECIFIED",
Mode::Auto => "AUTO",
Mode::Any => "ANY",
Mode::None => "NONE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MODE_UNSPECIFIED" => Some(Self::Unspecified),
"AUTO" => Some(Self::Auto),
"ANY" => Some(Self::Any),
"NONE" => Some(Self::None),
_ => None,
}
}
}
}
/// Structured representation of a function declaration as defined by the
/// [OpenAPI 3.03 specification](<https://spec.openapis.org/oas/v3.0.3>). Included
/// in this declaration are the function name and parameters. This
/// FunctionDeclaration is a representation of a block of code that can be used
/// as a `Tool` by the model and executed by the client.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FunctionDeclaration {
/// Required. The name of the function.
/// Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum
/// length of 63.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. A brief description of the function.
#[prost(string, tag = "2")]
pub description: ::prost::alloc::string::String,
/// Optional. Describes the parameters to this function. Reflects the Open
/// API 3.03 Parameter Object string Key: the name of the parameter. Parameter
/// names are case sensitive. Schema Value: the Schema defining the type used
/// for the parameter.
#[prost(message, optional, tag = "3")]
pub parameters: ::core::option::Option<Schema>,
}
/// A predicted `FunctionCall` returned from the model that contains
/// a string representing the `FunctionDeclaration.name` with the
/// arguments and their values.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FunctionCall {
/// Required. The name of the function to call.
/// Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum
/// length of 63.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. The function parameters and values in JSON object format.
#[prost(message, optional, tag = "2")]
pub args: ::core::option::Option<::prost_types::Struct>,
}
/// The result output from a `FunctionCall` that contains a string
/// representing the `FunctionDeclaration.name` and a structured JSON
/// object containing any output from the function is used as context to
/// the model. This should contain the result of a`FunctionCall` made
/// based on model prediction.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FunctionResponse {
/// Required. The name of the function to call.
/// Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum
/// length of 63.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. The function response in JSON object format.
#[prost(message, optional, tag = "2")]
pub response: ::core::option::Option<::prost_types::Struct>,
}
/// The `Schema` object allows the definition of input and output data types.
/// These types can be objects, but also primitives and arrays.
/// Represents a select subset of an [OpenAPI 3.0 schema
/// object](<https://spec.openapis.org/oas/v3.0.3#schema>).
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Schema {
/// Required. Data type.
#[prost(enumeration = "Type", tag = "1")]
pub r#type: i32,
/// Optional. The format of the data. This is used only for primitive
/// datatypes. Supported formats:
/// for NUMBER type: float, double
/// for INTEGER type: int32, int64
/// for STRING type: enum
#[prost(string, tag = "2")]
pub format: ::prost::alloc::string::String,
/// Optional. A brief description of the parameter. This could contain examples
/// of use. Parameter description may be formatted as Markdown.
#[prost(string, tag = "3")]
pub description: ::prost::alloc::string::String,
/// Optional. Indicates if the value may be null.
#[prost(bool, tag = "4")]
pub nullable: bool,
/// Optional. Possible values of the element of Type.STRING with enum format.
/// For example we can define an Enum Direction as :
/// {type:STRING, format:enum, enum:\["EAST", NORTH", "SOUTH", "WEST"\]}
#[prost(string, repeated, tag = "5")]
pub r#enum: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional. Schema of the elements of Type.ARRAY.
#[prost(message, optional, boxed, tag = "6")]
pub items: ::core::option::Option<::prost::alloc::boxed::Box<Schema>>,
/// Optional. Maximum number of the elements for Type.ARRAY.
#[prost(int64, tag = "21")]
pub max_items: i64,
/// Optional. Properties of Type.OBJECT.
#[prost(btree_map = "string, message", tag = "7")]
pub properties: ::prost::alloc::collections::BTreeMap<
::prost::alloc::string::String,
Schema,
>,
/// Optional. Required properties of Type.OBJECT.
#[prost(string, repeated, tag = "8")]
pub required: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Passage included inline with a grounding configuration.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GroundingPassage {
/// Identifier for the passage for attributing this passage in grounded
/// answers.
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// Content of the passage.
#[prost(message, optional, tag = "2")]
pub content: ::core::option::Option<Content>,
}
/// A repeated list of passages.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GroundingPassages {
/// List of passages.
#[prost(message, repeated, tag = "1")]
pub passages: ::prost::alloc::vec::Vec<GroundingPassage>,
}
/// Type contains the list of OpenAPI data types as defined by
/// <https://spec.openapis.org/oas/v3.0.3#data-types>
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Type {
/// Not specified, should not be used.
Unspecified = 0,
/// String type.
String = 1,
/// Number type.
Number = 2,
/// Integer type.
Integer = 3,
/// Boolean type.
Boolean = 4,
/// Array type.
Array = 5,
/// Object type.
Object = 6,
}
impl Type {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Type::Unspecified => "TYPE_UNSPECIFIED",
Type::String => "STRING",
Type::Number => "NUMBER",
Type::Integer => "INTEGER",
Type::Boolean => "BOOLEAN",
Type::Array => "ARRAY",
Type::Object => "OBJECT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"STRING" => Some(Self::String),
"NUMBER" => Some(Self::Number),
"INTEGER" => Some(Self::Integer),
"BOOLEAN" => Some(Self::Boolean),
"ARRAY" => Some(Self::Array),
"OBJECT" => Some(Self::Object),
_ => None,
}
}
}
/// A `Corpus` is a collection of `Document`s.
/// A project can create up to 5 corpora.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Corpus {
/// Immutable. Identifier. The `Corpus` resource name. The ID (name excluding
/// the "corpora/" prefix) can contain up to 40 characters that are lowercase
/// alphanumeric or dashes
/// (-). The ID cannot start or end with a dash. If the name is empty on
/// create, a unique name will be derived from `display_name` along with a 12
/// character random suffix.
/// Example: `corpora/my-awesome-corpora-123a456b789c`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. The human-readable display name for the `Corpus`. The display
/// name must be no more than 512 characters in length, including spaces.
/// Example: "Docs on Semantic Retriever"
#[prost(string, tag = "2")]
pub display_name: ::prost::alloc::string::String,
/// Output only. The Timestamp of when the `Corpus` was created.
#[prost(message, optional, tag = "3")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. The Timestamp of when the `Corpus` was last updated.
#[prost(message, optional, tag = "4")]
pub update_time: ::core::option::Option<::prost_types::Timestamp>,
}
/// A `Document` is a collection of `Chunk`s.
/// A `Corpus` can have a maximum of 10,000 `Document`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Document {
/// Immutable. Identifier. The `Document` resource name. The ID (name excluding
/// the "corpora/*/documents/" prefix) can contain up to 40 characters that are
/// lowercase alphanumeric or dashes (-). The ID cannot start or end with a
/// dash. If the name is empty on create, a unique name will be derived from
/// `display_name` along with a 12 character random suffix.
/// Example: `corpora/{corpus_id}/documents/my-awesome-doc-123a456b789c`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. The human-readable display name for the `Document`. The display
/// name must be no more than 512 characters in length, including spaces.
/// Example: "Semantic Retriever Documentation"
#[prost(string, tag = "2")]
pub display_name: ::prost::alloc::string::String,
/// Optional. User provided custom metadata stored as key-value pairs used for
/// querying. A `Document` can have a maximum of 20 `CustomMetadata`.
#[prost(message, repeated, tag = "3")]
pub custom_metadata: ::prost::alloc::vec::Vec<CustomMetadata>,
/// Output only. The Timestamp of when the `Document` was last updated.
#[prost(message, optional, tag = "4")]
pub update_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. The Timestamp of when the `Document` was created.
#[prost(message, optional, tag = "5")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
}
/// User provided string values assigned to a single metadata key.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StringList {
/// The string values of the metadata to store.
#[prost(string, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// User provided metadata stored as key-value pairs.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CustomMetadata {
/// Required. The key of the metadata to store.
#[prost(string, tag = "1")]
pub key: ::prost::alloc::string::String,
#[prost(oneof = "custom_metadata::Value", tags = "2, 6, 7")]
pub value: ::core::option::Option<custom_metadata::Value>,
}
/// Nested message and enum types in `CustomMetadata`.
pub mod custom_metadata {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
/// The string value of the metadata to store.
#[prost(string, tag = "2")]
StringValue(::prost::alloc::string::String),
/// The StringList value of the metadata to store.
#[prost(message, tag = "6")]
StringListValue(super::StringList),
/// The numeric value of the metadata to store.
#[prost(float, tag = "7")]
NumericValue(f32),
}
}
/// User provided filter to limit retrieval based on `Chunk` or `Document` level
/// metadata values.
/// Example (genre = drama OR genre = action):
/// key = "document.custom_metadata.genre"
/// conditions = [{string_value = "drama", operation = EQUAL},
/// {string_value = "action", operation = EQUAL}]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MetadataFilter {
/// Required. The key of the metadata to filter on.
#[prost(string, tag = "1")]
pub key: ::prost::alloc::string::String,
/// Required. The `Condition`s for the given key that will trigger this filter.
/// Multiple `Condition`s are joined by logical ORs.
#[prost(message, repeated, tag = "2")]
pub conditions: ::prost::alloc::vec::Vec<Condition>,
}
/// Filter condition applicable to a single key.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Condition {
/// Required. Operator applied to the given key-value pair to trigger the
/// condition.
#[prost(enumeration = "condition::Operator", tag = "5")]
pub operation: i32,
/// The value type must be consistent with the value type defined in the field
/// for the corresponding key. If the value types are not consistent, the
/// result will be an empty set. When the `CustomMetadata` has a `StringList`
/// value type, the filtering condition should use `string_value` paired with
/// an INCLUDES/EXCLUDES operation, otherwise the result will also be an empty
/// set.
#[prost(oneof = "condition::Value", tags = "1, 6")]
pub value: ::core::option::Option<condition::Value>,
}
/// Nested message and enum types in `Condition`.
pub mod condition {
/// Defines the valid operators that can be applied to a key-value pair.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Operator {
/// The default value. This value is unused.
Unspecified = 0,
/// Supported by numeric.
Less = 1,
/// Supported by numeric.
LessEqual = 2,
/// Supported by numeric & string.
Equal = 3,
/// Supported by numeric.
GreaterEqual = 4,
/// Supported by numeric.
Greater = 5,
/// Supported by numeric & string.
NotEqual = 6,
/// Supported by string only when `CustomMetadata` value type for the given
/// key has a `string_list_value`.
Includes = 7,
/// Supported by string only when `CustomMetadata` value type for the given
/// key has a `string_list_value`.
Excludes = 8,
}
impl Operator {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Operator::Unspecified => "OPERATOR_UNSPECIFIED",
Operator::Less => "LESS",
Operator::LessEqual => "LESS_EQUAL",
Operator::Equal => "EQUAL",
Operator::GreaterEqual => "GREATER_EQUAL",
Operator::Greater => "GREATER",
Operator::NotEqual => "NOT_EQUAL",
Operator::Includes => "INCLUDES",
Operator::Excludes => "EXCLUDES",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OPERATOR_UNSPECIFIED" => Some(Self::Unspecified),
"LESS" => Some(Self::Less),
"LESS_EQUAL" => Some(Self::LessEqual),
"EQUAL" => Some(Self::Equal),
"GREATER_EQUAL" => Some(Self::GreaterEqual),
"GREATER" => Some(Self::Greater),
"NOT_EQUAL" => Some(Self::NotEqual),
"INCLUDES" => Some(Self::Includes),
"EXCLUDES" => Some(Self::Excludes),
_ => None,
}
}
}
/// The value type must be consistent with the value type defined in the field
/// for the corresponding key. If the value types are not consistent, the
/// result will be an empty set. When the `CustomMetadata` has a `StringList`
/// value type, the filtering condition should use `string_value` paired with
/// an INCLUDES/EXCLUDES operation, otherwise the result will also be an empty
/// set.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
/// The string value to filter the metadata on.
#[prost(string, tag = "1")]
StringValue(::prost::alloc::string::String),
/// The numeric value to filter the metadata on.
#[prost(float, tag = "6")]
NumericValue(f32),
}
}
/// A `Chunk` is a subpart of a `Document` that is treated as an independent unit
/// for the purposes of vector representation and storage.
/// A `Corpus` can have a maximum of 1 million `Chunk`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Chunk {
/// Immutable. Identifier. The `Chunk` resource name. The ID (name excluding
/// the "corpora/*/documents/*/chunks/" prefix) can contain up to 40 characters
/// that are lowercase alphanumeric or dashes (-). The ID cannot start or end
/// with a dash. If the name is empty on create, a random 12-character unique
/// ID will be generated.
/// Example: `corpora/{corpus_id}/documents/{document_id}/chunks/123a456b789c`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. The content for the `Chunk`, such as the text string.
/// The maximum number of tokens per chunk is 2043.
#[prost(message, optional, tag = "2")]
pub data: ::core::option::Option<ChunkData>,
/// Optional. User provided custom metadata stored as key-value pairs.
/// The maximum number of `CustomMetadata` per chunk is 20.
#[prost(message, repeated, tag = "3")]
pub custom_metadata: ::prost::alloc::vec::Vec<CustomMetadata>,
/// Output only. The Timestamp of when the `Chunk` was created.
#[prost(message, optional, tag = "4")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. The Timestamp of when the `Chunk` was last updated.
#[prost(message, optional, tag = "5")]
pub update_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. Current state of the `Chunk`.
#[prost(enumeration = "chunk::State", tag = "6")]
pub state: i32,
}
/// Nested message and enum types in `Chunk`.
pub mod chunk {
/// States for the lifecycle of a `Chunk`.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum State {
/// The default value. This value is used if the state is omitted.
Unspecified = 0,
/// `Chunk` is being processed (embedding and vector storage).
PendingProcessing = 1,
/// `Chunk` is processed and available for querying.
Active = 2,
/// `Chunk` failed processing.
Failed = 10,
}
impl State {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
State::Unspecified => "STATE_UNSPECIFIED",
State::PendingProcessing => "STATE_PENDING_PROCESSING",
State::Active => "STATE_ACTIVE",
State::Failed => "STATE_FAILED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STATE_UNSPECIFIED" => Some(Self::Unspecified),
"STATE_PENDING_PROCESSING" => Some(Self::PendingProcessing),
"STATE_ACTIVE" => Some(Self::Active),
"STATE_FAILED" => Some(Self::Failed),
_ => None,
}
}
}
}
/// Extracted data that represents the `Chunk` content.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChunkData {
#[prost(oneof = "chunk_data::Data", tags = "1")]
pub data: ::core::option::Option<chunk_data::Data>,
}
/// Nested message and enum types in `ChunkData`.
pub mod chunk_data {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Data {
/// The `Chunk` content as a string.
/// The maximum number of tokens per chunk is 2043.
#[prost(string, tag = "1")]
StringValue(::prost::alloc::string::String),
}
}
/// Request to create a `Corpus`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateCorpusRequest {
/// Required. The `Corpus` to create.
#[prost(message, optional, tag = "1")]
pub corpus: ::core::option::Option<Corpus>,
}
/// Request for getting information about a specific `Corpus`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetCorpusRequest {
/// Required. The name of the `Corpus`.
/// Example: `corpora/my-corpus-123`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request to update a `Corpus`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateCorpusRequest {
/// Required. The `Corpus` to update.
#[prost(message, optional, tag = "1")]
pub corpus: ::core::option::Option<Corpus>,
/// Required. The list of fields to update.
/// Currently, this only supports updating `display_name`.
#[prost(message, optional, tag = "2")]
pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request to delete a `Corpus`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteCorpusRequest {
/// Required. The resource name of the `Corpus`.
/// Example: `corpora/my-corpus-123`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. If set to true, any `Document`s and objects related to this
/// `Corpus` will also be deleted.
///
/// If false (the default), a `FAILED_PRECONDITION` error will be returned if
/// `Corpus` contains any `Document`s.
#[prost(bool, tag = "2")]
pub force: bool,
}
/// Request for listing `Corpora`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListCorporaRequest {
/// Optional. The maximum number of `Corpora` to return (per page).
/// The service may return fewer `Corpora`.
///
/// If unspecified, at most 10 `Corpora` will be returned.
/// The maximum size limit is 20 `Corpora` per page.
#[prost(int32, tag = "1")]
pub page_size: i32,
/// Optional. A page token, received from a previous `ListCorpora` call.
///
/// Provide the `next_page_token` returned in the response as an argument to
/// the next request to retrieve the next page.
///
/// When paginating, all other parameters provided to `ListCorpora`
/// must match the call that provided the page token.
#[prost(string, tag = "2")]
pub page_token: ::prost::alloc::string::String,
}
/// Response from `ListCorpora` containing a paginated list of `Corpora`.
/// The results are sorted by ascending `corpus.create_time`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListCorporaResponse {
/// The returned corpora.
#[prost(message, repeated, tag = "1")]
pub corpora: ::prost::alloc::vec::Vec<Corpus>,
/// A token, which can be sent as `page_token` to retrieve the next page.
/// If this field is omitted, there are no more pages.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request for querying a `Corpus`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryCorpusRequest {
/// Required. The name of the `Corpus` to query.
/// Example: `corpora/my-corpus-123`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. Query string to perform semantic search.
#[prost(string, tag = "2")]
pub query: ::prost::alloc::string::String,
/// Optional. Filter for `Chunk` and `Document` metadata. Each `MetadataFilter`
/// object should correspond to a unique key. Multiple `MetadataFilter` objects
/// are joined by logical "AND"s.
///
/// Example query at document level:
/// (year >= 2020 OR year < 2010) AND (genre = drama OR genre = action)
///
/// `MetadataFilter` object list:
/// metadata_filters = [
/// {key = "document.custom_metadata.year"
/// conditions = [{int_value = 2020, operation = GREATER_EQUAL},
/// {int_value = 2010, operation = LESS}]},
/// {key = "document.custom_metadata.year"
/// conditions = [{int_value = 2020, operation = GREATER_EQUAL},
/// {int_value = 2010, operation = LESS}]},
/// {key = "document.custom_metadata.genre"
/// conditions = [{string_value = "drama", operation = EQUAL},
/// {string_value = "action", operation = EQUAL}]}]
///
/// Example query at chunk level for a numeric range of values:
/// (year > 2015 AND year <= 2020)
///
/// `MetadataFilter` object list:
/// metadata_filters = [
/// {key = "chunk.custom_metadata.year"
/// conditions = \[{int_value = 2015, operation = GREATER}\]},
/// {key = "chunk.custom_metadata.year"
/// conditions = \[{int_value = 2020, operation = LESS_EQUAL}\]}]
///
/// Note: "AND"s for the same key are only supported for numeric values. String
/// values only support "OR"s for the same key.
#[prost(message, repeated, tag = "3")]
pub metadata_filters: ::prost::alloc::vec::Vec<MetadataFilter>,
/// Optional. The maximum number of `Chunk`s to return.
/// The service may return fewer `Chunk`s.
///
/// If unspecified, at most 10 `Chunk`s will be returned.
/// The maximum specified result count is 100.
#[prost(int32, tag = "4")]
pub results_count: i32,
}
/// Response from `QueryCorpus` containing a list of relevant chunks.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryCorpusResponse {
/// The relevant chunks.
#[prost(message, repeated, tag = "1")]
pub relevant_chunks: ::prost::alloc::vec::Vec<RelevantChunk>,
}
/// The information for a chunk relevant to a query.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RelevantChunk {
/// `Chunk` relevance to the query.
#[prost(float, tag = "1")]
pub chunk_relevance_score: f32,
/// `Chunk` associated with the query.
#[prost(message, optional, tag = "2")]
pub chunk: ::core::option::Option<Chunk>,
}
/// Request to create a `Document`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateDocumentRequest {
/// Required. The name of the `Corpus` where this `Document` will be created.
/// Example: `corpora/my-corpus-123`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Required. The `Document` to create.
#[prost(message, optional, tag = "2")]
pub document: ::core::option::Option<Document>,
}
/// Request for getting information about a specific `Document`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDocumentRequest {
/// Required. The name of the `Document` to retrieve.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request to update a `Document`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateDocumentRequest {
/// Required. The `Document` to update.
#[prost(message, optional, tag = "1")]
pub document: ::core::option::Option<Document>,
/// Required. The list of fields to update.
/// Currently, this only supports updating `display_name` and
/// `custom_metadata`.
#[prost(message, optional, tag = "2")]
pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request to delete a `Document`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteDocumentRequest {
/// Required. The resource name of the `Document` to delete.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. If set to true, any `Chunk`s and objects related to this
/// `Document` will also be deleted.
///
/// If false (the default), a `FAILED_PRECONDITION` error will be returned if
/// `Document` contains any `Chunk`s.
#[prost(bool, tag = "2")]
pub force: bool,
}
/// Request for listing `Document`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListDocumentsRequest {
/// Required. The name of the `Corpus` containing `Document`s.
/// Example: `corpora/my-corpus-123`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Optional. The maximum number of `Document`s to return (per page).
/// The service may return fewer `Document`s.
///
/// If unspecified, at most 10 `Document`s will be returned.
/// The maximum size limit is 20 `Document`s per page.
#[prost(int32, tag = "2")]
pub page_size: i32,
/// Optional. A page token, received from a previous `ListDocuments` call.
///
/// Provide the `next_page_token` returned in the response as an argument to
/// the next request to retrieve the next page.
///
/// When paginating, all other parameters provided to `ListDocuments`
/// must match the call that provided the page token.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response from `ListDocuments` containing a paginated list of `Document`s.
/// The `Document`s are sorted by ascending `document.create_time`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListDocumentsResponse {
/// The returned `Document`s.
#[prost(message, repeated, tag = "1")]
pub documents: ::prost::alloc::vec::Vec<Document>,
/// A token, which can be sent as `page_token` to retrieve the next page.
/// If this field is omitted, there are no more pages.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request for querying a `Document`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDocumentRequest {
/// Required. The name of the `Document` to query.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. Query string to perform semantic search.
#[prost(string, tag = "2")]
pub query: ::prost::alloc::string::String,
/// Optional. The maximum number of `Chunk`s to return.
/// The service may return fewer `Chunk`s.
///
/// If unspecified, at most 10 `Chunk`s will be returned.
/// The maximum specified result count is 100.
#[prost(int32, tag = "3")]
pub results_count: i32,
/// Optional. Filter for `Chunk` metadata. Each `MetadataFilter` object should
/// correspond to a unique key. Multiple `MetadataFilter` objects are joined by
/// logical "AND"s.
///
/// Note: `Document`-level filtering is not supported for this request because
/// a `Document` name is already specified.
///
/// Example query:
/// (year >= 2020 OR year < 2010) AND (genre = drama OR genre = action)
///
/// `MetadataFilter` object list:
/// metadata_filters = [
/// {key = "chunk.custom_metadata.year"
/// conditions = [{int_value = 2020, operation = GREATER_EQUAL},
/// {int_value = 2010, operation = LESS}},
/// {key = "chunk.custom_metadata.genre"
/// conditions = [{string_value = "drama", operation = EQUAL},
/// {string_value = "action", operation = EQUAL}}]
///
/// Example query for a numeric range of values:
/// (year > 2015 AND year <= 2020)
///
/// `MetadataFilter` object list:
/// metadata_filters = [
/// {key = "chunk.custom_metadata.year"
/// conditions = \[{int_value = 2015, operation = GREATER}\]},
/// {key = "chunk.custom_metadata.year"
/// conditions = \[{int_value = 2020, operation = LESS_EQUAL}\]}]
///
/// Note: "AND"s for the same key are only supported for numeric values. String
/// values only support "OR"s for the same key.
#[prost(message, repeated, tag = "4")]
pub metadata_filters: ::prost::alloc::vec::Vec<MetadataFilter>,
}
/// Response from `QueryDocument` containing a list of relevant chunks.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryDocumentResponse {
/// The returned relevant chunks.
#[prost(message, repeated, tag = "1")]
pub relevant_chunks: ::prost::alloc::vec::Vec<RelevantChunk>,
}
/// Request to create a `Chunk`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateChunkRequest {
/// Required. The name of the `Document` where this `Chunk` will be created.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Required. The `Chunk` to create.
#[prost(message, optional, tag = "2")]
pub chunk: ::core::option::Option<Chunk>,
}
/// Request to batch create `Chunk`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCreateChunksRequest {
/// Optional. The name of the `Document` where this batch of `Chunk`s will be
/// created. The parent field in every `CreateChunkRequest` must match this
/// value. Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Required. The request messages specifying the `Chunk`s to create.
/// A maximum of 100 `Chunk`s can be created in a batch.
#[prost(message, repeated, tag = "2")]
pub requests: ::prost::alloc::vec::Vec<CreateChunkRequest>,
}
/// Response from `BatchCreateChunks` containing a list of created `Chunk`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCreateChunksResponse {
/// `Chunk`s created.
#[prost(message, repeated, tag = "1")]
pub chunks: ::prost::alloc::vec::Vec<Chunk>,
}
/// Request for getting information about a specific `Chunk`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetChunkRequest {
/// Required. The name of the `Chunk` to retrieve.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request to update a `Chunk`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateChunkRequest {
/// Required. The `Chunk` to update.
#[prost(message, optional, tag = "1")]
pub chunk: ::core::option::Option<Chunk>,
/// Required. The list of fields to update.
/// Currently, this only supports updating `custom_metadata` and `data`.
#[prost(message, optional, tag = "2")]
pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request to batch update `Chunk`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchUpdateChunksRequest {
/// Optional. The name of the `Document` containing the `Chunk`s to update.
/// The parent field in every `UpdateChunkRequest` must match this value.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Required. The request messages specifying the `Chunk`s to update.
/// A maximum of 100 `Chunk`s can be updated in a batch.
#[prost(message, repeated, tag = "2")]
pub requests: ::prost::alloc::vec::Vec<UpdateChunkRequest>,
}
/// Response from `BatchUpdateChunks` containing a list of updated `Chunk`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchUpdateChunksResponse {
/// `Chunk`s updated.
#[prost(message, repeated, tag = "1")]
pub chunks: ::prost::alloc::vec::Vec<Chunk>,
}
/// Request to delete a `Chunk`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteChunkRequest {
/// Required. The resource name of the `Chunk` to delete.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request to batch delete `Chunk`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchDeleteChunksRequest {
/// Optional. The name of the `Document` containing the `Chunk`s to delete.
/// The parent field in every `DeleteChunkRequest` must match this value.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Required. The request messages specifying the `Chunk`s to delete.
#[prost(message, repeated, tag = "2")]
pub requests: ::prost::alloc::vec::Vec<DeleteChunkRequest>,
}
/// Request for listing `Chunk`s.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListChunksRequest {
/// Required. The name of the `Document` containing `Chunk`s.
/// Example: `corpora/my-corpus-123/documents/the-doc-abc`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Optional. The maximum number of `Chunk`s to return (per page).
/// The service may return fewer `Chunk`s.
///
/// If unspecified, at most 10 `Chunk`s will be returned.
/// The maximum size limit is 100 `Chunk`s per page.
#[prost(int32, tag = "2")]
pub page_size: i32,
/// Optional. A page token, received from a previous `ListChunks` call.
///
/// Provide the `next_page_token` returned in the response as an argument to
/// the next request to retrieve the next page.
///
/// When paginating, all other parameters provided to `ListChunks`
/// must match the call that provided the page token.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response from `ListChunks` containing a paginated list of `Chunk`s.
/// The `Chunk`s are sorted by ascending `chunk.create_time`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListChunksResponse {
/// The returned `Chunk`s.
#[prost(message, repeated, tag = "1")]
pub chunks: ::prost::alloc::vec::Vec<Chunk>,
/// A token, which can be sent as `page_token` to retrieve the next page.
/// If this field is omitted, there are no more pages.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod retriever_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API for semantic search over a corpus of user uploaded content.
#[derive(Debug, Clone)]
pub struct RetrieverServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> RetrieverServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> RetrieverServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
RetrieverServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Creates an empty `Corpus`.
pub async fn create_corpus(
&mut self,
request: impl tonic::IntoRequest<super::CreateCorpusRequest>,
) -> std::result::Result<tonic::Response<super::Corpus>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/CreateCorpus",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"CreateCorpus",
),
);
self.inner.unary(req, path, codec).await
}
/// Gets information about a specific `Corpus`.
pub async fn get_corpus(
&mut self,
request: impl tonic::IntoRequest<super::GetCorpusRequest>,
) -> std::result::Result<tonic::Response<super::Corpus>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/GetCorpus",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"GetCorpus",
),
);
self.inner.unary(req, path, codec).await
}
/// Updates a `Corpus`.
pub async fn update_corpus(
&mut self,
request: impl tonic::IntoRequest<super::UpdateCorpusRequest>,
) -> std::result::Result<tonic::Response<super::Corpus>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/UpdateCorpus",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"UpdateCorpus",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes a `Corpus`.
pub async fn delete_corpus(
&mut self,
request: impl tonic::IntoRequest<super::DeleteCorpusRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/DeleteCorpus",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"DeleteCorpus",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists all `Corpora` owned by the user.
pub async fn list_corpora(
&mut self,
request: impl tonic::IntoRequest<super::ListCorporaRequest>,
) -> std::result::Result<
tonic::Response<super::ListCorporaResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/ListCorpora",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"ListCorpora",
),
);
self.inner.unary(req, path, codec).await
}
/// Performs semantic search over a `Corpus`.
pub async fn query_corpus(
&mut self,
request: impl tonic::IntoRequest<super::QueryCorpusRequest>,
) -> std::result::Result<
tonic::Response<super::QueryCorpusResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/QueryCorpus",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"QueryCorpus",
),
);
self.inner.unary(req, path, codec).await
}
/// Creates an empty `Document`.
pub async fn create_document(
&mut self,
request: impl tonic::IntoRequest<super::CreateDocumentRequest>,
) -> std::result::Result<tonic::Response<super::Document>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/CreateDocument",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"CreateDocument",
),
);
self.inner.unary(req, path, codec).await
}
/// Gets information about a specific `Document`.
pub async fn get_document(
&mut self,
request: impl tonic::IntoRequest<super::GetDocumentRequest>,
) -> std::result::Result<tonic::Response<super::Document>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/GetDocument",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"GetDocument",
),
);
self.inner.unary(req, path, codec).await
}
/// Updates a `Document`.
pub async fn update_document(
&mut self,
request: impl tonic::IntoRequest<super::UpdateDocumentRequest>,
) -> std::result::Result<tonic::Response<super::Document>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/UpdateDocument",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"UpdateDocument",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes a `Document`.
pub async fn delete_document(
&mut self,
request: impl tonic::IntoRequest<super::DeleteDocumentRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/DeleteDocument",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"DeleteDocument",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists all `Document`s in a `Corpus`.
pub async fn list_documents(
&mut self,
request: impl tonic::IntoRequest<super::ListDocumentsRequest>,
) -> std::result::Result<
tonic::Response<super::ListDocumentsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/ListDocuments",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"ListDocuments",
),
);
self.inner.unary(req, path, codec).await
}
/// Performs semantic search over a `Document`.
pub async fn query_document(
&mut self,
request: impl tonic::IntoRequest<super::QueryDocumentRequest>,
) -> std::result::Result<
tonic::Response<super::QueryDocumentResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/QueryDocument",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"QueryDocument",
),
);
self.inner.unary(req, path, codec).await
}
/// Creates a `Chunk`.
pub async fn create_chunk(
&mut self,
request: impl tonic::IntoRequest<super::CreateChunkRequest>,
) -> std::result::Result<tonic::Response<super::Chunk>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/CreateChunk",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"CreateChunk",
),
);
self.inner.unary(req, path, codec).await
}
/// Batch create `Chunk`s.
pub async fn batch_create_chunks(
&mut self,
request: impl tonic::IntoRequest<super::BatchCreateChunksRequest>,
) -> std::result::Result<
tonic::Response<super::BatchCreateChunksResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/BatchCreateChunks",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"BatchCreateChunks",
),
);
self.inner.unary(req, path, codec).await
}
/// Gets information about a specific `Chunk`.
pub async fn get_chunk(
&mut self,
request: impl tonic::IntoRequest<super::GetChunkRequest>,
) -> std::result::Result<tonic::Response<super::Chunk>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/GetChunk",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"GetChunk",
),
);
self.inner.unary(req, path, codec).await
}
/// Updates a `Chunk`.
pub async fn update_chunk(
&mut self,
request: impl tonic::IntoRequest<super::UpdateChunkRequest>,
) -> std::result::Result<tonic::Response<super::Chunk>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/UpdateChunk",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"UpdateChunk",
),
);
self.inner.unary(req, path, codec).await
}
/// Batch update `Chunk`s.
pub async fn batch_update_chunks(
&mut self,
request: impl tonic::IntoRequest<super::BatchUpdateChunksRequest>,
) -> std::result::Result<
tonic::Response<super::BatchUpdateChunksResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/BatchUpdateChunks",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"BatchUpdateChunks",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes a `Chunk`.
pub async fn delete_chunk(
&mut self,
request: impl tonic::IntoRequest<super::DeleteChunkRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/DeleteChunk",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"DeleteChunk",
),
);
self.inner.unary(req, path, codec).await
}
/// Batch delete `Chunk`s.
pub async fn batch_delete_chunks(
&mut self,
request: impl tonic::IntoRequest<super::BatchDeleteChunksRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/BatchDeleteChunks",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"BatchDeleteChunks",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists all `Chunk`s in a `Document`.
pub async fn list_chunks(
&mut self,
request: impl tonic::IntoRequest<super::ListChunksRequest>,
) -> std::result::Result<
tonic::Response<super::ListChunksResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.RetrieverService/ListChunks",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.RetrieverService",
"ListChunks",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// A fine-tuned model created using ModelService.CreateTunedModel.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TunedModel {
/// Output only. The tuned model name. A unique name will be generated on
/// create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on
/// create, the id portion of the name will be set by concatenating the words
/// of the display_name with hyphens and adding a random portion for
/// uniqueness.
///
/// Example:
///
/// * display_name = `Sentence Translator`
/// * name = `tunedModels/sentence-translator-u3b7m`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Optional. The name to display for this model in user interfaces.
/// The display name must be up to 40 characters including spaces.
#[prost(string, tag = "5")]
pub display_name: ::prost::alloc::string::String,
/// Optional. A short description of this model.
#[prost(string, tag = "6")]
pub description: ::prost::alloc::string::String,
/// Optional. Controls the randomness of the output.
///
/// Values can range over `\[0.0,1.0\]`, inclusive. A value closer to `1.0` will
/// produce responses that are more varied, while a value closer to `0.0` will
/// typically result in less surprising responses from the model.
///
/// This value specifies default to be the one used by the base model while
/// creating the model.
#[prost(float, optional, tag = "11")]
pub temperature: ::core::option::Option<f32>,
/// Optional. For Nucleus sampling.
///
/// Nucleus sampling considers the smallest set of tokens whose probability
/// sum is at least `top_p`.
///
/// This value specifies default to be the one used by the base model while
/// creating the model.
#[prost(float, optional, tag = "12")]
pub top_p: ::core::option::Option<f32>,
/// Optional. For Top-k sampling.
///
/// Top-k sampling considers the set of `top_k` most probable tokens.
/// This value specifies default to be used by the backend while making the
/// call to the model.
///
/// This value specifies default to be the one used by the base model while
/// creating the model.
#[prost(int32, optional, tag = "13")]
pub top_k: ::core::option::Option<i32>,
/// Output only. The state of the tuned model.
#[prost(enumeration = "tuned_model::State", tag = "7")]
pub state: i32,
/// Output only. The timestamp when this model was created.
#[prost(message, optional, tag = "8")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. The timestamp when this model was updated.
#[prost(message, optional, tag = "9")]
pub update_time: ::core::option::Option<::prost_types::Timestamp>,
/// Required. The tuning task that creates the tuned model.
#[prost(message, optional, tag = "10")]
pub tuning_task: ::core::option::Option<TuningTask>,
/// The model used as the starting point for tuning.
#[prost(oneof = "tuned_model::SourceModel", tags = "3, 4")]
pub source_model: ::core::option::Option<tuned_model::SourceModel>,
}
/// Nested message and enum types in `TunedModel`.
pub mod tuned_model {
/// The state of the tuned model.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum State {
/// The default value. This value is unused.
Unspecified = 0,
/// The model is being created.
Creating = 1,
/// The model is ready to be used.
Active = 2,
/// The model failed to be created.
Failed = 3,
}
impl State {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
State::Unspecified => "STATE_UNSPECIFIED",
State::Creating => "CREATING",
State::Active => "ACTIVE",
State::Failed => "FAILED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STATE_UNSPECIFIED" => Some(Self::Unspecified),
"CREATING" => Some(Self::Creating),
"ACTIVE" => Some(Self::Active),
"FAILED" => Some(Self::Failed),
_ => None,
}
}
}
/// The model used as the starting point for tuning.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum SourceModel {
/// Optional. TunedModel to use as the starting point for training the new
/// model.
#[prost(message, tag = "3")]
TunedModelSource(super::TunedModelSource),
/// Immutable. The name of the `Model` to tune.
/// Example: `models/gemini-1.5-flash-001`
#[prost(string, tag = "4")]
BaseModel(::prost::alloc::string::String),
}
}
/// Tuned model as a source for training a new model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TunedModelSource {
/// Immutable. The name of the `TunedModel` to use as the starting point for
/// training the new model.
/// Example: `tunedModels/my-tuned-model`
#[prost(string, tag = "1")]
pub tuned_model: ::prost::alloc::string::String,
/// Output only. The name of the base `Model` this `TunedModel` was tuned from.
/// Example: `models/gemini-1.5-flash-001`
#[prost(string, tag = "2")]
pub base_model: ::prost::alloc::string::String,
}
/// Tuning tasks that create tuned models.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TuningTask {
/// Output only. The timestamp when tuning this model started.
#[prost(message, optional, tag = "1")]
pub start_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. The timestamp when tuning this model completed.
#[prost(message, optional, tag = "2")]
pub complete_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. Metrics collected during tuning.
#[prost(message, repeated, tag = "3")]
pub snapshots: ::prost::alloc::vec::Vec<TuningSnapshot>,
/// Required. Input only. Immutable. The model training data.
#[prost(message, optional, tag = "4")]
pub training_data: ::core::option::Option<Dataset>,
/// Immutable. Hyperparameters controlling the tuning process. If not provided,
/// default values will be used.
#[prost(message, optional, tag = "5")]
pub hyperparameters: ::core::option::Option<Hyperparameters>,
}
/// Hyperparameters controlling the tuning process. Read more at
/// <https://ai.google.dev/docs/model_tuning_guidance>
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Hyperparameters {
/// Immutable. The number of training epochs. An epoch is one pass through the
/// training data. If not set, a default of 5 will be used.
#[prost(int32, optional, tag = "14")]
pub epoch_count: ::core::option::Option<i32>,
/// Immutable. The batch size hyperparameter for tuning.
/// If not set, a default of 4 or 16 will be used based on the number of
/// training examples.
#[prost(int32, optional, tag = "15")]
pub batch_size: ::core::option::Option<i32>,
/// Options for specifying learning rate during tuning.
#[prost(oneof = "hyperparameters::LearningRateOption", tags = "16, 17")]
pub learning_rate_option: ::core::option::Option<
hyperparameters::LearningRateOption,
>,
}
/// Nested message and enum types in `Hyperparameters`.
pub mod hyperparameters {
/// Options for specifying learning rate during tuning.
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum LearningRateOption {
/// Optional. Immutable. The learning rate hyperparameter for tuning.
/// If not set, a default of 0.001 or 0.0002 will be calculated based on the
/// number of training examples.
#[prost(float, tag = "16")]
LearningRate(f32),
/// Optional. Immutable. The learning rate multiplier is used to calculate a
/// final learning_rate based on the default (recommended) value. Actual
/// learning rate := learning_rate_multiplier * default learning rate Default
/// learning rate is dependent on base model and dataset size. If not set, a
/// default of 1.0 will be used.
#[prost(float, tag = "17")]
LearningRateMultiplier(f32),
}
}
/// Dataset for training or validation.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Dataset {
/// Inline data or a reference to the data.
#[prost(oneof = "dataset::Dataset", tags = "1")]
pub dataset: ::core::option::Option<dataset::Dataset>,
}
/// Nested message and enum types in `Dataset`.
pub mod dataset {
/// Inline data or a reference to the data.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Dataset {
/// Optional. Inline examples.
#[prost(message, tag = "1")]
Examples(super::TuningExamples),
}
}
/// A set of tuning examples. Can be training or validation data.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TuningExamples {
/// Required. The examples. Example input can be for text or discuss, but all
/// examples in a set must be of the same type.
#[prost(message, repeated, tag = "1")]
pub examples: ::prost::alloc::vec::Vec<TuningExample>,
}
/// A single example for tuning.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TuningExample {
/// Required. The expected model output.
#[prost(string, tag = "3")]
pub output: ::prost::alloc::string::String,
/// The input to the model for this example.
#[prost(oneof = "tuning_example::ModelInput", tags = "1")]
pub model_input: ::core::option::Option<tuning_example::ModelInput>,
}
/// Nested message and enum types in `TuningExample`.
pub mod tuning_example {
/// The input to the model for this example.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ModelInput {
/// Optional. Text model input.
#[prost(string, tag = "1")]
TextInput(::prost::alloc::string::String),
}
}
/// Record for a single tuning step.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TuningSnapshot {
/// Output only. The tuning step.
#[prost(int32, tag = "1")]
pub step: i32,
/// Output only. The epoch this step was part of.
#[prost(int32, tag = "2")]
pub epoch: i32,
/// Output only. The mean loss of the training examples for this step.
#[prost(float, tag = "3")]
pub mean_loss: f32,
/// Output only. The timestamp when this metric was computed.
#[prost(message, optional, tag = "4")]
pub compute_time: ::core::option::Option<::prost_types::Timestamp>,
}
/// Request for getting information about a specific Model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetModelRequest {
/// Required. The resource name of the model.
///
/// This name should match a model name returned by the `ListModels` method.
///
/// Format: `models/{model}`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request for listing all Models.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListModelsRequest {
/// The maximum number of `Models` to return (per page).
///
/// If unspecified, 50 models will be returned per page.
/// This method returns at most 1000 models per page, even if you pass a larger
/// page_size.
#[prost(int32, tag = "2")]
pub page_size: i32,
/// A page token, received from a previous `ListModels` call.
///
/// Provide the `page_token` returned by one request as an argument to the next
/// request to retrieve the next page.
///
/// When paginating, all other parameters provided to `ListModels` must match
/// the call that provided the page token.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response from `ListModel` containing a paginated list of Models.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListModelsResponse {
/// The returned Models.
#[prost(message, repeated, tag = "1")]
pub models: ::prost::alloc::vec::Vec<Model>,
/// A token, which can be sent as `page_token` to retrieve the next page.
///
/// If this field is omitted, there are no more pages.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request for getting information about a specific Model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetTunedModelRequest {
/// Required. The resource name of the model.
///
/// Format: `tunedModels/my-model-id`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request for listing TunedModels.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListTunedModelsRequest {
/// Optional. The maximum number of `TunedModels` to return (per page).
/// The service may return fewer tuned models.
///
/// If unspecified, at most 10 tuned models will be returned.
/// This method returns at most 1000 models per page, even if you pass a larger
/// page_size.
#[prost(int32, tag = "1")]
pub page_size: i32,
/// Optional. A page token, received from a previous `ListTunedModels` call.
///
/// Provide the `page_token` returned by one request as an argument to the next
/// request to retrieve the next page.
///
/// When paginating, all other parameters provided to `ListTunedModels`
/// must match the call that provided the page token.
#[prost(string, tag = "2")]
pub page_token: ::prost::alloc::string::String,
/// Optional. A filter is a full text search over the tuned model's description
/// and display name. By default, results will not include tuned models shared
/// with everyone.
///
/// Additional operators:
/// - owner:me
/// - writers:me
/// - readers:me
/// - readers:everyone
///
/// Examples:
/// "owner:me" returns all tuned models to which caller has owner role
/// "readers:me" returns all tuned models to which caller has reader role
/// "readers:everyone" returns all tuned models that are shared with everyone
#[prost(string, tag = "3")]
pub filter: ::prost::alloc::string::String,
}
/// Response from `ListTunedModels` containing a paginated list of Models.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListTunedModelsResponse {
/// The returned Models.
#[prost(message, repeated, tag = "1")]
pub tuned_models: ::prost::alloc::vec::Vec<TunedModel>,
/// A token, which can be sent as `page_token` to retrieve the next page.
///
/// If this field is omitted, there are no more pages.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request to create a TunedModel.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateTunedModelRequest {
/// Optional. The unique id for the tuned model if specified.
/// This value should be up to 40 characters, the first character must be a
/// letter, the last could be a letter or a number. The id must match the
/// regular expression: `[a-z](\[a-z0-9-\]{0,38}\[a-z0-9\])?`.
#[prost(string, optional, tag = "1")]
pub tuned_model_id: ::core::option::Option<::prost::alloc::string::String>,
/// Required. The tuned model to create.
#[prost(message, optional, tag = "2")]
pub tuned_model: ::core::option::Option<TunedModel>,
}
/// Metadata about the state and progress of creating a tuned model returned from
/// the long-running operation
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateTunedModelMetadata {
/// Name of the tuned model associated with the tuning operation.
#[prost(string, tag = "5")]
pub tuned_model: ::prost::alloc::string::String,
/// The total number of tuning steps.
#[prost(int32, tag = "1")]
pub total_steps: i32,
/// The number of steps completed.
#[prost(int32, tag = "2")]
pub completed_steps: i32,
/// The completed percentage for the tuning operation.
#[prost(float, tag = "3")]
pub completed_percent: f32,
/// Metrics collected during tuning.
#[prost(message, repeated, tag = "4")]
pub snapshots: ::prost::alloc::vec::Vec<TuningSnapshot>,
}
/// Request to update a TunedModel.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateTunedModelRequest {
/// Required. The tuned model to update.
#[prost(message, optional, tag = "1")]
pub tuned_model: ::core::option::Option<TunedModel>,
/// Required. The list of fields to update.
#[prost(message, optional, tag = "2")]
pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request to delete a TunedModel.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteTunedModelRequest {
/// Required. The resource name of the model.
/// Format: `tunedModels/my-model-id`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod model_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Provides methods for getting metadata information about Generative Models.
#[derive(Debug, Clone)]
pub struct ModelServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> ModelServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ModelServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
ModelServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Gets information about a specific `Model` such as its version number, token
/// limits,
/// [parameters](https://ai.google.dev/gemini-api/docs/models/generative-models#model-parameters)
/// and other metadata. Refer to the [Gemini models
/// guide](https://ai.google.dev/gemini-api/docs/models/gemini) for detailed
/// model information.
pub async fn get_model(
&mut self,
request: impl tonic::IntoRequest<super::GetModelRequest>,
) -> std::result::Result<tonic::Response<super::Model>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.ModelService/GetModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.ModelService",
"GetModel",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists the [`Model`s](https://ai.google.dev/gemini-api/docs/models/gemini)
/// available through the Gemini API.
pub async fn list_models(
&mut self,
request: impl tonic::IntoRequest<super::ListModelsRequest>,
) -> std::result::Result<
tonic::Response<super::ListModelsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.ModelService/ListModels",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.ModelService",
"ListModels",
),
);
self.inner.unary(req, path, codec).await
}
/// Gets information about a specific TunedModel.
pub async fn get_tuned_model(
&mut self,
request: impl tonic::IntoRequest<super::GetTunedModelRequest>,
) -> std::result::Result<tonic::Response<super::TunedModel>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.ModelService/GetTunedModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.ModelService",
"GetTunedModel",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists created tuned models.
pub async fn list_tuned_models(
&mut self,
request: impl tonic::IntoRequest<super::ListTunedModelsRequest>,
) -> std::result::Result<
tonic::Response<super::ListTunedModelsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.ModelService/ListTunedModels",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.ModelService",
"ListTunedModels",
),
);
self.inner.unary(req, path, codec).await
}
/// Creates a tuned model.
/// Check intermediate tuning progress (if any) through the
/// [google.longrunning.Operations] service.
///
/// Access status and results through the Operations service.
/// Example:
/// GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222
pub async fn create_tuned_model(
&mut self,
request: impl tonic::IntoRequest<super::CreateTunedModelRequest>,
) -> std::result::Result<
tonic::Response<super::super::super::super::longrunning::Operation>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.ModelService/CreateTunedModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.ModelService",
"CreateTunedModel",
),
);
self.inner.unary(req, path, codec).await
}
/// Updates a tuned model.
pub async fn update_tuned_model(
&mut self,
request: impl tonic::IntoRequest<super::UpdateTunedModelRequest>,
) -> std::result::Result<tonic::Response<super::TunedModel>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.ModelService/UpdateTunedModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.ModelService",
"UpdateTunedModel",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes a tuned model.
pub async fn delete_tuned_model(
&mut self,
request: impl tonic::IntoRequest<super::DeleteTunedModelRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.ModelService/DeleteTunedModel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.ModelService",
"DeleteTunedModel",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Content that has been preprocessed and can be used in subsequent request
/// to GenerativeService.
///
/// Cached content can be only used with model it was created for.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CachedContent {
/// Optional. Identifier. The resource name referring to the cached content.
/// Format: `cachedContents/{id}`
#[prost(string, optional, tag = "1")]
pub name: ::core::option::Option<::prost::alloc::string::String>,
/// Optional. Immutable. The user-generated meaningful display name of the
/// cached content. Maximum 128 Unicode characters.
#[prost(string, optional, tag = "11")]
pub display_name: ::core::option::Option<::prost::alloc::string::String>,
/// Required. Immutable. The name of the `Model` to use for cached content
/// Format: `models/{model}`
#[prost(string, optional, tag = "2")]
pub model: ::core::option::Option<::prost::alloc::string::String>,
/// Optional. Input only. Immutable. Developer set system instruction.
/// Currently text only.
#[prost(message, optional, tag = "3")]
pub system_instruction: ::core::option::Option<Content>,
/// Optional. Input only. Immutable. The content to cache.
#[prost(message, repeated, tag = "4")]
pub contents: ::prost::alloc::vec::Vec<Content>,
/// Optional. Input only. Immutable. A list of `Tools` the model may use to
/// generate the next response
#[prost(message, repeated, tag = "5")]
pub tools: ::prost::alloc::vec::Vec<Tool>,
/// Optional. Input only. Immutable. Tool config. This config is shared for all
/// tools.
#[prost(message, optional, tag = "6")]
pub tool_config: ::core::option::Option<ToolConfig>,
/// Output only. Creation time of the cache entry.
#[prost(message, optional, tag = "7")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. When the cache entry was last updated in UTC time.
#[prost(message, optional, tag = "8")]
pub update_time: ::core::option::Option<::prost_types::Timestamp>,
/// Output only. Metadata on the usage of the cached content.
#[prost(message, optional, tag = "12")]
pub usage_metadata: ::core::option::Option<cached_content::UsageMetadata>,
/// Specifies when this resource will expire.
#[prost(oneof = "cached_content::Expiration", tags = "9, 10")]
pub expiration: ::core::option::Option<cached_content::Expiration>,
}
/// Nested message and enum types in `CachedContent`.
pub mod cached_content {
/// Metadata on the usage of the cached content.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct UsageMetadata {
/// Total number of tokens that the cached content consumes.
#[prost(int32, tag = "1")]
pub total_token_count: i32,
}
/// Specifies when this resource will expire.
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum Expiration {
/// Timestamp in UTC of when this resource is considered expired.
/// This is *always* provided on output, regardless of what was sent
/// on input.
#[prost(message, tag = "9")]
ExpireTime(::prost_types::Timestamp),
/// Input only. New TTL for this resource, input only.
#[prost(message, tag = "10")]
Ttl(::prost_types::Duration),
}
}
/// Request to list CachedContents.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListCachedContentsRequest {
/// Optional. The maximum number of cached contents to return. The service may
/// return fewer than this value. If unspecified, some default (under maximum)
/// number of items will be returned. The maximum value is 1000; values above
/// 1000 will be coerced to 1000.
#[prost(int32, tag = "1")]
pub page_size: i32,
/// Optional. A page token, received from a previous `ListCachedContents` call.
/// Provide this to retrieve the subsequent page.
///
/// When paginating, all other parameters provided to `ListCachedContents` must
/// match the call that provided the page token.
#[prost(string, tag = "2")]
pub page_token: ::prost::alloc::string::String,
}
/// Response with CachedContents list.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListCachedContentsResponse {
/// List of cached contents.
#[prost(message, repeated, tag = "1")]
pub cached_contents: ::prost::alloc::vec::Vec<CachedContent>,
/// A token, which can be sent as `page_token` to retrieve the next page.
/// If this field is omitted, there are no subsequent pages.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request to create CachedContent.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateCachedContentRequest {
/// Required. The cached content to create.
#[prost(message, optional, tag = "1")]
pub cached_content: ::core::option::Option<CachedContent>,
}
/// Request to read CachedContent.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetCachedContentRequest {
/// Required. The resource name referring to the content cache entry.
/// Format: `cachedContents/{id}`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request to update CachedContent.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateCachedContentRequest {
/// Required. The content cache entry to update
#[prost(message, optional, tag = "1")]
pub cached_content: ::core::option::Option<CachedContent>,
/// The list of fields to update.
#[prost(message, optional, tag = "2")]
pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request to delete CachedContent.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteCachedContentRequest {
/// Required. The resource name referring to the content cache entry
/// Format: `cachedContents/{id}`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod cache_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// API for managing cache of content (CachedContent resources) that can be used
/// in GenerativeService requests. This way generate content requests can benefit
/// from preprocessing work being done earlier, possibly lowering their
/// computational cost. It is intended to be used with large contexts.
#[derive(Debug, Clone)]
pub struct CacheServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> CacheServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> CacheServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
CacheServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Lists CachedContents.
pub async fn list_cached_contents(
&mut self,
request: impl tonic::IntoRequest<super::ListCachedContentsRequest>,
) -> std::result::Result<
tonic::Response<super::ListCachedContentsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.CacheService/ListCachedContents",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.CacheService",
"ListCachedContents",
),
);
self.inner.unary(req, path, codec).await
}
/// Creates CachedContent resource.
pub async fn create_cached_content(
&mut self,
request: impl tonic::IntoRequest<super::CreateCachedContentRequest>,
) -> std::result::Result<tonic::Response<super::CachedContent>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.CacheService/CreateCachedContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.CacheService",
"CreateCachedContent",
),
);
self.inner.unary(req, path, codec).await
}
/// Reads CachedContent resource.
pub async fn get_cached_content(
&mut self,
request: impl tonic::IntoRequest<super::GetCachedContentRequest>,
) -> std::result::Result<tonic::Response<super::CachedContent>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.CacheService/GetCachedContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.CacheService",
"GetCachedContent",
),
);
self.inner.unary(req, path, codec).await
}
/// Updates CachedContent resource (only expiration is updatable).
pub async fn update_cached_content(
&mut self,
request: impl tonic::IntoRequest<super::UpdateCachedContentRequest>,
) -> std::result::Result<tonic::Response<super::CachedContent>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.CacheService/UpdateCachedContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.CacheService",
"UpdateCachedContent",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes CachedContent resource.
pub async fn delete_cached_content(
&mut self,
request: impl tonic::IntoRequest<super::DeleteCachedContentRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.CacheService/DeleteCachedContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.CacheService",
"DeleteCachedContent",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// A collection of source attributions for a piece of content.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CitationMetadata {
/// Citations to sources for a specific response.
#[prost(message, repeated, tag = "1")]
pub citation_sources: ::prost::alloc::vec::Vec<CitationSource>,
}
/// A citation to a source for a portion of a specific response.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CitationSource {
/// Optional. Start of segment of the response that is attributed to this
/// source.
///
/// Index indicates the start of the segment, measured in bytes.
#[prost(int32, optional, tag = "1")]
pub start_index: ::core::option::Option<i32>,
/// Optional. End of the attributed segment, exclusive.
#[prost(int32, optional, tag = "2")]
pub end_index: ::core::option::Option<i32>,
/// Optional. URI that is attributed as a source for a portion of the text.
#[prost(string, optional, tag = "3")]
pub uri: ::core::option::Option<::prost::alloc::string::String>,
/// Optional. License for the GitHub project that is attributed as a source for
/// segment.
///
/// License info is required for code citations.
#[prost(string, optional, tag = "4")]
pub license: ::core::option::Option<::prost::alloc::string::String>,
}
/// Content filtering metadata associated with processing a single request.
///
/// ContentFilter contains a reason and an optional supporting string. The reason
/// may be unspecified.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContentFilter {
/// The reason content was blocked during request processing.
#[prost(enumeration = "content_filter::BlockedReason", tag = "1")]
pub reason: i32,
/// A string that describes the filtering behavior in more detail.
#[prost(string, optional, tag = "2")]
pub message: ::core::option::Option<::prost::alloc::string::String>,
}
/// Nested message and enum types in `ContentFilter`.
pub mod content_filter {
/// A list of reasons why content may have been blocked.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum BlockedReason {
/// A blocked reason was not specified.
Unspecified = 0,
/// Content was blocked by safety settings.
Safety = 1,
/// Content was blocked, but the reason is uncategorized.
Other = 2,
}
impl BlockedReason {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
BlockedReason::Unspecified => "BLOCKED_REASON_UNSPECIFIED",
BlockedReason::Safety => "SAFETY",
BlockedReason::Other => "OTHER",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"BLOCKED_REASON_UNSPECIFIED" => Some(Self::Unspecified),
"SAFETY" => Some(Self::Safety),
"OTHER" => Some(Self::Other),
_ => None,
}
}
}
}
/// Safety feedback for an entire request.
///
/// This field is populated if content in the input and/or response is blocked
/// due to safety settings. SafetyFeedback may not exist for every HarmCategory.
/// Each SafetyFeedback will return the safety settings used by the request as
/// well as the lowest HarmProbability that should be allowed in order to return
/// a result.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct SafetyFeedback {
/// Safety rating evaluated from content.
#[prost(message, optional, tag = "1")]
pub rating: ::core::option::Option<SafetyRating>,
/// Safety settings applied to the request.
#[prost(message, optional, tag = "2")]
pub setting: ::core::option::Option<SafetySetting>,
}
/// Safety rating for a piece of content.
///
/// The safety rating contains the category of harm and the
/// harm probability level in that category for a piece of content.
/// Content is classified for safety across a number of
/// harm categories and the probability of the harm classification is included
/// here.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct SafetyRating {
/// Required. The category for this rating.
#[prost(enumeration = "HarmCategory", tag = "3")]
pub category: i32,
/// Required. The probability of harm for this content.
#[prost(enumeration = "safety_rating::HarmProbability", tag = "4")]
pub probability: i32,
/// Was this content blocked because of this rating?
#[prost(bool, tag = "5")]
pub blocked: bool,
}
/// Nested message and enum types in `SafetyRating`.
pub mod safety_rating {
/// The probability that a piece of content is harmful.
///
/// The classification system gives the probability of the content being
/// unsafe. This does not indicate the severity of harm for a piece of content.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum HarmProbability {
/// Probability is unspecified.
Unspecified = 0,
/// Content has a negligible chance of being unsafe.
Negligible = 1,
/// Content has a low chance of being unsafe.
Low = 2,
/// Content has a medium chance of being unsafe.
Medium = 3,
/// Content has a high chance of being unsafe.
High = 4,
}
impl HarmProbability {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
HarmProbability::Unspecified => "HARM_PROBABILITY_UNSPECIFIED",
HarmProbability::Negligible => "NEGLIGIBLE",
HarmProbability::Low => "LOW",
HarmProbability::Medium => "MEDIUM",
HarmProbability::High => "HIGH",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"HARM_PROBABILITY_UNSPECIFIED" => Some(Self::Unspecified),
"NEGLIGIBLE" => Some(Self::Negligible),
"LOW" => Some(Self::Low),
"MEDIUM" => Some(Self::Medium),
"HIGH" => Some(Self::High),
_ => None,
}
}
}
}
/// Safety setting, affecting the safety-blocking behavior.
///
/// Passing a safety setting for a category changes the allowed probability that
/// content is blocked.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct SafetySetting {
/// Required. The category for this setting.
#[prost(enumeration = "HarmCategory", tag = "3")]
pub category: i32,
/// Required. Controls the probability threshold at which harm is blocked.
#[prost(enumeration = "safety_setting::HarmBlockThreshold", tag = "4")]
pub threshold: i32,
}
/// Nested message and enum types in `SafetySetting`.
pub mod safety_setting {
/// Block at and beyond a specified harm probability.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum HarmBlockThreshold {
/// Threshold is unspecified.
Unspecified = 0,
/// Content with NEGLIGIBLE will be allowed.
BlockLowAndAbove = 1,
/// Content with NEGLIGIBLE and LOW will be allowed.
BlockMediumAndAbove = 2,
/// Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.
BlockOnlyHigh = 3,
/// All content will be allowed.
BlockNone = 4,
}
impl HarmBlockThreshold {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
HarmBlockThreshold::Unspecified => "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
HarmBlockThreshold::BlockLowAndAbove => "BLOCK_LOW_AND_ABOVE",
HarmBlockThreshold::BlockMediumAndAbove => "BLOCK_MEDIUM_AND_ABOVE",
HarmBlockThreshold::BlockOnlyHigh => "BLOCK_ONLY_HIGH",
HarmBlockThreshold::BlockNone => "BLOCK_NONE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"HARM_BLOCK_THRESHOLD_UNSPECIFIED" => Some(Self::Unspecified),
"BLOCK_LOW_AND_ABOVE" => Some(Self::BlockLowAndAbove),
"BLOCK_MEDIUM_AND_ABOVE" => Some(Self::BlockMediumAndAbove),
"BLOCK_ONLY_HIGH" => Some(Self::BlockOnlyHigh),
"BLOCK_NONE" => Some(Self::BlockNone),
_ => None,
}
}
}
}
/// The category of a rating.
///
/// These categories cover various kinds of harms that developers
/// may wish to adjust.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum HarmCategory {
/// Category is unspecified.
Unspecified = 0,
/// Negative or harmful comments targeting identity and/or protected attribute.
Derogatory = 1,
/// Content that is rude, disrespectful, or profane.
Toxicity = 2,
/// Describes scenarios depicting violence against an individual or group, or
/// general descriptions of gore.
Violence = 3,
/// Contains references to sexual acts or other lewd content.
Sexual = 4,
/// Promotes unchecked medical advice.
Medical = 5,
/// Dangerous content that promotes, facilitates, or encourages harmful acts.
Dangerous = 6,
/// Harasment content.
Harassment = 7,
/// Hate speech and content.
HateSpeech = 8,
/// Sexually explicit content.
SexuallyExplicit = 9,
/// Dangerous content.
DangerousContent = 10,
}
impl HarmCategory {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
HarmCategory::Unspecified => "HARM_CATEGORY_UNSPECIFIED",
HarmCategory::Derogatory => "HARM_CATEGORY_DEROGATORY",
HarmCategory::Toxicity => "HARM_CATEGORY_TOXICITY",
HarmCategory::Violence => "HARM_CATEGORY_VIOLENCE",
HarmCategory::Sexual => "HARM_CATEGORY_SEXUAL",
HarmCategory::Medical => "HARM_CATEGORY_MEDICAL",
HarmCategory::Dangerous => "HARM_CATEGORY_DANGEROUS",
HarmCategory::Harassment => "HARM_CATEGORY_HARASSMENT",
HarmCategory::HateSpeech => "HARM_CATEGORY_HATE_SPEECH",
HarmCategory::SexuallyExplicit => "HARM_CATEGORY_SEXUALLY_EXPLICIT",
HarmCategory::DangerousContent => "HARM_CATEGORY_DANGEROUS_CONTENT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"HARM_CATEGORY_UNSPECIFIED" => Some(Self::Unspecified),
"HARM_CATEGORY_DEROGATORY" => Some(Self::Derogatory),
"HARM_CATEGORY_TOXICITY" => Some(Self::Toxicity),
"HARM_CATEGORY_VIOLENCE" => Some(Self::Violence),
"HARM_CATEGORY_SEXUAL" => Some(Self::Sexual),
"HARM_CATEGORY_MEDICAL" => Some(Self::Medical),
"HARM_CATEGORY_DANGEROUS" => Some(Self::Dangerous),
"HARM_CATEGORY_HARASSMENT" => Some(Self::Harassment),
"HARM_CATEGORY_HATE_SPEECH" => Some(Self::HateSpeech),
"HARM_CATEGORY_SEXUALLY_EXPLICIT" => Some(Self::SexuallyExplicit),
"HARM_CATEGORY_DANGEROUS_CONTENT" => Some(Self::DangerousContent),
_ => None,
}
}
}
/// Request to generate a text completion response from the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateTextRequest {
/// Required. The name of the `Model` or `TunedModel` to use for generating the
/// completion.
/// Examples:
/// models/text-bison-001
/// tunedModels/sentence-translator-u3b7m
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Required. The free-form input text given to the model as a prompt.
///
/// Given a prompt, the model will generate a TextCompletion response it
/// predicts as the completion of the input text.
#[prost(message, optional, tag = "2")]
pub prompt: ::core::option::Option<TextPrompt>,
/// Optional. Controls the randomness of the output.
/// Note: The default value varies by model, see the `Model.temperature`
/// attribute of the `Model` returned the `getModel` function.
///
/// Values can range from \[0.0,1.0\],
/// inclusive. A value closer to 1.0 will produce responses that are more
/// varied and creative, while a value closer to 0.0 will typically result in
/// more straightforward responses from the model.
#[prost(float, optional, tag = "3")]
pub temperature: ::core::option::Option<f32>,
/// Optional. Number of generated responses to return.
///
/// This value must be between \[1, 8\], inclusive. If unset, this will default
/// to 1.
#[prost(int32, optional, tag = "4")]
pub candidate_count: ::core::option::Option<i32>,
/// Optional. The maximum number of tokens to include in a candidate.
///
/// If unset, this will default to output_token_limit specified in the `Model`
/// specification.
#[prost(int32, optional, tag = "5")]
pub max_output_tokens: ::core::option::Option<i32>,
/// Optional. The maximum cumulative probability of tokens to consider when
/// sampling.
///
/// The model uses combined Top-k and nucleus sampling.
///
/// Tokens are sorted based on their assigned probabilities so that only the
/// most likely tokens are considered. Top-k sampling directly limits the
/// maximum number of tokens to consider, while Nucleus sampling limits number
/// of tokens based on the cumulative probability.
///
/// Note: The default value varies by model, see the `Model.top_p`
/// attribute of the `Model` returned the `getModel` function.
#[prost(float, optional, tag = "6")]
pub top_p: ::core::option::Option<f32>,
/// Optional. The maximum number of tokens to consider when sampling.
///
/// The model uses combined Top-k and nucleus sampling.
///
/// Top-k sampling considers the set of `top_k` most probable tokens.
/// Defaults to 40.
///
/// Note: The default value varies by model, see the `Model.top_k`
/// attribute of the `Model` returned the `getModel` function.
#[prost(int32, optional, tag = "7")]
pub top_k: ::core::option::Option<i32>,
/// Optional. A list of unique `SafetySetting` instances for blocking unsafe
/// content.
///
/// that will be enforced on the `GenerateTextRequest.prompt` and
/// `GenerateTextResponse.candidates`. There should not be more than one
/// setting for each `SafetyCategory` type. The API will block any prompts and
/// responses that fail to meet the thresholds set by these settings. This list
/// overrides the default settings for each `SafetyCategory` specified in the
/// safety_settings. If there is no `SafetySetting` for a given
/// `SafetyCategory` provided in the list, the API will use the default safety
/// setting for that category. Harm categories HARM_CATEGORY_DEROGATORY,
/// HARM_CATEGORY_TOXICITY, HARM_CATEGORY_VIOLENCE, HARM_CATEGORY_SEXUAL,
/// HARM_CATEGORY_MEDICAL, HARM_CATEGORY_DANGEROUS are supported in text
/// service.
#[prost(message, repeated, tag = "8")]
pub safety_settings: ::prost::alloc::vec::Vec<SafetySetting>,
/// The set of character sequences (up to 5) that will stop output generation.
/// If specified, the API will stop at the first appearance of a stop
/// sequence. The stop sequence will not be included as part of the response.
#[prost(string, repeated, tag = "9")]
pub stop_sequences: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// The response from the model, including candidate completions.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateTextResponse {
/// Candidate responses from the model.
#[prost(message, repeated, tag = "1")]
pub candidates: ::prost::alloc::vec::Vec<TextCompletion>,
/// A set of content filtering metadata for the prompt and response
/// text.
///
/// This indicates which `SafetyCategory`(s) blocked a
/// candidate from this response, the lowest `HarmProbability`
/// that triggered a block, and the HarmThreshold setting for that category.
/// This indicates the smallest change to the `SafetySettings` that would be
/// necessary to unblock at least 1 response.
///
/// The blocking is configured by the `SafetySettings` in the request (or the
/// default `SafetySettings` of the API).
#[prost(message, repeated, tag = "3")]
pub filters: ::prost::alloc::vec::Vec<ContentFilter>,
/// Returns any safety feedback related to content filtering.
#[prost(message, repeated, tag = "4")]
pub safety_feedback: ::prost::alloc::vec::Vec<SafetyFeedback>,
}
/// Text given to the model as a prompt.
///
/// The Model will use this TextPrompt to Generate a text completion.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TextPrompt {
/// Required. The prompt text.
#[prost(string, tag = "1")]
pub text: ::prost::alloc::string::String,
}
/// Output text returned from a model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TextCompletion {
/// Output only. The generated text returned from the model.
#[prost(string, tag = "1")]
pub output: ::prost::alloc::string::String,
/// Ratings for the safety of a response.
///
/// There is at most one rating per category.
#[prost(message, repeated, tag = "2")]
pub safety_ratings: ::prost::alloc::vec::Vec<SafetyRating>,
/// Output only. Citation information for model-generated `output` in this
/// `TextCompletion`.
///
/// This field may be populated with attribution information for any text
/// included in the `output`.
#[prost(message, optional, tag = "3")]
pub citation_metadata: ::core::option::Option<CitationMetadata>,
}
/// Request to get a text embedding from the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmbedTextRequest {
/// Required. The model name to use with the format model=models/{model}.
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Optional. The free-form input text that the model will turn into an
/// embedding.
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
}
/// The response to a EmbedTextRequest.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmbedTextResponse {
/// Output only. The embedding generated from the input text.
#[prost(message, optional, tag = "1")]
pub embedding: ::core::option::Option<Embedding>,
}
/// Batch request to get a text embedding from the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchEmbedTextRequest {
/// Required. The name of the `Model` to use for generating the embedding.
/// Examples:
/// models/embedding-gecko-001
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Optional. The free-form input texts that the model will turn into an
/// embedding. The current limit is 100 texts, over which an error will be
/// thrown.
#[prost(string, repeated, tag = "2")]
pub texts: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional. Embed requests for the batch. Only one of `texts` or `requests`
/// can be set.
#[prost(message, repeated, tag = "3")]
pub requests: ::prost::alloc::vec::Vec<EmbedTextRequest>,
}
/// The response to a EmbedTextRequest.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchEmbedTextResponse {
/// Output only. The embeddings generated from the input text.
#[prost(message, repeated, tag = "1")]
pub embeddings: ::prost::alloc::vec::Vec<Embedding>,
}
/// A list of floats representing the embedding.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Embedding {
/// The embedding values.
#[prost(float, repeated, tag = "1")]
pub value: ::prost::alloc::vec::Vec<f32>,
}
/// Counts the number of tokens in the `prompt` sent to a model.
///
/// Models may tokenize text differently, so each model may return a different
/// `token_count`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CountTextTokensRequest {
/// Required. The model's resource name. This serves as an ID for the Model to
/// use.
///
/// This name should match a model name returned by the `ListModels` method.
///
/// Format: `models/{model}`
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Required. The free-form input text given to the model as a prompt.
#[prost(message, optional, tag = "2")]
pub prompt: ::core::option::Option<TextPrompt>,
}
/// A response from `CountTextTokens`.
///
/// It returns the model's `token_count` for the `prompt`.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CountTextTokensResponse {
/// The number of tokens that the `model` tokenizes the `prompt` into.
///
/// Always non-negative.
#[prost(int32, tag = "1")]
pub token_count: i32,
}
/// Generated client implementations.
pub mod text_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// API for using Generative Language Models (GLMs) trained to generate text.
///
/// Also known as Large Language Models (LLM)s, these generate text given an
/// input prompt from the user.
#[derive(Debug, Clone)]
pub struct TextServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> TextServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> TextServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
TextServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Generates a response from the model given an input message.
pub async fn generate_text(
&mut self,
request: impl tonic::IntoRequest<super::GenerateTextRequest>,
) -> std::result::Result<
tonic::Response<super::GenerateTextResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.TextService/GenerateText",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.TextService",
"GenerateText",
),
);
self.inner.unary(req, path, codec).await
}
/// Generates an embedding from the model given an input message.
pub async fn embed_text(
&mut self,
request: impl tonic::IntoRequest<super::EmbedTextRequest>,
) -> std::result::Result<
tonic::Response<super::EmbedTextResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.TextService/EmbedText",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.TextService",
"EmbedText",
),
);
self.inner.unary(req, path, codec).await
}
/// Generates multiple embeddings from the model given input text in a
/// synchronous call.
pub async fn batch_embed_text(
&mut self,
request: impl tonic::IntoRequest<super::BatchEmbedTextRequest>,
) -> std::result::Result<
tonic::Response<super::BatchEmbedTextResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.TextService/BatchEmbedText",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.TextService",
"BatchEmbedText",
),
);
self.inner.unary(req, path, codec).await
}
/// Runs a model's tokenizer on a text and returns the token count.
pub async fn count_text_tokens(
&mut self,
request: impl tonic::IntoRequest<super::CountTextTokensRequest>,
) -> std::result::Result<
tonic::Response<super::CountTextTokensResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.TextService/CountTextTokens",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.TextService",
"CountTextTokens",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Request to generate a message response from the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateMessageRequest {
/// Required. The name of the model to use.
///
/// Format: `name=models/{model}`.
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Required. The structured textual input given to the model as a prompt.
///
/// Given a
/// prompt, the model will return what it predicts is the next message in the
/// discussion.
#[prost(message, optional, tag = "2")]
pub prompt: ::core::option::Option<MessagePrompt>,
/// Optional. Controls the randomness of the output.
///
/// Values can range over `\[0.0,1.0\]`,
/// inclusive. A value closer to `1.0` will produce responses that are more
/// varied, while a value closer to `0.0` will typically result in
/// less surprising responses from the model.
#[prost(float, optional, tag = "3")]
pub temperature: ::core::option::Option<f32>,
/// Optional. The number of generated response messages to return.
///
/// This value must be between
/// `\[1, 8\]`, inclusive. If unset, this will default to `1`.
#[prost(int32, optional, tag = "4")]
pub candidate_count: ::core::option::Option<i32>,
/// Optional. The maximum cumulative probability of tokens to consider when
/// sampling.
///
/// The model uses combined Top-k and nucleus sampling.
///
/// Nucleus sampling considers the smallest set of tokens whose probability
/// sum is at least `top_p`.
#[prost(float, optional, tag = "5")]
pub top_p: ::core::option::Option<f32>,
/// Optional. The maximum number of tokens to consider when sampling.
///
/// The model uses combined Top-k and nucleus sampling.
///
/// Top-k sampling considers the set of `top_k` most probable tokens.
#[prost(int32, optional, tag = "6")]
pub top_k: ::core::option::Option<i32>,
}
/// The response from the model.
///
/// This includes candidate messages and
/// conversation history in the form of chronologically-ordered messages.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateMessageResponse {
/// Candidate response messages from the model.
#[prost(message, repeated, tag = "1")]
pub candidates: ::prost::alloc::vec::Vec<Message>,
/// The conversation history used by the model.
#[prost(message, repeated, tag = "2")]
pub messages: ::prost::alloc::vec::Vec<Message>,
/// A set of content filtering metadata for the prompt and response
/// text.
///
/// This indicates which `SafetyCategory`(s) blocked a
/// candidate from this response, the lowest `HarmProbability`
/// that triggered a block, and the HarmThreshold setting for that category.
#[prost(message, repeated, tag = "3")]
pub filters: ::prost::alloc::vec::Vec<ContentFilter>,
}
/// The base unit of structured text.
///
/// A `Message` includes an `author` and the `content` of
/// the `Message`.
///
/// The `author` is used to tag messages when they are fed to the
/// model as text.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Message {
/// Optional. The author of this Message.
///
/// This serves as a key for tagging
/// the content of this Message when it is fed to the model as text.
///
/// The author can be any alphanumeric string.
#[prost(string, tag = "1")]
pub author: ::prost::alloc::string::String,
/// Required. The text content of the structured `Message`.
#[prost(string, tag = "2")]
pub content: ::prost::alloc::string::String,
/// Output only. Citation information for model-generated `content` in this
/// `Message`.
///
/// If this `Message` was generated as output from the model, this field may be
/// populated with attribution information for any text included in the
/// `content`. This field is used only on output.
#[prost(message, optional, tag = "3")]
pub citation_metadata: ::core::option::Option<CitationMetadata>,
}
/// All of the structured input text passed to the model as a prompt.
///
/// A `MessagePrompt` contains a structured set of fields that provide context
/// for the conversation, examples of user input/model output message pairs that
/// prime the model to respond in different ways, and the conversation history
/// or list of messages representing the alternating turns of the conversation
/// between the user and the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MessagePrompt {
/// Optional. Text that should be provided to the model first to ground the
/// response.
///
/// If not empty, this `context` will be given to the model first before the
/// `examples` and `messages`. When using a `context` be sure to provide it
/// with every request to maintain continuity.
///
/// This field can be a description of your prompt to the model to help provide
/// context and guide the responses. Examples: "Translate the phrase from
/// English to French." or "Given a statement, classify the sentiment as happy,
/// sad or neutral."
///
/// Anything included in this field will take precedence over message history
/// if the total input size exceeds the model's `input_token_limit` and the
/// input request is truncated.
#[prost(string, tag = "1")]
pub context: ::prost::alloc::string::String,
/// Optional. Examples of what the model should generate.
///
/// This includes both user input and the response that the model should
/// emulate.
///
/// These `examples` are treated identically to conversation messages except
/// that they take precedence over the history in `messages`:
/// If the total input size exceeds the model's `input_token_limit` the input
/// will be truncated. Items will be dropped from `messages` before `examples`.
#[prost(message, repeated, tag = "2")]
pub examples: ::prost::alloc::vec::Vec<Example>,
/// Required. A snapshot of the recent conversation history sorted
/// chronologically.
///
/// Turns alternate between two authors.
///
/// If the total input size exceeds the model's `input_token_limit` the input
/// will be truncated: The oldest items will be dropped from `messages`.
#[prost(message, repeated, tag = "3")]
pub messages: ::prost::alloc::vec::Vec<Message>,
}
/// An input/output example used to instruct the Model.
///
/// It demonstrates how the model should respond or format its response.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Example {
/// Required. An example of an input `Message` from the user.
#[prost(message, optional, tag = "1")]
pub input: ::core::option::Option<Message>,
/// Required. An example of what the model should output given the input.
#[prost(message, optional, tag = "2")]
pub output: ::core::option::Option<Message>,
}
/// Counts the number of tokens in the `prompt` sent to a model.
///
/// Models may tokenize text differently, so each model may return a different
/// `token_count`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CountMessageTokensRequest {
/// Required. The model's resource name. This serves as an ID for the Model to
/// use.
///
/// This name should match a model name returned by the `ListModels` method.
///
/// Format: `models/{model}`
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Required. The prompt, whose token count is to be returned.
#[prost(message, optional, tag = "2")]
pub prompt: ::core::option::Option<MessagePrompt>,
}
/// A response from `CountMessageTokens`.
///
/// It returns the model's `token_count` for the `prompt`.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CountMessageTokensResponse {
/// The number of tokens that the `model` tokenizes the `prompt` into.
///
/// Always non-negative.
#[prost(int32, tag = "1")]
pub token_count: i32,
}
/// Generated client implementations.
pub mod discuss_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// An API for using Generative Language Models (GLMs) in dialog applications.
///
/// Also known as large language models (LLMs), this API provides models that
/// are trained for multi-turn dialog.
#[derive(Debug, Clone)]
pub struct DiscussServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> DiscussServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> DiscussServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
DiscussServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Generates a response from the model given an input `MessagePrompt`.
pub async fn generate_message(
&mut self,
request: impl tonic::IntoRequest<super::GenerateMessageRequest>,
) -> std::result::Result<
tonic::Response<super::GenerateMessageResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.DiscussService/GenerateMessage",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.DiscussService",
"GenerateMessage",
),
);
self.inner.unary(req, path, codec).await
}
/// Runs a model's tokenizer on a string and returns the token count.
pub async fn count_message_tokens(
&mut self,
request: impl tonic::IntoRequest<super::CountMessageTokensRequest>,
) -> std::result::Result<
tonic::Response<super::CountMessageTokensResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.DiscussService/CountMessageTokens",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.DiscussService",
"CountMessageTokens",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Request to create a `Permission`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreatePermissionRequest {
/// Required. The parent resource of the `Permission`.
/// Formats:
/// `tunedModels/{tuned_model}`
/// `corpora/{corpus}`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Required. The permission to create.
#[prost(message, optional, tag = "2")]
pub permission: ::core::option::Option<Permission>,
}
/// Request for getting information about a specific `Permission`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetPermissionRequest {
/// Required. The resource name of the permission.
///
/// Formats:
/// `tunedModels/{tuned_model}/permissions/{permission}`
/// `corpora/{corpus}/permissions/{permission}`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request for listing permissions.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListPermissionsRequest {
/// Required. The parent resource of the permissions.
/// Formats:
/// `tunedModels/{tuned_model}`
/// `corpora/{corpus}`
#[prost(string, tag = "1")]
pub parent: ::prost::alloc::string::String,
/// Optional. The maximum number of `Permission`s to return (per page).
/// The service may return fewer permissions.
///
/// If unspecified, at most 10 permissions will be returned.
/// This method returns at most 1000 permissions per page, even if you pass
/// larger page_size.
#[prost(int32, tag = "2")]
pub page_size: i32,
/// Optional. A page token, received from a previous `ListPermissions` call.
///
/// Provide the `page_token` returned by one request as an argument to the
/// next request to retrieve the next page.
///
/// When paginating, all other parameters provided to `ListPermissions`
/// must match the call that provided the page token.
#[prost(string, tag = "3")]
pub page_token: ::prost::alloc::string::String,
}
/// Response from `ListPermissions` containing a paginated list of
/// permissions.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListPermissionsResponse {
/// Returned permissions.
#[prost(message, repeated, tag = "1")]
pub permissions: ::prost::alloc::vec::Vec<Permission>,
/// A token, which can be sent as `page_token` to retrieve the next page.
///
/// If this field is omitted, there are no more pages.
#[prost(string, tag = "2")]
pub next_page_token: ::prost::alloc::string::String,
}
/// Request to update the `Permission`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdatePermissionRequest {
/// Required. The permission to update.
///
/// The permission's `name` field is used to identify the permission to update.
#[prost(message, optional, tag = "1")]
pub permission: ::core::option::Option<Permission>,
/// Required. The list of fields to update. Accepted ones:
/// - role (`Permission.role` field)
#[prost(message, optional, tag = "2")]
pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request to delete the `Permission`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeletePermissionRequest {
/// Required. The resource name of the permission.
/// Formats:
/// `tunedModels/{tuned_model}/permissions/{permission}`
/// `corpora/{corpus}/permissions/{permission}`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Request to transfer the ownership of the tuned model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransferOwnershipRequest {
/// Required. The resource name of the tuned model to transfer ownership.
///
/// Format: `tunedModels/my-model-id`
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Required. The email address of the user to whom the tuned model is being
/// transferred to.
#[prost(string, tag = "2")]
pub email_address: ::prost::alloc::string::String,
}
/// Response from `TransferOwnership`.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TransferOwnershipResponse {}
/// Generated client implementations.
pub mod permission_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Provides methods for managing permissions to PaLM API resources.
#[derive(Debug, Clone)]
pub struct PermissionServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> PermissionServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> PermissionServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
PermissionServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Create a permission to a specific resource.
pub async fn create_permission(
&mut self,
request: impl tonic::IntoRequest<super::CreatePermissionRequest>,
) -> std::result::Result<tonic::Response<super::Permission>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.PermissionService/CreatePermission",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.PermissionService",
"CreatePermission",
),
);
self.inner.unary(req, path, codec).await
}
/// Gets information about a specific Permission.
pub async fn get_permission(
&mut self,
request: impl tonic::IntoRequest<super::GetPermissionRequest>,
) -> std::result::Result<tonic::Response<super::Permission>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.PermissionService/GetPermission",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.PermissionService",
"GetPermission",
),
);
self.inner.unary(req, path, codec).await
}
/// Lists permissions for the specific resource.
pub async fn list_permissions(
&mut self,
request: impl tonic::IntoRequest<super::ListPermissionsRequest>,
) -> std::result::Result<
tonic::Response<super::ListPermissionsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.PermissionService/ListPermissions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.PermissionService",
"ListPermissions",
),
);
self.inner.unary(req, path, codec).await
}
/// Updates the permission.
pub async fn update_permission(
&mut self,
request: impl tonic::IntoRequest<super::UpdatePermissionRequest>,
) -> std::result::Result<tonic::Response<super::Permission>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.PermissionService/UpdatePermission",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.PermissionService",
"UpdatePermission",
),
);
self.inner.unary(req, path, codec).await
}
/// Deletes the permission.
pub async fn delete_permission(
&mut self,
request: impl tonic::IntoRequest<super::DeletePermissionRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.PermissionService/DeletePermission",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.PermissionService",
"DeletePermission",
),
);
self.inner.unary(req, path, codec).await
}
/// Transfers ownership of the tuned model.
/// This is the only way to change ownership of the tuned model.
/// The current owner will be downgraded to writer role.
pub async fn transfer_ownership(
&mut self,
request: impl tonic::IntoRequest<super::TransferOwnershipRequest>,
) -> std::result::Result<
tonic::Response<super::TransferOwnershipResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.PermissionService/TransferOwnership",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.PermissionService",
"TransferOwnership",
),
);
self.inner.unary(req, path, codec).await
}
}
}
/// Request to generate a completion from the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateContentRequest {
/// Required. The name of the `Model` to use for generating the completion.
///
/// Format: `name=models/{model}`.
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Optional. Developer set [system
/// instruction(s)](<https://ai.google.dev/gemini-api/docs/system-instructions>).
/// Currently, text only.
#[prost(message, optional, tag = "8")]
pub system_instruction: ::core::option::Option<Content>,
/// Required. The content of the current conversation with the model.
///
/// For single-turn queries, this is a single instance. For multi-turn queries
/// like [chat](<https://ai.google.dev/gemini-api/docs/text-generation#chat>),
/// this is a repeated field that contains the conversation history and the
/// latest request.
#[prost(message, repeated, tag = "2")]
pub contents: ::prost::alloc::vec::Vec<Content>,
/// Optional. A list of `Tools` the `Model` may use to generate the next
/// response.
///
/// A `Tool` is a piece of code that enables the system to interact with
/// external systems to perform an action, or set of actions, outside of
/// knowledge and scope of the `Model`. Supported `Tool`s are `Function` and
/// `code_execution`. Refer to the [Function
/// calling](<https://ai.google.dev/gemini-api/docs/function-calling>) and the
/// [Code execution](<https://ai.google.dev/gemini-api/docs/code-execution>)
/// guides to learn more.
#[prost(message, repeated, tag = "5")]
pub tools: ::prost::alloc::vec::Vec<Tool>,
/// Optional. Tool configuration for any `Tool` specified in the request. Refer
/// to the [Function calling
/// guide](<https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode>)
/// for a usage example.
#[prost(message, optional, tag = "7")]
pub tool_config: ::core::option::Option<ToolConfig>,
/// Optional. A list of unique `SafetySetting` instances for blocking unsafe
/// content.
///
/// This will be enforced on the `GenerateContentRequest.contents` and
/// `GenerateContentResponse.candidates`. There should not be more than one
/// setting for each `SafetyCategory` type. The API will block any contents and
/// responses that fail to meet the thresholds set by these settings. This list
/// overrides the default settings for each `SafetyCategory` specified in the
/// safety_settings. If there is no `SafetySetting` for a given
/// `SafetyCategory` provided in the list, the API will use the default safety
/// setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH,
/// HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT,
/// HARM_CATEGORY_HARASSMENT are supported. Refer to the
/// [guide](<https://ai.google.dev/gemini-api/docs/safety-settings>)
/// for detailed information on available safety settings. Also refer to the
/// [Safety guidance](<https://ai.google.dev/gemini-api/docs/safety-guidance>) to
/// learn how to incorporate safety considerations in your AI applications.
#[prost(message, repeated, tag = "3")]
pub safety_settings: ::prost::alloc::vec::Vec<SafetySetting>,
/// Optional. Configuration options for model generation and outputs.
#[prost(message, optional, tag = "4")]
pub generation_config: ::core::option::Option<GenerationConfig>,
/// Optional. The name of the content
/// [cached](<https://ai.google.dev/gemini-api/docs/caching>) to use as context
/// to serve the prediction. Format: `cachedContents/{cachedContent}`
#[prost(string, optional, tag = "9")]
pub cached_content: ::core::option::Option<::prost::alloc::string::String>,
}
/// Configuration options for model generation and outputs. Not all parameters
/// are configurable for every model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerationConfig {
/// Optional. Number of generated responses to return.
///
/// Currently, this value can only be set to 1. If unset, this will default
/// to 1.
#[prost(int32, optional, tag = "1")]
pub candidate_count: ::core::option::Option<i32>,
/// Optional. The set of character sequences (up to 5) that will stop output
/// generation. If specified, the API will stop at the first appearance of a
/// `stop_sequence`. The stop sequence will not be included as part of the
/// response.
#[prost(string, repeated, tag = "2")]
pub stop_sequences: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional. The maximum number of tokens to include in a response candidate.
///
/// Note: The default value varies by model, see the `Model.output_token_limit`
/// attribute of the `Model` returned from the `getModel` function.
#[prost(int32, optional, tag = "4")]
pub max_output_tokens: ::core::option::Option<i32>,
/// Optional. Controls the randomness of the output.
///
/// Note: The default value varies by model, see the `Model.temperature`
/// attribute of the `Model` returned from the `getModel` function.
///
/// Values can range from \[0.0, 2.0\].
#[prost(float, optional, tag = "5")]
pub temperature: ::core::option::Option<f32>,
/// Optional. The maximum cumulative probability of tokens to consider when
/// sampling.
///
/// The model uses combined Top-k and Top-p (nucleus) sampling.
///
/// Tokens are sorted based on their assigned probabilities so that only the
/// most likely tokens are considered. Top-k sampling directly limits the
/// maximum number of tokens to consider, while Nucleus sampling limits the
/// number of tokens based on the cumulative probability.
///
/// Note: The default value varies by `Model` and is specified by
/// the`Model.top_p` attribute returned from the `getModel` function. An empty
/// `top_k` attribute indicates that the model doesn't apply top-k sampling
/// and doesn't allow setting `top_k` on requests.
#[prost(float, optional, tag = "6")]
pub top_p: ::core::option::Option<f32>,
/// Optional. The maximum number of tokens to consider when sampling.
///
/// Gemini models use Top-p (nucleus) sampling or a combination of Top-k and
/// nucleus sampling. Top-k sampling considers the set of `top_k` most probable
/// tokens. Models running with nucleus sampling don't allow top_k setting.
///
/// Note: The default value varies by `Model` and is specified by
/// the`Model.top_p` attribute returned from the `getModel` function. An empty
/// `top_k` attribute indicates that the model doesn't apply top-k sampling
/// and doesn't allow setting `top_k` on requests.
#[prost(int32, optional, tag = "7")]
pub top_k: ::core::option::Option<i32>,
/// Optional. MIME type of the generated candidate text.
/// Supported MIME types are:
/// `text/plain`: (default) Text output.
/// `application/json`: JSON response in the response candidates.
/// Refer to the
/// [docs](<https://ai.google.dev/gemini-api/docs/prompting_with_media#plain_text_formats>)
/// for a list of all supported text MIME types.
#[prost(string, tag = "13")]
pub response_mime_type: ::prost::alloc::string::String,
/// Optional. Output schema of the generated candidate text. Schemas must be a
/// subset of the [OpenAPI schema](<https://spec.openapis.org/oas/v3.0.3#schema>)
/// and can be objects, primitives or arrays.
///
/// If set, a compatible `response_mime_type` must also be set.
/// Compatible MIME types:
/// `application/json`: Schema for JSON response.
/// Refer to the [JSON text generation
/// guide](<https://ai.google.dev/gemini-api/docs/json-mode>) for more details.
#[prost(message, optional, tag = "14")]
pub response_schema: ::core::option::Option<Schema>,
}
/// Configuration for retrieving grounding content from a `Corpus` or
/// `Document` created using the Semantic Retriever API.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SemanticRetrieverConfig {
/// Required. Name of the resource for retrieval. Example: `corpora/123` or
/// `corpora/123/documents/abc`.
#[prost(string, tag = "1")]
pub source: ::prost::alloc::string::String,
/// Required. Query to use for matching `Chunk`s in the given resource by
/// similarity.
#[prost(message, optional, tag = "2")]
pub query: ::core::option::Option<Content>,
/// Optional. Filters for selecting `Document`s and/or `Chunk`s from the
/// resource.
#[prost(message, repeated, tag = "3")]
pub metadata_filters: ::prost::alloc::vec::Vec<MetadataFilter>,
/// Optional. Maximum number of relevant `Chunk`s to retrieve.
#[prost(int32, optional, tag = "4")]
pub max_chunks_count: ::core::option::Option<i32>,
/// Optional. Minimum relevance score for retrieved relevant `Chunk`s.
#[prost(float, optional, tag = "5")]
pub minimum_relevance_score: ::core::option::Option<f32>,
}
/// Response from the model supporting multiple candidate responses.
///
/// Safety ratings and content filtering are reported for both
/// prompt in `GenerateContentResponse.prompt_feedback` and for each candidate
/// in `finish_reason` and in `safety_ratings`. The API:
/// - Returns either all requested candidates or none of them
/// - Returns no candidates at all only if there was something wrong with the
/// prompt (check `prompt_feedback`)
/// - Reports feedback on each candidate in `finish_reason` and
/// `safety_ratings`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateContentResponse {
/// Candidate responses from the model.
#[prost(message, repeated, tag = "1")]
pub candidates: ::prost::alloc::vec::Vec<Candidate>,
/// Returns the prompt's feedback related to the content filters.
#[prost(message, optional, tag = "2")]
pub prompt_feedback: ::core::option::Option<
generate_content_response::PromptFeedback,
>,
/// Output only. Metadata on the generation requests' token usage.
#[prost(message, optional, tag = "3")]
pub usage_metadata: ::core::option::Option<generate_content_response::UsageMetadata>,
}
/// Nested message and enum types in `GenerateContentResponse`.
pub mod generate_content_response {
/// A set of the feedback metadata the prompt specified in
/// `GenerateContentRequest.content`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PromptFeedback {
/// Optional. If set, the prompt was blocked and no candidates are returned.
/// Rephrase the prompt.
#[prost(enumeration = "prompt_feedback::BlockReason", tag = "1")]
pub block_reason: i32,
/// Ratings for safety of the prompt.
/// There is at most one rating per category.
#[prost(message, repeated, tag = "2")]
pub safety_ratings: ::prost::alloc::vec::Vec<super::SafetyRating>,
}
/// Nested message and enum types in `PromptFeedback`.
pub mod prompt_feedback {
/// Specifies the reason why the prompt was blocked.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum BlockReason {
/// Default value. This value is unused.
Unspecified = 0,
/// Prompt was blocked due to safety reasons. Inspect `safety_ratings`
/// to understand which safety category blocked it.
Safety = 1,
/// Prompt was blocked due to unknown reasons.
Other = 2,
/// Prompt was blocked due to the terms which are included from the
/// terminology blocklist.
Blocklist = 3,
/// Prompt was blocked due to prohibited content.
ProhibitedContent = 4,
}
impl BlockReason {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
BlockReason::Unspecified => "BLOCK_REASON_UNSPECIFIED",
BlockReason::Safety => "SAFETY",
BlockReason::Other => "OTHER",
BlockReason::Blocklist => "BLOCKLIST",
BlockReason::ProhibitedContent => "PROHIBITED_CONTENT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"BLOCK_REASON_UNSPECIFIED" => Some(Self::Unspecified),
"SAFETY" => Some(Self::Safety),
"OTHER" => Some(Self::Other),
"BLOCKLIST" => Some(Self::Blocklist),
"PROHIBITED_CONTENT" => Some(Self::ProhibitedContent),
_ => None,
}
}
}
}
/// Metadata on the generation request's token usage.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct UsageMetadata {
/// Number of tokens in the prompt. When `cached_content` is set, this is
/// still the total effective prompt size meaning this includes the number of
/// tokens in the cached content.
#[prost(int32, tag = "1")]
pub prompt_token_count: i32,
/// Number of tokens in the cached part of the prompt (the cached content)
#[prost(int32, tag = "4")]
pub cached_content_token_count: i32,
/// Total number of tokens across all the generated response candidates.
#[prost(int32, tag = "2")]
pub candidates_token_count: i32,
/// Total token count for the generation request (prompt + response
/// candidates).
#[prost(int32, tag = "3")]
pub total_token_count: i32,
}
}
/// A response candidate generated from the model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Candidate {
/// Output only. Index of the candidate in the list of response candidates.
#[prost(int32, optional, tag = "3")]
pub index: ::core::option::Option<i32>,
/// Output only. Generated content returned from the model.
#[prost(message, optional, tag = "1")]
pub content: ::core::option::Option<Content>,
/// Optional. Output only. The reason why the model stopped generating tokens.
///
/// If empty, the model has not stopped generating tokens.
#[prost(enumeration = "candidate::FinishReason", tag = "2")]
pub finish_reason: i32,
/// List of ratings for the safety of a response candidate.
///
/// There is at most one rating per category.
#[prost(message, repeated, tag = "5")]
pub safety_ratings: ::prost::alloc::vec::Vec<SafetyRating>,
/// Output only. Citation information for model-generated candidate.
///
/// This field may be populated with recitation information for any text
/// included in the `content`. These are passages that are "recited" from
/// copyrighted material in the foundational LLM's training data.
#[prost(message, optional, tag = "6")]
pub citation_metadata: ::core::option::Option<CitationMetadata>,
/// Output only. Token count for this candidate.
#[prost(int32, tag = "7")]
pub token_count: i32,
/// Output only. Attribution information for sources that contributed to a
/// grounded answer.
///
/// This field is populated for `GenerateAnswer` calls.
#[prost(message, repeated, tag = "8")]
pub grounding_attributions: ::prost::alloc::vec::Vec<GroundingAttribution>,
}
/// Nested message and enum types in `Candidate`.
pub mod candidate {
/// Defines the reason why the model stopped generating tokens.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum FinishReason {
/// Default value. This value is unused.
Unspecified = 0,
/// Natural stop point of the model or provided stop sequence.
Stop = 1,
/// The maximum number of tokens as specified in the request was reached.
MaxTokens = 2,
/// The response candidate content was flagged for safety reasons.
Safety = 3,
/// The response candidate content was flagged for recitation reasons.
Recitation = 4,
/// The response candidate content was flagged for using an unsupported
/// language.
Language = 6,
/// Unknown reason.
Other = 5,
/// Token generation stopped because the content contains forbidden terms.
Blocklist = 7,
/// Token generation stopped for potentially containing prohibited content.
ProhibitedContent = 8,
/// Token generation stopped because the content potentially contains
/// Sensitive Personally Identifiable Information (SPII).
Spii = 9,
/// The function call generated by the model is invalid.
MalformedFunctionCall = 10,
}
impl FinishReason {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
FinishReason::Unspecified => "FINISH_REASON_UNSPECIFIED",
FinishReason::Stop => "STOP",
FinishReason::MaxTokens => "MAX_TOKENS",
FinishReason::Safety => "SAFETY",
FinishReason::Recitation => "RECITATION",
FinishReason::Language => "LANGUAGE",
FinishReason::Other => "OTHER",
FinishReason::Blocklist => "BLOCKLIST",
FinishReason::ProhibitedContent => "PROHIBITED_CONTENT",
FinishReason::Spii => "SPII",
FinishReason::MalformedFunctionCall => "MALFORMED_FUNCTION_CALL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"FINISH_REASON_UNSPECIFIED" => Some(Self::Unspecified),
"STOP" => Some(Self::Stop),
"MAX_TOKENS" => Some(Self::MaxTokens),
"SAFETY" => Some(Self::Safety),
"RECITATION" => Some(Self::Recitation),
"LANGUAGE" => Some(Self::Language),
"OTHER" => Some(Self::Other),
"BLOCKLIST" => Some(Self::Blocklist),
"PROHIBITED_CONTENT" => Some(Self::ProhibitedContent),
"SPII" => Some(Self::Spii),
"MALFORMED_FUNCTION_CALL" => Some(Self::MalformedFunctionCall),
_ => None,
}
}
}
}
/// Identifier for the source contributing to this attribution.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AttributionSourceId {
#[prost(oneof = "attribution_source_id::Source", tags = "1, 2")]
pub source: ::core::option::Option<attribution_source_id::Source>,
}
/// Nested message and enum types in `AttributionSourceId`.
pub mod attribution_source_id {
/// Identifier for a part within a `GroundingPassage`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GroundingPassageId {
/// Output only. ID of the passage matching the `GenerateAnswerRequest`'s
/// `GroundingPassage.id`.
#[prost(string, tag = "1")]
pub passage_id: ::prost::alloc::string::String,
/// Output only. Index of the part within the `GenerateAnswerRequest`'s
/// `GroundingPassage.content`.
#[prost(int32, tag = "2")]
pub part_index: i32,
}
/// Identifier for a `Chunk` retrieved via Semantic Retriever specified in the
/// `GenerateAnswerRequest` using `SemanticRetrieverConfig`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SemanticRetrieverChunk {
/// Output only. Name of the source matching the request's
/// `SemanticRetrieverConfig.source`. Example: `corpora/123` or
/// `corpora/123/documents/abc`
#[prost(string, tag = "1")]
pub source: ::prost::alloc::string::String,
/// Output only. Name of the `Chunk` containing the attributed text.
/// Example: `corpora/123/documents/abc/chunks/xyz`
#[prost(string, tag = "2")]
pub chunk: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Source {
/// Identifier for an inline passage.
#[prost(message, tag = "1")]
GroundingPassage(GroundingPassageId),
/// Identifier for a `Chunk` fetched via Semantic Retriever.
#[prost(message, tag = "2")]
SemanticRetrieverChunk(SemanticRetrieverChunk),
}
}
/// Attribution for a source that contributed to an answer.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GroundingAttribution {
/// Output only. Identifier for the source contributing to this attribution.
#[prost(message, optional, tag = "3")]
pub source_id: ::core::option::Option<AttributionSourceId>,
/// Grounding source content that makes up this attribution.
#[prost(message, optional, tag = "2")]
pub content: ::core::option::Option<Content>,
}
/// Request to generate a grounded answer from the `Model`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateAnswerRequest {
/// Required. The name of the `Model` to use for generating the grounded
/// response.
///
/// Format: `model=models/{model}`.
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Required. The content of the current conversation with the `Model`. For
/// single-turn queries, this is a single question to answer. For multi-turn
/// queries, this is a repeated field that contains conversation history and
/// the last `Content` in the list containing the question.
///
/// Note: `GenerateAnswer` only supports queries in English.
#[prost(message, repeated, tag = "2")]
pub contents: ::prost::alloc::vec::Vec<Content>,
/// Required. Style in which answers should be returned.
#[prost(enumeration = "generate_answer_request::AnswerStyle", tag = "5")]
pub answer_style: i32,
/// Optional. A list of unique `SafetySetting` instances for blocking unsafe
/// content.
///
/// This will be enforced on the `GenerateAnswerRequest.contents` and
/// `GenerateAnswerResponse.candidate`. There should not be more than one
/// setting for each `SafetyCategory` type. The API will block any contents and
/// responses that fail to meet the thresholds set by these settings. This list
/// overrides the default settings for each `SafetyCategory` specified in the
/// safety_settings. If there is no `SafetySetting` for a given
/// `SafetyCategory` provided in the list, the API will use the default safety
/// setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH,
/// HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT,
/// HARM_CATEGORY_HARASSMENT are supported.
/// Refer to the
/// [guide](<https://ai.google.dev/gemini-api/docs/safety-settings>)
/// for detailed information on available safety settings. Also refer to the
/// [Safety guidance](<https://ai.google.dev/gemini-api/docs/safety-guidance>) to
/// learn how to incorporate safety considerations in your AI applications.
#[prost(message, repeated, tag = "3")]
pub safety_settings: ::prost::alloc::vec::Vec<SafetySetting>,
/// Optional. Controls the randomness of the output.
///
/// Values can range from \[0.0,1.0\], inclusive. A value closer to 1.0 will
/// produce responses that are more varied and creative, while a value closer
/// to 0.0 will typically result in more straightforward responses from the
/// model. A low temperature (~0.2) is usually recommended for
/// Attributed-Question-Answering use cases.
#[prost(float, optional, tag = "4")]
pub temperature: ::core::option::Option<f32>,
/// The sources in which to ground the answer.
#[prost(oneof = "generate_answer_request::GroundingSource", tags = "6, 7")]
pub grounding_source: ::core::option::Option<
generate_answer_request::GroundingSource,
>,
}
/// Nested message and enum types in `GenerateAnswerRequest`.
pub mod generate_answer_request {
/// Style for grounded answers.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum AnswerStyle {
/// Unspecified answer style.
Unspecified = 0,
/// Succint but abstract style.
Abstractive = 1,
/// Very brief and extractive style.
Extractive = 2,
/// Verbose style including extra details. The response may be formatted as a
/// sentence, paragraph, multiple paragraphs, or bullet points, etc.
Verbose = 3,
}
impl AnswerStyle {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
AnswerStyle::Unspecified => "ANSWER_STYLE_UNSPECIFIED",
AnswerStyle::Abstractive => "ABSTRACTIVE",
AnswerStyle::Extractive => "EXTRACTIVE",
AnswerStyle::Verbose => "VERBOSE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ANSWER_STYLE_UNSPECIFIED" => Some(Self::Unspecified),
"ABSTRACTIVE" => Some(Self::Abstractive),
"EXTRACTIVE" => Some(Self::Extractive),
"VERBOSE" => Some(Self::Verbose),
_ => None,
}
}
}
/// The sources in which to ground the answer.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum GroundingSource {
/// Passages provided inline with the request.
#[prost(message, tag = "6")]
InlinePassages(super::GroundingPassages),
/// Content retrieved from resources created via the Semantic Retriever
/// API.
#[prost(message, tag = "7")]
SemanticRetriever(super::SemanticRetrieverConfig),
}
}
/// Response from the model for a grounded answer.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenerateAnswerResponse {
/// Candidate answer from the model.
///
/// Note: The model *always* attempts to provide a grounded answer, even when
/// the answer is unlikely to be answerable from the given passages.
/// In that case, a low-quality or ungrounded answer may be provided, along
/// with a low `answerable_probability`.
#[prost(message, optional, tag = "1")]
pub answer: ::core::option::Option<Candidate>,
/// Output only. The model's estimate of the probability that its answer is
/// correct and grounded in the input passages.
///
/// A low `answerable_probability` indicates that the answer might not be
/// grounded in the sources.
///
/// When `answerable_probability` is low, you may want to:
///
/// * Display a message to the effect of "We couldn’t answer that question" to
/// the user.
/// * Fall back to a general-purpose LLM that answers the question from world
/// knowledge. The threshold and nature of such fallbacks will depend on
/// individual use cases. `0.5` is a good starting threshold.
#[prost(float, optional, tag = "2")]
pub answerable_probability: ::core::option::Option<f32>,
/// Output only. Feedback related to the input data used to answer the
/// question, as opposed to the model-generated response to the question.
///
/// The input data can be one or more of the following:
///
/// - Question specified by the last entry in `GenerateAnswerRequest.content`
/// - Conversation history specified by the other entries in
/// `GenerateAnswerRequest.content`
/// - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or
/// `GenerateAnswerRequest.inline_passages`)
#[prost(message, optional, tag = "3")]
pub input_feedback: ::core::option::Option<generate_answer_response::InputFeedback>,
}
/// Nested message and enum types in `GenerateAnswerResponse`.
pub mod generate_answer_response {
/// Feedback related to the input data used to answer the question, as opposed
/// to the model-generated response to the question.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InputFeedback {
/// Optional. If set, the input was blocked and no candidates are returned.
/// Rephrase the input.
#[prost(enumeration = "input_feedback::BlockReason", optional, tag = "1")]
pub block_reason: ::core::option::Option<i32>,
/// Ratings for safety of the input.
/// There is at most one rating per category.
#[prost(message, repeated, tag = "2")]
pub safety_ratings: ::prost::alloc::vec::Vec<super::SafetyRating>,
}
/// Nested message and enum types in `InputFeedback`.
pub mod input_feedback {
/// Specifies what was the reason why input was blocked.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum BlockReason {
/// Default value. This value is unused.
Unspecified = 0,
/// Input was blocked due to safety reasons. Inspect
/// `safety_ratings` to understand which safety category blocked it.
Safety = 1,
/// Input was blocked due to other reasons.
Other = 2,
}
impl BlockReason {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
BlockReason::Unspecified => "BLOCK_REASON_UNSPECIFIED",
BlockReason::Safety => "SAFETY",
BlockReason::Other => "OTHER",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"BLOCK_REASON_UNSPECIFIED" => Some(Self::Unspecified),
"SAFETY" => Some(Self::Safety),
"OTHER" => Some(Self::Other),
_ => None,
}
}
}
}
}
/// Request containing the `Content` for the model to embed.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmbedContentRequest {
/// Required. The model's resource name. This serves as an ID for the Model to
/// use.
///
/// This name should match a model name returned by the `ListModels` method.
///
/// Format: `models/{model}`
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Required. The content to embed. Only the `parts.text` fields will be
/// counted.
#[prost(message, optional, tag = "2")]
pub content: ::core::option::Option<Content>,
/// Optional. Optional task type for which the embeddings will be used. Can
/// only be set for `models/embedding-001`.
#[prost(enumeration = "TaskType", optional, tag = "3")]
pub task_type: ::core::option::Option<i32>,
/// Optional. An optional title for the text. Only applicable when TaskType is
/// `RETRIEVAL_DOCUMENT`.
///
/// Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality
/// embeddings for retrieval.
#[prost(string, optional, tag = "4")]
pub title: ::core::option::Option<::prost::alloc::string::String>,
/// Optional. Optional reduced dimension for the output embedding. If set,
/// excessive values in the output embedding are truncated from the end.
/// Supported by newer models since 2024 only. You cannot set this value if
/// using the earlier model (`models/embedding-001`).
#[prost(int32, optional, tag = "5")]
pub output_dimensionality: ::core::option::Option<i32>,
}
/// A list of floats representing an embedding.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContentEmbedding {
/// The embedding values.
#[prost(float, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<f32>,
}
/// The response to an `EmbedContentRequest`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EmbedContentResponse {
/// Output only. The embedding generated from the input content.
#[prost(message, optional, tag = "1")]
pub embedding: ::core::option::Option<ContentEmbedding>,
}
/// Batch request to get embeddings from the model for a list of prompts.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchEmbedContentsRequest {
/// Required. The model's resource name. This serves as an ID for the Model to
/// use.
///
/// This name should match a model name returned by the `ListModels` method.
///
/// Format: `models/{model}`
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Required. Embed requests for the batch. The model in each of these requests
/// must match the model specified `BatchEmbedContentsRequest.model`.
#[prost(message, repeated, tag = "2")]
pub requests: ::prost::alloc::vec::Vec<EmbedContentRequest>,
}
/// The response to a `BatchEmbedContentsRequest`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchEmbedContentsResponse {
/// Output only. The embeddings for each request, in the same order as provided
/// in the batch request.
#[prost(message, repeated, tag = "1")]
pub embeddings: ::prost::alloc::vec::Vec<ContentEmbedding>,
}
/// Counts the number of tokens in the `prompt` sent to a model.
///
/// Models may tokenize text differently, so each model may return a different
/// `token_count`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CountTokensRequest {
/// Required. The model's resource name. This serves as an ID for the Model to
/// use.
///
/// This name should match a model name returned by the `ListModels` method.
///
/// Format: `models/{model}`
#[prost(string, tag = "1")]
pub model: ::prost::alloc::string::String,
/// Optional. The input given to the model as a prompt. This field is ignored
/// when `generate_content_request` is set.
#[prost(message, repeated, tag = "2")]
pub contents: ::prost::alloc::vec::Vec<Content>,
/// Optional. The overall input given to the `Model`. This includes the prompt
/// as well as other model steering information like [system
/// instructions](<https://ai.google.dev/gemini-api/docs/system-instructions>),
/// and/or function declarations for [function
/// calling](<https://ai.google.dev/gemini-api/docs/function-calling>).
/// `Model`s/`Content`s and `generate_content_request`s are mutually
/// exclusive. You can either send `Model` + `Content`s or a
/// `generate_content_request`, but never both.
#[prost(message, optional, tag = "3")]
pub generate_content_request: ::core::option::Option<GenerateContentRequest>,
}
/// A response from `CountTokens`.
///
/// It returns the model's `token_count` for the `prompt`.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CountTokensResponse {
/// The number of tokens that the `Model` tokenizes the `prompt` into. Always
/// non-negative.
#[prost(int32, tag = "1")]
pub total_tokens: i32,
/// Number of tokens in the cached part of the prompt, i.e. in the cached
/// content.
#[prost(int32, tag = "5")]
pub cached_content_token_count: i32,
}
/// Type of task for which the embedding will be used.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum TaskType {
/// Unset value, which will default to one of the other enum values.
Unspecified = 0,
/// Specifies the given text is a query in a search/retrieval setting.
RetrievalQuery = 1,
/// Specifies the given text is a document from the corpus being searched.
RetrievalDocument = 2,
/// Specifies the given text will be used for STS.
SemanticSimilarity = 3,
/// Specifies that the given text will be classified.
Classification = 4,
/// Specifies that the embeddings will be used for clustering.
Clustering = 5,
/// Specifies that the given text will be used for question answering.
QuestionAnswering = 6,
/// Specifies that the given text will be used for fact verification.
FactVerification = 7,
}
impl TaskType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
TaskType::Unspecified => "TASK_TYPE_UNSPECIFIED",
TaskType::RetrievalQuery => "RETRIEVAL_QUERY",
TaskType::RetrievalDocument => "RETRIEVAL_DOCUMENT",
TaskType::SemanticSimilarity => "SEMANTIC_SIMILARITY",
TaskType::Classification => "CLASSIFICATION",
TaskType::Clustering => "CLUSTERING",
TaskType::QuestionAnswering => "QUESTION_ANSWERING",
TaskType::FactVerification => "FACT_VERIFICATION",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"TASK_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"RETRIEVAL_QUERY" => Some(Self::RetrievalQuery),
"RETRIEVAL_DOCUMENT" => Some(Self::RetrievalDocument),
"SEMANTIC_SIMILARITY" => Some(Self::SemanticSimilarity),
"CLASSIFICATION" => Some(Self::Classification),
"CLUSTERING" => Some(Self::Clustering),
"QUESTION_ANSWERING" => Some(Self::QuestionAnswering),
"FACT_VERIFICATION" => Some(Self::FactVerification),
_ => None,
}
}
}
/// Generated client implementations.
pub mod generative_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// API for using Large Models that generate multimodal content and have
/// additional capabilities beyond text generation.
#[derive(Debug, Clone)]
pub struct GenerativeServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> GenerativeServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> GenerativeServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
GenerativeServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Generates a model response given an input `GenerateContentRequest`.
/// Refer to the [text generation
/// guide](https://ai.google.dev/gemini-api/docs/text-generation) for detailed
/// usage information. Input capabilities differ between models, including
/// tuned models. Refer to the [model
/// guide](https://ai.google.dev/gemini-api/docs/models/gemini) and [tuning
/// guide](https://ai.google.dev/gemini-api/docs/model-tuning) for details.
pub async fn generate_content(
&mut self,
request: impl tonic::IntoRequest<super::GenerateContentRequest>,
) -> std::result::Result<
tonic::Response<super::GenerateContentResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.GenerativeService/GenerateContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.GenerativeService",
"GenerateContent",
),
);
self.inner.unary(req, path, codec).await
}
/// Generates a grounded answer from the model given an input
/// `GenerateAnswerRequest`.
pub async fn generate_answer(
&mut self,
request: impl tonic::IntoRequest<super::GenerateAnswerRequest>,
) -> std::result::Result<
tonic::Response<super::GenerateAnswerResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.GenerativeService/GenerateAnswer",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.GenerativeService",
"GenerateAnswer",
),
);
self.inner.unary(req, path, codec).await
}
/// Generates a [streamed
/// response](https://ai.google.dev/gemini-api/docs/text-generation?lang=python#generate-a-text-stream)
/// from the model given an input `GenerateContentRequest`.
pub async fn stream_generate_content(
&mut self,
request: impl tonic::IntoRequest<super::GenerateContentRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GenerateContentResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.GenerativeService/StreamGenerateContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.GenerativeService",
"StreamGenerateContent",
),
);
self.inner.server_streaming(req, path, codec).await
}
/// Generates a text embedding vector from the input `Content` using the
/// specified [Gemini Embedding
/// model](https://ai.google.dev/gemini-api/docs/models/gemini#text-embedding).
pub async fn embed_content(
&mut self,
request: impl tonic::IntoRequest<super::EmbedContentRequest>,
) -> std::result::Result<
tonic::Response<super::EmbedContentResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.GenerativeService/EmbedContent",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.GenerativeService",
"EmbedContent",
),
);
self.inner.unary(req, path, codec).await
}
/// Generates multiple embedding vectors from the input `Content` which
/// consists of a batch of strings represented as `EmbedContentRequest`
/// objects.
pub async fn batch_embed_contents(
&mut self,
request: impl tonic::IntoRequest<super::BatchEmbedContentsRequest>,
) -> std::result::Result<
tonic::Response<super::BatchEmbedContentsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.GenerativeService/BatchEmbedContents",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.GenerativeService",
"BatchEmbedContents",
),
);
self.inner.unary(req, path, codec).await
}
/// Runs a model's tokenizer on input `Content` and returns the token count.
/// Refer to the [tokens guide](https://ai.google.dev/gemini-api/docs/tokens)
/// to learn more about tokens.
pub async fn count_tokens(
&mut self,
request: impl tonic::IntoRequest<super::CountTokensRequest>,
) -> std::result::Result<
tonic::Response<super::CountTokensResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.ai.generativelanguage.v1beta.GenerativeService/CountTokens",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.ai.generativelanguage.v1beta.GenerativeService",
"CountTokens",
),
);
self.inner.unary(req, path, codec).await
}
}
}