Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: add models for gitee.ai (#9490)
方程0ebd9856725e
diff --git a/api/core/model_runtime/model_providers/gitee_ai/_assets/Gitee-AI-Logo-full.svg b/api/core/model_runtime/model_providers/gitee_ai/_assets/Gitee-AI-Logo-full.svgnew file mode 100644index 00000000000..f9738b585b7--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/_assets/Gitee-AI-Logo-full.svg@@ -0,0 +1,6 @@+<svg width="145" height="40" viewBox="0 0 145 40" fill="none" xmlns="http://www.w3.org/2000/svg">+<path fill-rule="evenodd" clip-rule="evenodd" d="M25.132 24.3947C25.497 25.7527 25.8984 27.1413 26.3334 28.5834C26.7302 29.8992 25.5459 30.4167 25.0752 29.1758C24.571 27.8466 24.0885 26.523 23.6347 25.1729C21.065 26.4654 18.5025 27.5424 15.5961 28.7541C16.7581 33.0256 17.8309 36.5984 19.4952 39.9935C19.4953 39.9936 19.4953 39.9937 19.4954 39.9938C19.6631 39.9979 19.8313 40 20 40C31.0457 40 40 31.0457 40 20C40 16.0335 38.8453 12.3366 36.8537 9.22729C31.6585 9.69534 27.0513 10.4562 22.8185 11.406C22.8882 12.252 22.9677 13.0739 23.0555 13.855C23.3824 16.7604 23.9112 19.5281 24.6137 22.3836C27.0581 21.2848 29.084 20.3225 30.6816 19.522C32.2154 18.7535 33.6943 18.7062 31.2018 20.6594C29.0388 22.1602 27.0644 23.3566 25.132 24.3947ZM36.1559 8.20846C33.0001 3.89184 28.1561 0.887462 22.5955 0.166882C22.4257 2.86234 22.4785 6.26344 22.681 9.50447C26.7473 8.88859 31.1721 8.46032 36.1559 8.20846ZM19.9369 9.73661e-05C19.7594 2.92694 19.8384 6.65663 20.19 9.91293C17.3748 10.4109 14.7225 11.0064 12.1592 11.7038C12.0486 10.4257 11.9927 9.25764 11.9927 8.24178C11.9927 7.5054 11.3957 6.90844 10.6593 6.90844C9.92296 6.90844 9.32601 7.5054 9.32601 8.24178C9.32601 9.47868 9.42873 10.898 9.61402 12.438C8.33567 12.8278 7.07397 13.2443 5.81918 13.688C5.12493 13.9336 4.76118 14.6954 5.0067 15.3896C5.25223 16.0839 6.01406 16.4476 6.7083 16.2021C7.7931 15.8185 8.88482 15.4388 9.98927 15.0659C10.5222 18.3344 11.3344 21.9428 12.2703 25.4156C12.4336 26.0218 12.6062 26.6262 12.7863 27.2263C9.34168 28.4135 5.82612 29.3782 2.61128 29.8879C0.949407 26.9716 0 23.5967 0 20C0 8.97534 8.92023 0.0341108 19.9369 9.73661e-05ZM4.19152 32.2527C7.45069 36.4516 12.3458 39.3173 17.9204 39.8932C16.5916 37.455 14.9338 33.717 13.5405 29.5901C10.4404 30.7762 7.25883 31.6027 4.19152 32.2527ZM22.9735 23.1135C22.1479 20.41 21.4462 17.5441 20.9225 14.277C20.746 13.5841 20.5918 12.8035 20.4593 11.9636C17.6508 12.6606 14.9992 13.4372 12.4356 14.2598C12.8479 17.4766 13.5448 21.1334 14.5118 24.7218C14.662 25.2792 14.8081 25.8248 14.9514 26.3594L14.9516 26.3603L14.9524 26.3634L14.9526 26.3639L14.973 26.4401C16.1833 25.9872 17.3746 25.5123 18.53 25.0259C20.1235 24.3552 21.6051 23.7165 22.9735 23.1135Z" fill="#141519"/>+<path d="M57.0058 34.9872C59.7347 34.9872 61.9133 34.4549 63.5416 33.3903C65.1699 32.3257 65.984 30.9471 65.984 29.2547C65.984 26.5249 63.9464 25.1601 59.8712 25.1601H57.3605C56.5236 25.1601 55.9233 25.0782 55.5594 24.9144C55.1956 24.7506 55.0136 24.4776 55.0136 24.0955C55.0136 23.7133 55.1319 23.3948 55.3684 23.14C55.4593 23.0309 55.5776 22.9945 55.7231 23.0309C56.3053 23.1946 56.8602 23.2765 57.3878 23.2765C59.2617 23.2765 60.7854 22.8261 61.9588 21.9253C63.1323 21.0245 63.719 19.6915 63.719 17.9262C63.719 17.2711 63.6007 16.6887 63.3642 16.1792C63.346 16.1428 63.3506 16.1018 63.3779 16.0563C63.4051 16.0108 63.4461 15.9881 63.5007 15.9881H64.1283C64.5831 15.9881 64.9652 15.8334 65.2745 15.524C65.5838 15.2147 65.7384 14.8325 65.7384 14.3775V13.9954C65.7384 13.5586 65.5838 13.181 65.2745 12.8625C64.9652 12.5441 64.5831 12.3848 64.1283 12.3848H60.1168C59.9894 12.3848 59.853 12.3666 59.7074 12.3302C58.9979 12.1118 58.2247 12.0027 57.3878 12.0027C56.2053 12.0027 55.1228 12.2074 54.1404 12.6168C53.1579 13.0263 52.3438 13.6814 51.6979 14.5823C51.0521 15.4831 50.7292 16.5522 50.7292 17.7897C50.7292 18.6451 50.9293 19.4276 51.3295 20.1373C51.7298 20.8471 52.2301 21.4203 52.8305 21.8571C52.8668 21.8753 52.885 21.9026 52.885 21.939C52.885 21.9754 52.8668 22.0118 52.8305 22.0481C52.3211 22.4121 51.9117 22.8534 51.6024 23.3721C51.2932 23.8907 51.1385 24.423 51.1385 24.969C51.1385 26.1337 51.6024 27.0345 52.5303 27.6714C52.5667 27.6896 52.5849 27.7215 52.5849 27.767C52.5849 27.8125 52.5667 27.8534 52.5303 27.8898C51.8026 28.2538 51.2522 28.6996 50.8793 29.2274C50.5063 29.7552 50.3198 30.3375 50.3198 30.9744C50.3198 31.8844 50.6291 32.6487 51.2477 33.2674C51.8662 33.8862 52.6622 34.3275 53.6355 34.5914C54.6088 34.8552 55.7322 34.9872 57.0058 34.9872ZM57.3878 20.2738C56.7874 20.2738 56.3008 20.06 55.9278 19.6323C55.5549 19.2047 55.3684 18.5905 55.3684 17.7897C55.3684 17.0072 55.5549 16.4021 55.9278 15.9744C56.3008 15.5468 56.7874 15.333 57.3878 15.333C57.9882 15.333 58.4748 15.5422 58.8478 15.9608C59.2208 16.3794 59.4072 16.989 59.4072 17.7897C59.4072 18.5905 59.2208 19.2047 58.8478 19.6323C58.4748 20.06 57.9882 20.2738 57.3878 20.2738ZM57.7699 31.8753C56.7329 31.8753 55.9096 31.7342 55.3002 31.4522C54.6907 31.1701 54.386 30.747 54.386 30.1828C54.386 29.7279 54.5952 29.3002 55.0136 28.8998C55.0682 28.8452 55.1501 28.8179 55.2592 28.8179H55.3411C55.7959 28.9089 56.4873 28.9544 57.4151 28.9544H58.916C59.7165 28.9544 60.3032 29.0363 60.6762 29.2001C61.0492 29.3639 61.2356 29.6642 61.2356 30.1009C61.2356 30.6105 60.9127 31.0336 60.2669 31.3703C59.621 31.7069 58.7887 31.8753 57.7699 31.8753ZM70.978 10.0918C71.7967 10.0918 72.4698 9.85524 72.9974 9.38209C73.525 8.90893 73.7888 8.29928 73.7888 7.55315C73.7888 6.80702 73.525 6.19282 72.9974 5.71057C72.4698 5.22831 71.7967 4.98718 70.978 4.98718C70.1411 4.98718 69.4543 5.22831 68.9176 5.71057C68.3809 6.19282 68.1126 6.80702 68.1126 7.55315C68.1126 8.29928 68.3809 8.90893 68.9176 9.38209C69.4543 9.85524 70.1411 10.0918 70.978 10.0918ZM71.824 28.2174C72.2606 28.2174 72.6381 28.0582 72.9565 27.7397C73.2749 27.4212 73.434 27.0436 73.434 26.6068V13.9135C73.434 13.4767 73.2749 13.0991 72.9565 12.7806C72.6381 12.4622 72.2606 12.3029 71.824 12.3029H70.1047C69.6499 12.3029 69.2678 12.4622 68.9586 12.7806C68.6493 13.0991 68.4946 13.4767 68.4946 13.9135V26.6068C68.4946 27.0436 68.6493 27.4212 68.9586 27.7397C69.2678 28.0582 69.6499 28.2174 70.1047 28.2174H71.824ZM83.6949 28.5996C84.3862 28.5996 85.0685 28.5359 85.7416 28.4085C86.1782 28.3357 86.5148 28.0991 86.7513 27.6987C86.9151 27.4258 86.9969 27.1437 86.9969 26.8525C86.9969 26.7251 86.9878 26.5886 86.9696 26.4431L86.8605 26.0063C86.7695 25.6241 86.5421 25.3193 86.1783 25.0918C85.8144 24.8643 85.405 24.7415 84.9502 24.7233C83.6949 24.6687 83.0672 23.8498 83.0672 22.2665V16.3976C83.0672 16.2702 83.1309 16.2065 83.2583 16.2065H85.1958C85.6325 16.2065 86.01 16.0472 86.3283 15.7288C86.6467 15.4103 86.8059 15.0327 86.8059 14.5959V13.9135C86.8059 13.4767 86.6467 13.0991 86.3283 12.7806C86.01 12.4622 85.6325 12.3029 85.1958 12.3029H83.2583C83.1309 12.3029 83.0672 12.2392 83.0672 12.1118V9.73696C83.0672 9.282 82.9081 8.89983 82.5897 8.59046C82.2713 8.28109 81.8938 8.1264 81.4572 8.1264H80.5293C80.0745 8.1264 79.6742 8.27654 79.3286 8.57681C78.9829 8.87708 78.7737 9.2547 78.7009 9.70966L78.4007 12.1118C78.3825 12.2392 78.3007 12.312 78.1551 12.3302L77.5275 12.3848C77.0726 12.4212 76.6906 12.6077 76.3813 12.9444C76.072 13.2811 75.9174 13.6769 75.9174 14.1319V14.5959C75.9174 15.0327 76.0766 15.4103 76.395 15.7288C76.7133 16.0472 77.0908 16.2065 77.5275 16.2065H77.8822C78.0096 16.2065 78.0733 16.2702 78.0733 16.3976V22.3211C78.0733 24.3047 78.5281 25.8471 79.4377 26.9481C80.3474 28.0491 81.7664 28.5996 83.6949 28.5996ZM97.0395 28.5996C98.4949 28.5996 99.9322 28.2629 101.351 27.5895C101.751 27.4076 102.006 27.0891 102.115 26.6341C102.17 26.4885 102.197 26.343 102.197 26.1974C102.197 25.9244 102.115 25.6514 101.952 25.3784L101.87 25.2147C101.651 24.8325 101.333 24.5777 100.915 24.4503C100.714 24.3957 100.514 24.3684 100.314 24.3684C100.078 24.3684 99.8503 24.4048 99.632 24.4776C99.0134 24.696 98.3767 24.8052 97.7217 24.8052C95.5749 24.8052 94.2741 23.8498 93.8193 21.939C93.8011 21.8844 93.8102 21.8343 93.8466 21.7888C93.883 21.7433 93.9285 21.7206 93.983 21.7206H101.488C101.961 21.7206 102.379 21.5704 102.743 21.2702C103.107 20.9699 103.298 20.5923 103.316 20.1373V19.6187C103.316 17.3257 102.734 15.4694 101.57 14.05C100.405 12.6305 98.7132 11.9208 96.4937 11.9208C95.5295 11.9208 94.5971 12.1164 93.6965 12.5077C92.796 12.8989 91.9955 13.4449 91.295 14.1455C90.5946 14.8461 90.0306 15.7288 89.6031 16.7934C89.1755 17.858 88.9618 19.0181 88.9618 20.2738C88.9618 22.8398 89.7213 24.8689 91.2405 26.3612C92.7596 27.8534 94.6926 28.5996 97.0395 28.5996ZM98.8952 18.4995H93.9012C93.7738 18.4995 93.7102 18.454 93.7102 18.363C93.7102 17.6168 94.0649 16.9526 94.7744 16.3703C95.2839 15.9335 95.8933 15.7151 96.6028 15.7151C97.4215 15.7151 98.0355 15.9471 98.4449 16.4112C98.8542 16.8753 99.0771 17.4986 99.1135 18.2811V18.3084C99.1135 18.4358 99.0407 18.4995 98.8952 18.4995ZM113.686 28.5996C115.142 28.5996 116.579 28.2629 117.998 27.5895C118.398 27.4076 118.653 27.0891 118.762 26.6341C118.817 26.4885 118.844 26.343 118.844 26.1974C118.844 25.9244 118.762 25.6514 118.598 25.3784L118.516 25.2147C118.298 24.8325 117.98 24.5777 117.561 24.4503C117.361 24.3957 117.161 24.3684 116.961 24.3684C116.724 24.3684 116.497 24.4048 116.279 24.4776C115.66 24.696 115.023 24.8052 114.368 24.8052C112.222 24.8052 110.921 23.8498 110.466 21.939C110.448 21.8844 110.457 21.8343 110.493 21.7888C110.53 21.7433 110.575 21.7206 110.63 21.7206H118.134C118.607 21.7206 119.026 21.5704 119.39 21.2702C119.753 20.9699 119.944 20.5923 119.963 20.1373V19.6187C119.963 17.3257 119.38 15.4694 118.216 14.05C117.052 12.6305 115.36 11.9208 113.14 11.9208C112.176 11.9208 111.244 12.1164 110.343 12.5077C109.443 12.8989 108.642 13.4449 107.942 14.1455C107.241 14.8461 106.677 15.7288 106.25 16.7934C105.822 17.858 105.608 19.0181 105.608 20.2738C105.608 22.8398 106.368 24.8689 107.887 26.3612C109.406 27.8534 111.339 28.5996 113.686 28.5996ZM115.542 18.4995H110.548C110.42 18.4995 110.357 18.454 110.357 18.363C110.357 17.6168 110.712 16.9526 111.421 16.3703C111.93 15.9335 112.54 15.7151 113.249 15.7151C114.068 15.7151 114.682 15.9471 115.091 16.4112C115.501 16.8753 115.724 17.4986 115.76 18.2811V18.3084C115.76 18.4358 115.687 18.4995 115.542 18.4995Z" fill="black"/>+<path d="M126.817 28.3723H123.96L131.579 11.7057L139.377 28.3723H136.579L131.579 17.8366L126.817 28.3723Z" fill="black"/>+<path d="M142.141 12.039H144.998V28.3724H142.141V12.039Z" fill="black"/>+</svg>diff --git a/api/core/model_runtime/model_providers/gitee_ai/_assets/Gitee-AI-Logo.svg b/api/core/model_runtime/model_providers/gitee_ai/_assets/Gitee-AI-Logo.svgnew file mode 100644index 00000000000..1f51187f197--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/_assets/Gitee-AI-Logo.svg@@ -0,0 +1,3 @@+<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">+<path fill-rule="evenodd" clip-rule="evenodd" d="M25.132 24.3947C25.497 25.7527 25.8984 27.1413 26.3334 28.5834C26.7302 29.8992 25.5459 30.4167 25.0752 29.1758C24.571 27.8466 24.0885 26.523 23.6347 25.1729C21.065 26.4654 18.5025 27.5424 15.5961 28.7541C16.7581 33.0256 17.8309 36.5984 19.4952 39.9935C19.4953 39.9936 19.4953 39.9937 19.4954 39.9938C19.6631 39.9979 19.8313 40 20 40C31.0457 40 40 31.0457 40 20C40 16.0335 38.8453 12.3366 36.8537 9.22729C31.6585 9.69534 27.0513 10.4562 22.8185 11.406C22.8882 12.252 22.9677 13.0739 23.0555 13.855C23.3824 16.7604 23.9112 19.5281 24.6137 22.3836C27.0581 21.2848 29.084 20.3225 30.6816 19.522C32.2154 18.7535 33.6943 18.7062 31.2018 20.6594C29.0388 22.1602 27.0644 23.3566 25.132 24.3947ZM36.1559 8.20846C33.0001 3.89184 28.1561 0.887462 22.5955 0.166882C22.4257 2.86234 22.4785 6.26344 22.681 9.50447C26.7473 8.88859 31.1721 8.46032 36.1559 8.20846ZM19.9369 9.73661e-05C19.7594 2.92694 19.8384 6.65663 20.19 9.91293C17.3748 10.4109 14.7225 11.0064 12.1592 11.7038C12.0486 10.4257 11.9927 9.25764 11.9927 8.24178C11.9927 7.5054 11.3957 6.90844 10.6593 6.90844C9.92296 6.90844 9.32601 7.5054 9.32601 8.24178C9.32601 9.47868 9.42873 10.898 9.61402 12.438C8.33567 12.8278 7.07397 13.2443 5.81918 13.688C5.12493 13.9336 4.76118 14.6954 5.0067 15.3896C5.25223 16.0839 6.01406 16.4476 6.7083 16.2021C7.7931 15.8185 8.88482 15.4388 9.98927 15.0659C10.5222 18.3344 11.3344 21.9428 12.2703 25.4156C12.4336 26.0218 12.6062 26.6262 12.7863 27.2263C9.34168 28.4135 5.82612 29.3782 2.61128 29.8879C0.949407 26.9716 0 23.5967 0 20C0 8.97534 8.92023 0.0341108 19.9369 9.73661e-05ZM4.19152 32.2527C7.45069 36.4516 12.3458 39.3173 17.9204 39.8932C16.5916 37.455 14.9338 33.717 13.5405 29.5901C10.4404 30.7762 7.25883 31.6027 4.19152 32.2527ZM22.9735 23.1135C22.1479 20.41 21.4462 17.5441 20.9225 14.277C20.746 13.5841 20.5918 12.8035 20.4593 11.9636C17.6508 12.6606 14.9992 13.4372 12.4356 14.2598C12.8479 17.4766 13.5448 21.1334 14.5118 24.7218C14.662 25.2792 14.8081 25.8248 14.9514 26.3594L14.9516 26.3603L14.9524 26.3634L14.9526 26.3639L14.973 26.4401C16.1833 25.9872 17.3746 25.5123 18.53 25.0259C20.1235 24.3552 21.6051 23.7165 22.9735 23.1135Z" fill="#141519"/>+</svg>diff --git a/api/core/model_runtime/model_providers/gitee_ai/_common.py b/api/core/model_runtime/model_providers/gitee_ai/_common.pynew file mode 100644index 00000000000..0750f3b75d0--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/_common.py@@ -0,0 +1,47 @@+from dashscope.common.error import (+ AuthenticationError,+ InvalidParameter,+ RequestFailure,+ ServiceUnavailableError,+ UnsupportedHTTPMethod,+ UnsupportedModel,+)++from core.model_runtime.errors.invoke import (+ InvokeAuthorizationError,+ InvokeBadRequestError,+ InvokeConnectionError,+ InvokeError,+ InvokeRateLimitError,+ InvokeServerUnavailableError,+)+++class _CommonGiteeAI:+ @property+ def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:+ """+ Map model invoke error to unified error+ The key is the error type thrown to the caller+ The value is the error type thrown by the model,+ which needs to be converted into a unified error type for the caller.++ :return: Invoke error mapping+ """+ return {+ InvokeConnectionError: [+ RequestFailure,+ ],+ InvokeServerUnavailableError: [+ ServiceUnavailableError,+ ],+ InvokeRateLimitError: [],+ InvokeAuthorizationError: [+ AuthenticationError,+ ],+ InvokeBadRequestError: [+ InvalidParameter,+ UnsupportedModel,+ UnsupportedHTTPMethod,+ ],+ }diff --git a/api/core/model_runtime/model_providers/gitee_ai/gitee_ai.py b/api/core/model_runtime/model_providers/gitee_ai/gitee_ai.pynew file mode 100644index 00000000000..ca67594ce42--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/gitee_ai.py@@ -0,0 +1,25 @@+import logging++from core.model_runtime.entities.model_entities import ModelType+from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.__base.model_provider import ModelProvider++logger = logging.getLogger(__name__)+++class GiteeAIProvider(ModelProvider):+ def validate_provider_credentials(self, credentials: dict) -> None:+ """+ Validate provider credentials+ if validate failed, raise exception++ :param credentials: provider credentials, credentials form defined in `provider_credential_schema`.+ """+ try:+ model_instance = self.get_model_instance(ModelType.LLM)+ model_instance.validate_credentials(model="Qwen2-7B-Instruct", credentials=credentials)+ except CredentialsValidateFailedError as ex:+ raise ex+ except Exception as ex:+ logger.exception(f"{self.get_provider_schema().provider} credentials validate failed")+ raise exdiff --git a/api/core/model_runtime/model_providers/gitee_ai/gitee_ai.yaml b/api/core/model_runtime/model_providers/gitee_ai/gitee_ai.yamlnew file mode 100644index 00000000000..7f7d0f2e538--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/gitee_ai.yaml@@ -0,0 +1,35 @@+provider: gitee_ai+label:+ en_US: Gitee AI+ zh_Hans: Gitee AI+description:+ en_US: 快速体验大模型,领先探索 AI 开源世界+ zh_Hans: 快速体验大模型,领先探索 AI 开源世界+icon_small:+ en_US: Gitee-AI-Logo.svg+icon_large:+ en_US: Gitee-AI-Logo-full.svg+help:+ title:+ en_US: Get your token from Gitee AI+ zh_Hans: 从 Gitee AI 获取 token+ url:+ en_US: https://ai.gitee.com/dashboard/settings/tokens+supported_model_types:+ - llm+ - text-embedding+ - rerank+ - speech2text+ - tts+configurate_methods:+ - predefined-model+provider_credential_schema:+ credential_form_schemas:+ - variable: api_key+ label:+ en_US: API Key+ type: secret-input+ required: true+ placeholder:+ zh_Hans: 在此输入您的 API Key+ en_US: Enter your API Keydiff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/Qwen2-72B-Instruct.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/Qwen2-72B-Instruct.yamlnew file mode 100644index 00000000000..0348438a75e--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/Qwen2-72B-Instruct.yaml@@ -0,0 +1,105 @@+model: Qwen2-72B-Instruct+label:+ zh_Hans: Qwen2-72B-Instruct+ en_US: Qwen2-72B-Instruct+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 6400+parameter_rules:+ - name: stream+ use_template: boolean+ label:+ en_US: "Stream"+ zh_Hans: "流式"+ type: boolean+ default: true+ required: true+ help:+ en_US: "Whether to return the results in batches through streaming. If set to true, the generated text will be pushed to the user in real time during the generation process."+ zh_Hans: "是否通过流式分批返回结果。如果设置为 true,生成过程中实时地向用户推送每一部分生成的文本。"++ - name: max_tokens+ use_template: max_tokens+ label:+ en_US: "Max Tokens"+ zh_Hans: "最大Token数"+ type: int+ default: 512+ min: 1+ required: true+ help:+ en_US: "The maximum number of tokens that can be generated by the model varies depending on the model."+ zh_Hans: "模型可生成的最大 token 个数,不同模型上限不同。"++ - name: temperature+ use_template: temperature+ label:+ en_US: "Temperature"+ zh_Hans: "采样温度"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The randomness of the sampling temperature control output. The temperature value is within the range of [0.0, 1.0]. The higher the value, the more random and creative the output; the lower the value, the more stable it is. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样温度控制输出的随机性。温度值在 [0.0, 1.0] 范围内,值越高,输出越随机和创造性;值越低,输出越稳定。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_p+ use_template: top_p+ label:+ en_US: "Top P"+ zh_Hans: "Top P"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The value range of the sampling method is [0.0, 1.0]. The top_p value determines that the model selects tokens from the top p% of candidate words with the highest probability; when top_p is 0, this parameter is invalid. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样方法的取值范围为 [0.0,1.0]。top_p 值确定模型从概率最高的前p%的候选词中选取 tokens;当 top_p 为 0 时,此参数无效。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_k+ use_template: top_k+ label:+ en_US: "Top K"+ zh_Hans: "Top K"+ type: int+ default: 50+ min: 0+ max: 100+ required: true+ help:+ en_US: "The value range is [0,100], which limits the model to only select from the top k words with the highest probability when choosing the next word at each step. The larger the value, the more diverse text generation will be."+ zh_Hans: "取值范围为 [0,100],限制模型在每一步选择下一个词时,只从概率最高的前 k 个词中选取。数值越大,文本生成越多样。"++ - name: frequency_penalty+ use_template: frequency_penalty+ label:+ en_US: "Frequency Penalty"+ zh_Hans: "频率惩罚"+ type: float+ default: 0+ min: -1.0+ max: 1.0+ precision: 1+ required: false+ help:+ en_US: "Used to adjust the frequency of repeated content in automatically generated text. Positive numbers reduce repetition, while negative numbers increase repetition. After setting this parameter, if a word has already appeared in the text, the model will decrease the probability of choosing that word for subsequent generation."+ zh_Hans: "用于调整自动生成文本中重复内容的频率。正数减少重复,负数增加重复。设置此参数后,如果一个词在文本中已经出现过,模型在后续生成中选择该词的概率会降低。"++ - name: user+ use_template: text+ label:+ en_US: "User"+ zh_Hans: "用户"+ type: string+ required: false+ help:+ en_US: "Used to track and differentiate conversation requests from different users."+ zh_Hans: "用于追踪和区分不同用户的对话请求。"diff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/Qwen2-7B-Instruct.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/Qwen2-7B-Instruct.yamlnew file mode 100644index 00000000000..ba1ad788f50--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/Qwen2-7B-Instruct.yaml@@ -0,0 +1,105 @@+model: Qwen2-7B-Instruct+label:+ zh_Hans: Qwen2-7B-Instruct+ en_US: Qwen2-7B-Instruct+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 32768+parameter_rules:+ - name: stream+ use_template: boolean+ label:+ en_US: "Stream"+ zh_Hans: "流式"+ type: boolean+ default: true+ required: true+ help:+ en_US: "Whether to return the results in batches through streaming. If set to true, the generated text will be pushed to the user in real time during the generation process."+ zh_Hans: "是否通过流式分批返回结果。如果设置为 true,生成过程中实时地向用户推送每一部分生成的文本。"++ - name: max_tokens+ use_template: max_tokens+ label:+ en_US: "Max Tokens"+ zh_Hans: "最大Token数"+ type: int+ default: 512+ min: 1+ required: true+ help:+ en_US: "The maximum number of tokens that can be generated by the model varies depending on the model."+ zh_Hans: "模型可生成的最大 token 个数,不同模型上限不同。"++ - name: temperature+ use_template: temperature+ label:+ en_US: "Temperature"+ zh_Hans: "采样温度"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The randomness of the sampling temperature control output. The temperature value is within the range of [0.0, 1.0]. The higher the value, the more random and creative the output; the lower the value, the more stable it is. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样温度控制输出的随机性。温度值在 [0.0, 1.0] 范围内,值越高,输出越随机和创造性;值越低,输出越稳定。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_p+ use_template: top_p+ label:+ en_US: "Top P"+ zh_Hans: "Top P"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The value range of the sampling method is [0.0, 1.0]. The top_p value determines that the model selects tokens from the top p% of candidate words with the highest probability; when top_p is 0, this parameter is invalid. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样方法的取值范围为 [0.0,1.0]。top_p 值确定模型从概率最高的前p%的候选词中选取 tokens;当 top_p 为 0 时,此参数无效。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_k+ use_template: top_k+ label:+ en_US: "Top K"+ zh_Hans: "Top K"+ type: int+ default: 50+ min: 0+ max: 100+ required: true+ help:+ en_US: "The value range is [0,100], which limits the model to only select from the top k words with the highest probability when choosing the next word at each step. The larger the value, the more diverse text generation will be."+ zh_Hans: "取值范围为 [0,100],限制模型在每一步选择下一个词时,只从概率最高的前 k 个词中选取。数值越大,文本生成越多样。"++ - name: frequency_penalty+ use_template: frequency_penalty+ label:+ en_US: "Frequency Penalty"+ zh_Hans: "频率惩罚"+ type: float+ default: 0+ min: -1.0+ max: 1.0+ precision: 1+ required: false+ help:+ en_US: "Used to adjust the frequency of repeated content in automatically generated text. Positive numbers reduce repetition, while negative numbers increase repetition. After setting this parameter, if a word has already appeared in the text, the model will decrease the probability of choosing that word for subsequent generation."+ zh_Hans: "用于调整自动生成文本中重复内容的频率。正数减少重复,负数增加重复。设置此参数后,如果一个词在文本中已经出现过,模型在后续生成中选择该词的概率会降低。"++ - name: user+ use_template: text+ label:+ en_US: "User"+ zh_Hans: "用户"+ type: string+ required: false+ help:+ en_US: "Used to track and differentiate conversation requests from different users."+ zh_Hans: "用于追踪和区分不同用户的对话请求。"diff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/Yi-1.5-34B-Chat.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/Yi-1.5-34B-Chat.yamlnew file mode 100644index 00000000000..f7260c987b3--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/Yi-1.5-34B-Chat.yaml@@ -0,0 +1,105 @@+model: Yi-1.5-34B-Chat+label:+ zh_Hans: Yi-1.5-34B-Chat+ en_US: Yi-1.5-34B-Chat+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 4096+parameter_rules:+ - name: stream+ use_template: boolean+ label:+ en_US: "Stream"+ zh_Hans: "流式"+ type: boolean+ default: true+ required: true+ help:+ en_US: "Whether to return the results in batches through streaming. If set to true, the generated text will be pushed to the user in real time during the generation process."+ zh_Hans: "是否通过流式分批返回结果。如果设置为 true,生成过程中实时地向用户推送每一部分生成的文本。"++ - name: max_tokens+ use_template: max_tokens+ label:+ en_US: "Max Tokens"+ zh_Hans: "最大Token数"+ type: int+ default: 512+ min: 1+ required: true+ help:+ en_US: "The maximum number of tokens that can be generated by the model varies depending on the model."+ zh_Hans: "模型可生成的最大 token 个数,不同模型上限不同。"++ - name: temperature+ use_template: temperature+ label:+ en_US: "Temperature"+ zh_Hans: "采样温度"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The randomness of the sampling temperature control output. The temperature value is within the range of [0.0, 1.0]. The higher the value, the more random and creative the output; the lower the value, the more stable it is. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样温度控制输出的随机性。温度值在 [0.0, 1.0] 范围内,值越高,输出越随机和创造性;值越低,输出越稳定。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_p+ use_template: top_p+ label:+ en_US: "Top P"+ zh_Hans: "Top P"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The value range of the sampling method is [0.0, 1.0]. The top_p value determines that the model selects tokens from the top p% of candidate words with the highest probability; when top_p is 0, this parameter is invalid. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样方法的取值范围为 [0.0,1.0]。top_p 值确定模型从概率最高的前p%的候选词中选取 tokens;当 top_p 为 0 时,此参数无效。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_k+ use_template: top_k+ label:+ en_US: "Top K"+ zh_Hans: "Top K"+ type: int+ default: 50+ min: 0+ max: 100+ required: true+ help:+ en_US: "The value range is [0,100], which limits the model to only select from the top k words with the highest probability when choosing the next word at each step. The larger the value, the more diverse text generation will be."+ zh_Hans: "取值范围为 [0,100],限制模型在每一步选择下一个词时,只从概率最高的前 k 个词中选取。数值越大,文本生成越多样。"++ - name: frequency_penalty+ use_template: frequency_penalty+ label:+ en_US: "Frequency Penalty"+ zh_Hans: "频率惩罚"+ type: float+ default: 0+ min: -1.0+ max: 1.0+ precision: 1+ required: false+ help:+ en_US: "Used to adjust the frequency of repeated content in automatically generated text. Positive numbers reduce repetition, while negative numbers increase repetition. After setting this parameter, if a word has already appeared in the text, the model will decrease the probability of choosing that word for subsequent generation."+ zh_Hans: "用于调整自动生成文本中重复内容的频率。正数减少重复,负数增加重复。设置此参数后,如果一个词在文本中已经出现过,模型在后续生成中选择该词的概率会降低。"++ - name: user+ use_template: text+ label:+ en_US: "User"+ zh_Hans: "用户"+ type: string+ required: false+ help:+ en_US: "Used to track and differentiate conversation requests from different users."+ zh_Hans: "用于追踪和区分不同用户的对话请求。"diff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/_position.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/_position.yamlnew file mode 100644index 00000000000..21f6120742b--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/_position.yaml@@ -0,0 +1,7 @@+- Qwen2-7B-Instruct+- Qwen2-72B-Instruct+- Yi-1.5-34B-Chat+- glm-4-9b-chat+- deepseek-coder-33B-instruct-chat+- deepseek-coder-33B-instruct-completions+- codegeex4-all-9bdiff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/codegeex4-all-9b.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/codegeex4-all-9b.yamlnew file mode 100644index 00000000000..8632cd92aba--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/codegeex4-all-9b.yaml@@ -0,0 +1,105 @@+model: codegeex4-all-9b+label:+ zh_Hans: codegeex4-all-9b+ en_US: codegeex4-all-9b+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 40960+parameter_rules:+ - name: stream+ use_template: boolean+ label:+ en_US: "Stream"+ zh_Hans: "流式"+ type: boolean+ default: true+ required: true+ help:+ en_US: "Whether to return the results in batches through streaming. If set to true, the generated text will be pushed to the user in real time during the generation process."+ zh_Hans: "是否通过流式分批返回结果。如果设置为 true,生成过程中实时地向用户推送每一部分生成的文本。"++ - name: max_tokens+ use_template: max_tokens+ label:+ en_US: "Max Tokens"+ zh_Hans: "最大Token数"+ type: int+ default: 512+ min: 1+ required: true+ help:+ en_US: "The maximum number of tokens that can be generated by the model varies depending on the model."+ zh_Hans: "模型可生成的最大 token 个数,不同模型上限不同。"++ - name: temperature+ use_template: temperature+ label:+ en_US: "Temperature"+ zh_Hans: "采样温度"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The randomness of the sampling temperature control output. The temperature value is within the range of [0.0, 1.0]. The higher the value, the more random and creative the output; the lower the value, the more stable it is. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样温度控制输出的随机性。温度值在 [0.0, 1.0] 范围内,值越高,输出越随机和创造性;值越低,输出越稳定。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_p+ use_template: top_p+ label:+ en_US: "Top P"+ zh_Hans: "Top P"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The value range of the sampling method is [0.0, 1.0]. The top_p value determines that the model selects tokens from the top p% of candidate words with the highest probability; when top_p is 0, this parameter is invalid. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样方法的取值范围为 [0.0,1.0]。top_p 值确定模型从概率最高的前p%的候选词中选取 tokens;当 top_p 为 0 时,此参数无效。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_k+ use_template: top_k+ label:+ en_US: "Top K"+ zh_Hans: "Top K"+ type: int+ default: 50+ min: 0+ max: 100+ required: true+ help:+ en_US: "The value range is [0,100], which limits the model to only select from the top k words with the highest probability when choosing the next word at each step. The larger the value, the more diverse text generation will be."+ zh_Hans: "取值范围为 [0,100],限制模型在每一步选择下一个词时,只从概率最高的前 k 个词中选取。数值越大,文本生成越多样。"++ - name: frequency_penalty+ use_template: frequency_penalty+ label:+ en_US: "Frequency Penalty"+ zh_Hans: "频率惩罚"+ type: float+ default: 0+ min: -1.0+ max: 1.0+ precision: 1+ required: false+ help:+ en_US: "Used to adjust the frequency of repeated content in automatically generated text. Positive numbers reduce repetition, while negative numbers increase repetition. After setting this parameter, if a word has already appeared in the text, the model will decrease the probability of choosing that word for subsequent generation."+ zh_Hans: "用于调整自动生成文本中重复内容的频率。正数减少重复,负数增加重复。设置此参数后,如果一个词在文本中已经出现过,模型在后续生成中选择该词的概率会降低。"++ - name: user+ use_template: text+ label:+ en_US: "User"+ zh_Hans: "用户"+ type: string+ required: false+ help:+ en_US: "Used to track and differentiate conversation requests from different users."+ zh_Hans: "用于追踪和区分不同用户的对话请求。"diff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/deepseek-coder-33B-instruct-chat.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/deepseek-coder-33B-instruct-chat.yamlnew file mode 100644index 00000000000..2ac00761d50--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/deepseek-coder-33B-instruct-chat.yaml@@ -0,0 +1,105 @@+model: deepseek-coder-33B-instruct-chat+label:+ zh_Hans: deepseek-coder-33B-instruct-chat+ en_US: deepseek-coder-33B-instruct-chat+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 9000+parameter_rules:+ - name: stream+ use_template: boolean+ label:+ en_US: "Stream"+ zh_Hans: "流式"+ type: boolean+ default: true+ required: true+ help:+ en_US: "Whether to return the results in batches through streaming. If set to true, the generated text will be pushed to the user in real time during the generation process."+ zh_Hans: "是否通过流式分批返回结果。如果设置为 true,生成过程中实时地向用户推送每一部分生成的文本。"++ - name: max_tokens+ use_template: max_tokens+ label:+ en_US: "Max Tokens"+ zh_Hans: "最大Token数"+ type: int+ default: 512+ min: 1+ required: true+ help:+ en_US: "The maximum number of tokens that can be generated by the model varies depending on the model."+ zh_Hans: "模型可生成的最大 token 个数,不同模型上限不同。"++ - name: temperature+ use_template: temperature+ label:+ en_US: "Temperature"+ zh_Hans: "采样温度"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The randomness of the sampling temperature control output. The temperature value is within the range of [0.0, 1.0]. The higher the value, the more random and creative the output; the lower the value, the more stable it is. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样温度控制输出的随机性。温度值在 [0.0, 1.0] 范围内,值越高,输出越随机和创造性;值越低,输出越稳定。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_p+ use_template: top_p+ label:+ en_US: "Top P"+ zh_Hans: "Top P"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The value range of the sampling method is [0.0, 1.0]. The top_p value determines that the model selects tokens from the top p% of candidate words with the highest probability; when top_p is 0, this parameter is invalid. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样方法的取值范围为 [0.0,1.0]。top_p 值确定模型从概率最高的前p%的候选词中选取 tokens;当 top_p 为 0 时,此参数无效。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_k+ use_template: top_k+ label:+ en_US: "Top K"+ zh_Hans: "Top K"+ type: int+ default: 50+ min: 0+ max: 100+ required: true+ help:+ en_US: "The value range is [0,100], which limits the model to only select from the top k words with the highest probability when choosing the next word at each step. The larger the value, the more diverse text generation will be."+ zh_Hans: "取值范围为 [0,100],限制模型在每一步选择下一个词时,只从概率最高的前 k 个词中选取。数值越大,文本生成越多样。"++ - name: frequency_penalty+ use_template: frequency_penalty+ label:+ en_US: "Frequency Penalty"+ zh_Hans: "频率惩罚"+ type: float+ default: 0+ min: -1.0+ max: 1.0+ precision: 1+ required: false+ help:+ en_US: "Used to adjust the frequency of repeated content in automatically generated text. Positive numbers reduce repetition, while negative numbers increase repetition. After setting this parameter, if a word has already appeared in the text, the model will decrease the probability of choosing that word for subsequent generation."+ zh_Hans: "用于调整自动生成文本中重复内容的频率。正数减少重复,负数增加重复。设置此参数后,如果一个词在文本中已经出现过,模型在后续生成中选择该词的概率会降低。"++ - name: user+ use_template: text+ label:+ en_US: "User"+ zh_Hans: "用户"+ type: string+ required: false+ help:+ en_US: "Used to track and differentiate conversation requests from different users."+ zh_Hans: "用于追踪和区分不同用户的对话请求。"diff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/deepseek-coder-33B-instruct-completions.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/deepseek-coder-33B-instruct-completions.yamlnew file mode 100644index 00000000000..7c364d89f7c--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/deepseek-coder-33B-instruct-completions.yaml@@ -0,0 +1,91 @@+model: deepseek-coder-33B-instruct-completions+label:+ zh_Hans: deepseek-coder-33B-instruct-completions+ en_US: deepseek-coder-33B-instruct-completions+model_type: llm+features:+ - agent-thought+model_properties:+ mode: completion+ context_size: 9000+parameter_rules:+ - name: stream+ use_template: boolean+ label:+ en_US: "Stream"+ zh_Hans: "流式"+ type: boolean+ default: true+ required: true+ help:+ en_US: "Whether to return the results in batches through streaming. If set to true, the generated text will be pushed to the user in real time during the generation process."+ zh_Hans: "是否通过流式分批返回结果。如果设置为 true,生成过程中实时地向用户推送每一部分生成的文本。"++ - name: max_tokens+ use_template: max_tokens+ label:+ en_US: "Max Tokens"+ zh_Hans: "最大Token数"+ type: int+ default: 512+ min: 1+ required: true+ help:+ en_US: "The maximum number of tokens that can be generated by the model varies depending on the model."+ zh_Hans: "模型可生成的最大 token 个数,不同模型上限不同。"++ - name: temperature+ use_template: temperature+ label:+ en_US: "Temperature"+ zh_Hans: "采样温度"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The randomness of the sampling temperature control output. The temperature value is within the range of [0.0, 1.0]. The higher the value, the more random and creative the output; the lower the value, the more stable it is. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样温度控制输出的随机性。温度值在 [0.0, 1.0] 范围内,值越高,输出越随机和创造性;值越低,输出越稳定。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_p+ use_template: top_p+ label:+ en_US: "Top P"+ zh_Hans: "Top P"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The value range of the sampling method is [0.0, 1.0]. The top_p value determines that the model selects tokens from the top p% of candidate words with the highest probability; when top_p is 0, this parameter is invalid. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样方法的取值范围为 [0.0,1.0]。top_p 值确定模型从概率最高的前p%的候选词中选取 tokens;当 top_p 为 0 时,此参数无效。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: frequency_penalty+ use_template: frequency_penalty+ label:+ en_US: "Frequency Penalty"+ zh_Hans: "频率惩罚"+ type: float+ default: 0+ min: -1.0+ max: 1.0+ precision: 1+ required: false+ help:+ en_US: "Used to adjust the frequency of repeated content in automatically generated text. Positive numbers reduce repetition, while negative numbers increase repetition. After setting this parameter, if a word has already appeared in the text, the model will decrease the probability of choosing that word for subsequent generation."+ zh_Hans: "用于调整自动生成文本中重复内容的频率。正数减少重复,负数增加重复。设置此参数后,如果一个词在文本中已经出现过,模型在后续生成中选择该词的概率会降低。"++ - name: user+ use_template: text+ label:+ en_US: "User"+ zh_Hans: "用户"+ type: string+ required: false+ help:+ en_US: "Used to track and differentiate conversation requests from different users."+ zh_Hans: "用于追踪和区分不同用户的对话请求。"diff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/glm-4-9b-chat.yaml b/api/core/model_runtime/model_providers/gitee_ai/llm/glm-4-9b-chat.yamlnew file mode 100644index 00000000000..2afe1cf959f--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/glm-4-9b-chat.yaml@@ -0,0 +1,105 @@+model: glm-4-9b-chat+label:+ zh_Hans: glm-4-9b-chat+ en_US: glm-4-9b-chat+model_type: llm+features:+ - agent-thought+model_properties:+ mode: chat+ context_size: 32768+parameter_rules:+ - name: stream+ use_template: boolean+ label:+ en_US: "Stream"+ zh_Hans: "流式"+ type: boolean+ default: true+ required: true+ help:+ en_US: "Whether to return the results in batches through streaming. If set to true, the generated text will be pushed to the user in real time during the generation process."+ zh_Hans: "是否通过流式分批返回结果。如果设置为 true,生成过程中实时地向用户推送每一部分生成的文本。"++ - name: max_tokens+ use_template: max_tokens+ label:+ en_US: "Max Tokens"+ zh_Hans: "最大Token数"+ type: int+ default: 512+ min: 1+ required: true+ help:+ en_US: "The maximum number of tokens that can be generated by the model varies depending on the model."+ zh_Hans: "模型可生成的最大 token 个数,不同模型上限不同。"++ - name: temperature+ use_template: temperature+ label:+ en_US: "Temperature"+ zh_Hans: "采样温度"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The randomness of the sampling temperature control output. The temperature value is within the range of [0.0, 1.0]. The higher the value, the more random and creative the output; the lower the value, the more stable it is. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样温度控制输出的随机性。温度值在 [0.0, 1.0] 范围内,值越高,输出越随机和创造性;值越低,输出越稳定。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_p+ use_template: top_p+ label:+ en_US: "Top P"+ zh_Hans: "Top P"+ type: float+ default: 0.7+ min: 0.0+ max: 1.0+ precision: 1+ required: true+ help:+ en_US: "The value range of the sampling method is [0.0, 1.0]. The top_p value determines that the model selects tokens from the top p% of candidate words with the highest probability; when top_p is 0, this parameter is invalid. It is recommended to adjust either top_p or temperature parameters according to your needs to avoid adjusting both at the same time."+ zh_Hans: "采样方法的取值范围为 [0.0,1.0]。top_p 值确定模型从概率最高的前p%的候选词中选取 tokens;当 top_p 为 0 时,此参数无效。建议根据需求调整 top_p 或 temperature 参数,避免同时调整两者。"++ - name: top_k+ use_template: top_k+ label:+ en_US: "Top K"+ zh_Hans: "Top K"+ type: int+ default: 50+ min: 0+ max: 100+ required: true+ help:+ en_US: "The value range is [0,100], which limits the model to only select from the top k words with the highest probability when choosing the next word at each step. The larger the value, the more diverse text generation will be."+ zh_Hans: "取值范围为 [0,100],限制模型在每一步选择下一个词时,只从概率最高的前 k 个词中选取。数值越大,文本生成越多样。"++ - name: frequency_penalty+ use_template: frequency_penalty+ label:+ en_US: "Frequency Penalty"+ zh_Hans: "频率惩罚"+ type: float+ default: 0+ min: -1.0+ max: 1.0+ precision: 1+ required: false+ help:+ en_US: "Used to adjust the frequency of repeated content in automatically generated text. Positive numbers reduce repetition, while negative numbers increase repetition. After setting this parameter, if a word has already appeared in the text, the model will decrease the probability of choosing that word for subsequent generation."+ zh_Hans: "用于调整自动生成文本中重复内容的频率。正数减少重复,负数增加重复。设置此参数后,如果一个词在文本中已经出现过,模型在后续生成中选择该词的概率会降低。"++ - name: user+ use_template: text+ label:+ en_US: "User"+ zh_Hans: "用户"+ type: string+ required: false+ help:+ en_US: "Used to track and differentiate conversation requests from different users."+ zh_Hans: "用于追踪和区分不同用户的对话请求。"diff --git a/api/core/model_runtime/model_providers/gitee_ai/llm/llm.py b/api/core/model_runtime/model_providers/gitee_ai/llm/llm.pynew file mode 100644index 00000000000..b65db6f6658--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/llm/llm.py@@ -0,0 +1,47 @@+from collections.abc import Generator+from typing import Optional, Union++from core.model_runtime.entities.llm_entities import LLMMode, LLMResult+from core.model_runtime.entities.message_entities import (+ PromptMessage,+ PromptMessageTool,+)+from core.model_runtime.model_providers.openai_api_compatible.llm.llm import OAIAPICompatLargeLanguageModel+++class GiteeAILargeLanguageModel(OAIAPICompatLargeLanguageModel):+ MODEL_TO_IDENTITY: dict[str, str] = {+ "Yi-1.5-34B-Chat": "Yi-34B-Chat",+ "deepseek-coder-33B-instruct-completions": "deepseek-coder-33B-instruct",+ "deepseek-coder-33B-instruct-chat": "deepseek-coder-33B-instruct",+ }++ def _invoke(+ self,+ model: str,+ credentials: dict,+ prompt_messages: list[PromptMessage],+ model_parameters: dict,+ tools: Optional[list[PromptMessageTool]] = None,+ stop: Optional[list[str]] = None,+ stream: bool = True,+ user: Optional[str] = None,+ ) -> Union[LLMResult, Generator]:+ self._add_custom_parameters(credentials, model, model_parameters)+ return super()._invoke(model, credentials, prompt_messages, model_parameters, tools, stop, stream)++ def validate_credentials(self, model: str, credentials: dict) -> None:+ self._add_custom_parameters(credentials, model, None)+ super().validate_credentials(model, credentials)++ @staticmethod+ def _add_custom_parameters(credentials: dict, model: str, model_parameters: dict) -> None:+ if model is None:+ model = "bge-large-zh-v1.5"++ model_identity = GiteeAILargeLanguageModel.MODEL_TO_IDENTITY.get(model, model)+ credentials["endpoint_url"] = f"https://ai.gitee.com/api/serverless/{model_identity}/"+ if model.endswith("completions"):+ credentials["mode"] = LLMMode.COMPLETION.value+ else:+ credentials["mode"] = LLMMode.CHAT.valuediff --git a/api/core/model_runtime/model_providers/gitee_ai/rerank/__init__.py b/api/core/model_runtime/model_providers/gitee_ai/rerank/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/api/core/model_runtime/model_providers/gitee_ai/rerank/_position.yaml b/api/core/model_runtime/model_providers/gitee_ai/rerank/_position.yamlnew file mode 100644index 00000000000..83162fd338d--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/rerank/_position.yaml@@ -0,0 +1 @@+- bge-reranker-v2-m3diff --git a/api/core/model_runtime/model_providers/gitee_ai/rerank/bge-reranker-v2-m3.yaml b/api/core/model_runtime/model_providers/gitee_ai/rerank/bge-reranker-v2-m3.yamlnew file mode 100644index 00000000000..f0681641e12--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/rerank/bge-reranker-v2-m3.yaml@@ -0,0 +1,4 @@+model: bge-reranker-v2-m3+model_type: rerank+model_properties:+ context_size: 1024diff --git a/api/core/model_runtime/model_providers/gitee_ai/rerank/rerank.py b/api/core/model_runtime/model_providers/gitee_ai/rerank/rerank.pynew file mode 100644index 00000000000..231345c2f4e--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/rerank/rerank.py@@ -0,0 +1,128 @@+from typing import Optional++import httpx++from core.model_runtime.entities.common_entities import I18nObject+from core.model_runtime.entities.model_entities import AIModelEntity, FetchFrom, ModelPropertyKey, ModelType+from core.model_runtime.entities.rerank_entities import RerankDocument, RerankResult+from core.model_runtime.errors.invoke import (+ InvokeAuthorizationError,+ InvokeBadRequestError,+ InvokeConnectionError,+ InvokeError,+ InvokeRateLimitError,+ InvokeServerUnavailableError,+)+from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.__base.rerank_model import RerankModel+++class GiteeAIRerankModel(RerankModel):+ """+ Model class for rerank model.+ """++ def _invoke(+ self,+ model: str,+ credentials: dict,+ query: str,+ docs: list[str],+ score_threshold: Optional[float] = None,+ top_n: Optional[int] = None,+ user: Optional[str] = None,+ ) -> RerankResult:+ """+ Invoke rerank model++ :param model: model name+ :param credentials: model credentials+ :param query: search query+ :param docs: docs for reranking+ :param score_threshold: score threshold+ :param top_n: top n documents to return+ :param user: unique user id+ :return: rerank result+ """+ if len(docs) == 0:+ return RerankResult(model=model, docs=[])++ base_url = credentials.get("base_url", "https://ai.gitee.com/api/serverless")+ base_url = base_url.removesuffix("/")++ try:+ body = {"model": model, "query": query, "documents": docs}+ if top_n is not None:+ body["top_n"] = top_n+ response = httpx.post(+ f"{base_url}/{model}/rerank",+ json=body,+ headers={"Authorization": f"Bearer {credentials.get('api_key')}"},+ )++ response.raise_for_status()+ results = response.json()++ rerank_documents = []+ for result in results["results"]:+ rerank_document = RerankDocument(+ index=result["index"],+ text=result["document"]["text"],+ score=result["relevance_score"],+ )+ if score_threshold is None or result["relevance_score"] >= score_threshold:+ rerank_documents.append(rerank_document)+ return RerankResult(model=model, docs=rerank_documents)+ except httpx.HTTPStatusError as e:+ raise InvokeServerUnavailableError(str(e))++ def validate_credentials(self, model: str, credentials: dict) -> None:+ """+ Validate model credentials++ :param model: model name+ :param credentials: model credentials+ :return:+ """+ try:+ self._invoke(+ model=model,+ credentials=credentials,+ query="What is the capital of the United States?",+ docs=[+ "Carson City is the capital city of the American state of Nevada. At the 2010 United States "+ "Census, Carson City had a population of 55,274.",+ "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean that "+ "are a political division controlled by the United States. Its capital is Saipan.",+ ],+ score_threshold=0.01,+ )+ except Exception as ex:+ raise CredentialsValidateFailedError(str(ex))++ @property+ def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:+ """+ Map model invoke error to unified error+ """+ return {+ InvokeConnectionError: [httpx.ConnectError],+ InvokeServerUnavailableError: [httpx.RemoteProtocolError],+ InvokeRateLimitError: [],+ InvokeAuthorizationError: [httpx.HTTPStatusError],+ InvokeBadRequestError: [httpx.RequestError],+ }++ def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity:+ """+ generate custom model entities from credentials+ """+ entity = AIModelEntity(+ model=model,+ label=I18nObject(en_US=model),+ model_type=ModelType.RERANK,+ fetch_from=FetchFrom.CUSTOMIZABLE_MODEL,+ model_properties={ModelPropertyKey.CONTEXT_SIZE: int(credentials.get("context_size"))},+ )++ return entitydiff --git a/api/core/model_runtime/model_providers/gitee_ai/speech2text/__init__.py b/api/core/model_runtime/model_providers/gitee_ai/speech2text/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/api/core/model_runtime/model_providers/gitee_ai/speech2text/_position.yaml b/api/core/model_runtime/model_providers/gitee_ai/speech2text/_position.yamlnew file mode 100644index 00000000000..8e9b47598bd--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/speech2text/_position.yaml@@ -0,0 +1,2 @@+- whisper-base+- whisper-largediff --git a/api/core/model_runtime/model_providers/gitee_ai/speech2text/speech2text.py b/api/core/model_runtime/model_providers/gitee_ai/speech2text/speech2text.pynew file mode 100644index 00000000000..5597f5b43e5--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/speech2text/speech2text.py@@ -0,0 +1,53 @@+import os+from typing import IO, Optional++import requests++from core.model_runtime.errors.invoke import InvokeBadRequestError+from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.__base.speech2text_model import Speech2TextModel+from core.model_runtime.model_providers.gitee_ai._common import _CommonGiteeAI+++class GiteeAISpeech2TextModel(_CommonGiteeAI, Speech2TextModel):+ """+ Model class for OpenAI Compatible Speech to text model.+ """++ def _invoke(self, model: str, credentials: dict, file: IO[bytes], user: Optional[str] = None) -> str:+ """+ Invoke speech2text model++ :param model: model name+ :param credentials: model credentials+ :param file: audio file+ :param user: unique user id+ :return: text for given audio file+ """+ # doc: https://ai.gitee.com/docs/openapi/serverless#tag/serverless/POST/{service}/speech-to-text++ endpoint_url = f"https://ai.gitee.com/api/serverless/{model}/speech-to-text"+ files = [("file", file)]+ _, file_ext = os.path.splitext(file.name)+ headers = {"Content-Type": f"audio/{file_ext}", "Authorization": f"Bearer {credentials.get('api_key')}"}+ response = requests.post(endpoint_url, headers=headers, files=files)+ if response.status_code != 200:+ raise InvokeBadRequestError(response.text)+ response_data = response.json()+ return response_data["text"]++ def validate_credentials(self, model: str, credentials: dict) -> None:+ """+ Validate model credentials++ :param model: model name+ :param credentials: model credentials+ :return:+ """+ try:+ audio_file_path = self._get_demo_file_path()++ with open(audio_file_path, "rb") as audio_file:+ self._invoke(model, credentials, audio_file)+ except Exception as ex:+ raise CredentialsValidateFailedError(str(ex))diff --git a/api/core/model_runtime/model_providers/gitee_ai/speech2text/whisper-base.yaml b/api/core/model_runtime/model_providers/gitee_ai/speech2text/whisper-base.yamlnew file mode 100644index 00000000000..a50bf5fc2d6--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/speech2text/whisper-base.yaml@@ -0,0 +1,5 @@+model: whisper-base+model_type: speech2text+model_properties:+ file_upload_limit: 1+ supported_file_extensions: flac,mp3,mp4,mpeg,mpga,m4a,ogg,wav,webmdiff --git a/api/core/model_runtime/model_providers/gitee_ai/speech2text/whisper-large.yaml b/api/core/model_runtime/model_providers/gitee_ai/speech2text/whisper-large.yamlnew file mode 100644index 00000000000..1be7b1a3919--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/speech2text/whisper-large.yaml@@ -0,0 +1,5 @@+model: whisper-large+model_type: speech2text+model_properties:+ file_upload_limit: 1+ supported_file_extensions: flac,mp3,mp4,mpeg,mpga,m4a,ogg,wav,webmdiff --git a/api/core/model_runtime/model_providers/gitee_ai/text_embedding/_position.yaml b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/_position.yamlnew file mode 100644index 00000000000..e8abe6440de--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/_position.yaml@@ -0,0 +1,3 @@+- bge-large-zh-v1.5+- bge-small-zh-v1.5+- bge-m3diff --git a/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-large-zh-v1.5.yaml b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-large-zh-v1.5.yamlnew file mode 100644index 00000000000..9e3ca76e882--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-large-zh-v1.5.yaml@@ -0,0 +1,8 @@+model: bge-large-zh-v1.5+label:+ zh_Hans: bge-large-zh-v1.5+ en_US: bge-large-zh-v1.5+model_type: text-embedding+model_properties:+ context_size: 200000+ max_chunks: 20diff --git a/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-m3.yaml b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-m3.yamlnew file mode 100644index 00000000000..a7a99a98a3e--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-m3.yaml@@ -0,0 +1,8 @@+model: bge-m3+label:+ zh_Hans: bge-m3+ en_US: bge-m3+model_type: text-embedding+model_properties:+ context_size: 200000+ max_chunks: 20diff --git a/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-small-zh-v1.5.yaml b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-small-zh-v1.5.yamlnew file mode 100644index 00000000000..bd760408fa6--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/bge-small-zh-v1.5.yaml@@ -0,0 +1,8 @@+model: bge-small-zh-v1.5+label:+ zh_Hans: bge-small-zh-v1.5+ en_US: bge-small-zh-v1.5+model_type: text-embedding+model_properties:+ context_size: 200000+ max_chunks: 20diff --git a/api/core/model_runtime/model_providers/gitee_ai/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/text_embedding.pynew file mode 100644index 00000000000..b833c5652c6--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/text_embedding/text_embedding.py@@ -0,0 +1,31 @@+from typing import Optional++from core.entities.embedding_type import EmbeddingInputType+from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult+from core.model_runtime.model_providers.openai_api_compatible.text_embedding.text_embedding import (+ OAICompatEmbeddingModel,+)+++class GiteeAIEmbeddingModel(OAICompatEmbeddingModel):+ def _invoke(+ self,+ model: str,+ credentials: dict,+ texts: list[str],+ user: Optional[str] = None,+ input_type: EmbeddingInputType = EmbeddingInputType.DOCUMENT,+ ) -> TextEmbeddingResult:+ self._add_custom_parameters(credentials, model)+ return super()._invoke(model, credentials, texts, user, input_type)++ def validate_credentials(self, model: str, credentials: dict) -> None:+ self._add_custom_parameters(credentials, None)+ super().validate_credentials(model, credentials)++ @staticmethod+ def _add_custom_parameters(credentials: dict, model: str) -> None:+ if model is None:+ model = "bge-m3"++ credentials["endpoint_url"] = f"https://ai.gitee.com/api/serverless/{model}/v1/"diff --git a/api/core/model_runtime/model_providers/gitee_ai/tts/ChatTTS.yaml b/api/core/model_runtime/model_providers/gitee_ai/tts/ChatTTS.yamlnew file mode 100644index 00000000000..940391dfab0--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/tts/ChatTTS.yaml@@ -0,0 +1,11 @@+model: ChatTTS+model_type: tts+model_properties:+ default_voice: 'default'+ voices:+ - mode: 'default'+ name: 'Default'+ language: [ 'zh-Hans', 'en-US', 'de-DE', 'fr-FR', 'es-ES', 'it-IT', 'th-TH', 'id-ID' ]+ word_limit: 3500+ audio_type: 'mp3'+ max_workers: 5diff --git a/api/core/model_runtime/model_providers/gitee_ai/tts/FunAudioLLM-CosyVoice-300M.yaml b/api/core/model_runtime/model_providers/gitee_ai/tts/FunAudioLLM-CosyVoice-300M.yamlnew file mode 100644index 00000000000..8fc57348015--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/tts/FunAudioLLM-CosyVoice-300M.yaml@@ -0,0 +1,11 @@+model: FunAudioLLM-CosyVoice-300M+model_type: tts+model_properties:+ default_voice: 'default'+ voices:+ - mode: 'default'+ name: 'Default'+ language: [ 'zh-Hans', 'en-US', 'de-DE', 'fr-FR', 'es-ES', 'it-IT', 'th-TH', 'id-ID' ]+ word_limit: 3500+ audio_type: 'mp3'+ max_workers: 5diff --git a/api/core/model_runtime/model_providers/gitee_ai/tts/__init__.py b/api/core/model_runtime/model_providers/gitee_ai/tts/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/api/core/model_runtime/model_providers/gitee_ai/tts/_position.yaml b/api/core/model_runtime/model_providers/gitee_ai/tts/_position.yamlnew file mode 100644index 00000000000..13c6ec84540--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/tts/_position.yaml@@ -0,0 +1,4 @@+- speecht5_tts+- ChatTTS+- fish-speech-1.2-sft+- FunAudioLLM-CosyVoice-300Mdiff --git a/api/core/model_runtime/model_providers/gitee_ai/tts/fish-speech-1.2-sft.yaml b/api/core/model_runtime/model_providers/gitee_ai/tts/fish-speech-1.2-sft.yamlnew file mode 100644index 00000000000..93cc28bc9dc--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/tts/fish-speech-1.2-sft.yaml@@ -0,0 +1,11 @@+model: fish-speech-1.2-sft+model_type: tts+model_properties:+ default_voice: 'default'+ voices:+ - mode: 'default'+ name: 'Default'+ language: [ 'zh-Hans', 'en-US', 'de-DE', 'fr-FR', 'es-ES', 'it-IT', 'th-TH', 'id-ID' ]+ word_limit: 3500+ audio_type: 'mp3'+ max_workers: 5diff --git a/api/core/model_runtime/model_providers/gitee_ai/tts/speecht5_tts.yaml b/api/core/model_runtime/model_providers/gitee_ai/tts/speecht5_tts.yamlnew file mode 100644index 00000000000..f9c843bd412--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/tts/speecht5_tts.yaml@@ -0,0 +1,11 @@+model: speecht5_tts+model_type: tts+model_properties:+ default_voice: 'default'+ voices:+ - mode: 'default'+ name: 'Default'+ language: [ 'zh-Hans', 'en-US', 'de-DE', 'fr-FR', 'es-ES', 'it-IT', 'th-TH', 'id-ID' ]+ word_limit: 3500+ audio_type: 'mp3'+ max_workers: 5diff --git a/api/core/model_runtime/model_providers/gitee_ai/tts/tts.py b/api/core/model_runtime/model_providers/gitee_ai/tts/tts.pynew file mode 100644index 00000000000..ed2bd5b13dd--- /dev/null+++ b/api/core/model_runtime/model_providers/gitee_ai/tts/tts.py@@ -0,0 +1,79 @@+from typing import Optional++import requests++from core.model_runtime.errors.invoke import InvokeBadRequestError+from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.__base.tts_model import TTSModel+from core.model_runtime.model_providers.gitee_ai._common import _CommonGiteeAI+++class GiteeAIText2SpeechModel(_CommonGiteeAI, TTSModel):+ """+ Model class for OpenAI Speech to text model.+ """++ def _invoke(+ self, model: str, tenant_id: str, credentials: dict, content_text: str, voice: str, user: Optional[str] = None+ ) -> any:+ """+ _invoke text2speech model++ :param model: model name+ :param tenant_id: user tenant id+ :param credentials: model credentials+ :param content_text: text content to be translated+ :param voice: model timbre+ :param user: unique user id+ :return: text translated to audio file+ """+ return self._tts_invoke_streaming(model=model, credentials=credentials, content_text=content_text, voice=voice)++ def validate_credentials(self, model: str, credentials: dict) -> None:+ """+ validate credentials text2speech model++ :param model: model name+ :param credentials: model credentials+ :return: text translated to audio file+ """+ try:+ self._tts_invoke_streaming(+ model=model,+ credentials=credentials,+ content_text="Hello Dify!",+ voice=self._get_model_default_voice(model, credentials),+ )+ except Exception as ex:+ raise CredentialsValidateFailedError(str(ex))++ def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> any:+ """+ _tts_invoke_streaming text2speech model+ :param model: model name+ :param credentials: model credentials+ :param content_text: text content to be translated+ :param voice: model timbre+ :return: text translated to audio file+ """+ try:+ # doc: https://ai.gitee.com/docs/openapi/serverless#tag/serverless/POST/{service}/text-to-speech+ endpoint_url = "https://ai.gitee.com/api/serverless/" + model + "/text-to-speech"++ headers = {"Content-Type": "application/json"}+ api_key = credentials.get("api_key")+ if api_key:+ headers["Authorization"] = f"Bearer {api_key}"++ payload = {"inputs": content_text}+ response = requests.post(endpoint_url, headers=headers, json=payload)++ if response.status_code != 200:+ raise InvokeBadRequestError(response.text)++ data = response.content++ for i in range(0, len(data), 1024):+ yield data[i : i + 1024]+ except Exception as ex:+ raise InvokeBadRequestError(str(ex))diff --git a/api/pytest.ini b/api/pytest.iniindex dcca08e2e5c..a23a4b3f3d8 100644--- a/api/pytest.ini+++ b/api/pytest.ini@@ -27,3 +27,4 @@ env =XINFERENCE_GENERATION_MODEL_UID = generateXINFERENCE_RERANK_MODEL_UID = rerankXINFERENCE_SERVER_URL = http://a.abc.com:11451+ GITEE_AI_API_KEY = aaaaaaaaaaaaaaaaaaaadiff --git a/api/tests/integration_tests/.env.example b/api/tests/integration_tests/.env.exampleindex 2d52399d29a..6791cd891bb 100644--- a/api/tests/integration_tests/.env.example+++ b/api/tests/integration_tests/.env.example@@ -83,3 +83,6 @@ VOLC_EMBEDDING_ENDPOINT_ID=# 360 AI CredentialsZHINAO_API_KEY=++# Gitee AI Credentials+GITEE_AI_API_KEY=diff --git a/api/tests/integration_tests/model_runtime/gitee_ai/__init__.py b/api/tests/integration_tests/model_runtime/gitee_ai/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/api/tests/integration_tests/model_runtime/gitee_ai/test_llm.py b/api/tests/integration_tests/model_runtime/gitee_ai/test_llm.pynew file mode 100644index 00000000000..753c52ce31d--- /dev/null+++ b/api/tests/integration_tests/model_runtime/gitee_ai/test_llm.py@@ -0,0 +1,132 @@+import os+from collections.abc import Generator++import pytest++from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta+from core.model_runtime.entities.message_entities import (+ AssistantPromptMessage,+ PromptMessageTool,+ SystemPromptMessage,+ UserPromptMessage,+)+from core.model_runtime.entities.model_entities import AIModelEntity+from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.gitee_ai.llm.llm import GiteeAILargeLanguageModel+++def test_predefined_models():+ model = GiteeAILargeLanguageModel()+ model_schemas = model.predefined_models()++ assert len(model_schemas) >= 1+ assert isinstance(model_schemas[0], AIModelEntity)+++def test_validate_credentials_for_chat_model():+ model = GiteeAILargeLanguageModel()++ with pytest.raises(CredentialsValidateFailedError):+ # model name to gpt-3.5-turbo because of mocking+ model.validate_credentials(model="gpt-3.5-turbo", credentials={"api_key": "invalid_key"})++ model.validate_credentials(+ model="Qwen2-7B-Instruct",+ credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")},+ )+++def test_invoke_chat_model():+ model = GiteeAILargeLanguageModel()++ result = model.invoke(+ model="Qwen2-7B-Instruct",+ credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")},+ prompt_messages=[+ SystemPromptMessage(+ content="You are a helpful AI assistant.",+ ),+ UserPromptMessage(content="Hello World!"),+ ],+ model_parameters={+ "temperature": 0.0,+ "top_p": 1.0,+ "presence_penalty": 0.0,+ "frequency_penalty": 0.0,+ "max_tokens": 10,+ "stream": False,+ },+ stop=["How"],+ stream=False,+ user="foo",+ )++ assert isinstance(result, LLMResult)+ assert len(result.message.content) > 0+++def test_invoke_stream_chat_model():+ model = GiteeAILargeLanguageModel()++ result = model.invoke(+ model="Qwen2-7B-Instruct",+ credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")},+ prompt_messages=[+ SystemPromptMessage(+ content="You are a helpful AI assistant.",+ ),+ UserPromptMessage(content="Hello World!"),+ ],+ model_parameters={"temperature": 0.0, "max_tokens": 100, "stream": False},+ stream=True,+ user="foo",+ )++ assert isinstance(result, Generator)++ for chunk in result:+ assert isinstance(chunk, LLMResultChunk)+ assert isinstance(chunk.delta, LLMResultChunkDelta)+ assert isinstance(chunk.delta.message, AssistantPromptMessage)+ assert len(chunk.delta.message.content) > 0 if chunk.delta.finish_reason is None else True+ if chunk.delta.finish_reason is not None:+ assert chunk.delta.usage is not None+++def test_get_num_tokens():+ model = GiteeAILargeLanguageModel()++ num_tokens = model.get_num_tokens(+ model="Qwen2-7B-Instruct",+ credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")},+ prompt_messages=[UserPromptMessage(content="Hello World!")],+ )++ assert num_tokens == 10++ num_tokens = model.get_num_tokens(+ model="Qwen2-7B-Instruct",+ credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")},+ prompt_messages=[+ SystemPromptMessage(+ content="You are a helpful AI assistant.",+ ),+ UserPromptMessage(content="Hello World!"),+ ],+ tools=[+ PromptMessageTool(+ name="get_weather",+ description="Determine weather in my location",+ parameters={+ "type": "object",+ "properties": {+ "location": {"type": "string", "description": "The city and state e.g. San Francisco, CA"},+ "unit": {"type": "string", "enum": ["c", "f"]},+ },+ "required": ["location"],+ },+ ),+ ],+ )++ assert num_tokens == 77diff --git a/api/tests/integration_tests/model_runtime/gitee_ai/test_provider.py b/api/tests/integration_tests/model_runtime/gitee_ai/test_provider.pynew file mode 100644index 00000000000..f12ed54a457--- /dev/null+++ b/api/tests/integration_tests/model_runtime/gitee_ai/test_provider.py@@ -0,0 +1,15 @@+import os++import pytest++from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.gitee_ai.gitee_ai import GiteeAIProvider+++def test_validate_provider_credentials():+ provider = GiteeAIProvider()++ with pytest.raises(CredentialsValidateFailedError):+ provider.validate_provider_credentials(credentials={"api_key": "invalid_key"})++ provider.validate_provider_credentials(credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")})diff --git a/api/tests/integration_tests/model_runtime/gitee_ai/test_rerank.py b/api/tests/integration_tests/model_runtime/gitee_ai/test_rerank.pynew file mode 100644index 00000000000..0e5914a61f7--- /dev/null+++ b/api/tests/integration_tests/model_runtime/gitee_ai/test_rerank.py@@ -0,0 +1,47 @@+import os++import pytest++from core.model_runtime.entities.rerank_entities import RerankResult+from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.gitee_ai.rerank.rerank import GiteeAIRerankModel+++def test_validate_credentials():+ model = GiteeAIRerankModel()++ with pytest.raises(CredentialsValidateFailedError):+ model.validate_credentials(+ model="bge-reranker-v2-m3",+ credentials={"api_key": "invalid_key"},+ )++ model.validate_credentials(+ model="bge-reranker-v2-m3",+ credentials={+ "api_key": os.environ.get("GITEE_AI_API_KEY"),+ },+ )+++def test_invoke_model():+ model = GiteeAIRerankModel()+ result = model.invoke(+ model="bge-reranker-v2-m3",+ credentials={+ "api_key": os.environ.get("GITEE_AI_API_KEY"),+ },+ query="What is the capital of the United States?",+ docs=[+ "Carson City is the capital city of the American state of Nevada. At the 2010 United States "+ "Census, Carson City had a population of 55,274.",+ "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean that "+ "are a political division controlled by the United States. Its capital is Saipan.",+ ],+ top_n=1,+ score_threshold=0.01,+ )++ assert isinstance(result, RerankResult)+ assert len(result.docs) == 1+ assert result.docs[0].score >= 0.01diff --git a/api/tests/integration_tests/model_runtime/gitee_ai/test_speech2text.py b/api/tests/integration_tests/model_runtime/gitee_ai/test_speech2text.pynew file mode 100644index 00000000000..4a01453fdd1--- /dev/null+++ b/api/tests/integration_tests/model_runtime/gitee_ai/test_speech2text.py@@ -0,0 +1,45 @@+import os++import pytest++from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.gitee_ai.speech2text.speech2text import GiteeAISpeech2TextModel+++def test_validate_credentials():+ model = GiteeAISpeech2TextModel()++ with pytest.raises(CredentialsValidateFailedError):+ model.validate_credentials(+ model="whisper-base",+ credentials={"api_key": "invalid_key"},+ )++ model.validate_credentials(+ model="whisper-base",+ credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")},+ )+++def test_invoke_model():+ model = GiteeAISpeech2TextModel()++ # Get the directory of the current file+ current_dir = os.path.dirname(os.path.abspath(__file__))++ # Get assets directory+ assets_dir = os.path.join(os.path.dirname(current_dir), "assets")++ # Construct the path to the audio file+ audio_file_path = os.path.join(assets_dir, "audio.mp3")++ # Open the file and get the file object+ with open(audio_file_path, "rb") as audio_file:+ file = audio_file++ result = model.invoke(+ model="whisper-base", credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")}, file=file+ )++ assert isinstance(result, str)+ assert result == "1 2 3 4 5 6 7 8 9 10"diff --git a/api/tests/integration_tests/model_runtime/gitee_ai/test_text_embedding.py b/api/tests/integration_tests/model_runtime/gitee_ai/test_text_embedding.pynew file mode 100644index 00000000000..34648f0bc8a--- /dev/null+++ b/api/tests/integration_tests/model_runtime/gitee_ai/test_text_embedding.py@@ -0,0 +1,46 @@+import os++import pytest++from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult+from core.model_runtime.errors.validate import CredentialsValidateFailedError+from core.model_runtime.model_providers.gitee_ai.text_embedding.text_embedding import GiteeAIEmbeddingModel+++def test_validate_credentials():+ model = GiteeAIEmbeddingModel()++ with pytest.raises(CredentialsValidateFailedError):+ model.validate_credentials(model="bge-large-zh-v1.5", credentials={"api_key": "invalid_key"})++ model.validate_credentials(model="bge-large-zh-v1.5", credentials={"api_key": os.environ.get("GITEE_AI_API_KEY")})+++def test_invoke_model():+ model = GiteeAIEmbeddingModel()++ result = model.invoke(+ model="bge-large-zh-v1.5",+ credentials={+ "api_key": os.environ.get("GITEE_AI_API_KEY"),+ },+ texts=["hello", "world"],+ user="user",+ )++ assert isinstance(result, TextEmbeddingResult)+ assert len(result.embeddings) == 2+++def test_get_num_tokens():+ model = GiteeAIEmbeddingModel()++ num_tokens = model.get_num_tokens(+ model="bge-large-zh-v1.5",+ credentials={+ "api_key": os.environ.get("GITEE_AI_API_KEY"),+ },+ texts=["hello", "world"],+ )++ assert num_tokens == 2diff --git a/api/tests/integration_tests/model_runtime/gitee_ai/test_tts.py b/api/tests/integration_tests/model_runtime/gitee_ai/test_tts.pynew file mode 100644index 00000000000..9f18161a7bb--- /dev/null+++ b/api/tests/integration_tests/model_runtime/gitee_ai/test_tts.py@@ -0,0 +1,23 @@+import os++from core.model_runtime.model_providers.gitee_ai.tts.tts import GiteeAIText2SpeechModel+++def test_invoke_model():+ model = GiteeAIText2SpeechModel()++ result = model.invoke(+ model="speecht5_tts",+ tenant_id="test",+ credentials={+ "api_key": os.environ.get("GITEE_AI_API_KEY"),+ },+ content_text="Hello, world!",+ voice="",+ )++ content = b""+ for chunk in result:+ content += chunk++ assert content != b""