Forráskód Böngészése

Feat/add xinference openllm provider (#958)

zxhlyh 1 éve%!(EXTRA string=óta)
szülő
commit
215a27fd95
21 módosított fájl, 1119 hozzáadás és 3 törlés
  1. 19 0
      web/app/components/base/icons/assets/public/llm/openllm-text.svg
  2. 12 0
      web/app/components/base/icons/assets/public/llm/openllm.svg
  3. 42 0
      web/app/components/base/icons/assets/public/llm/xorbits-inference-text.svg
  4. 24 0
      web/app/components/base/icons/assets/public/llm/xorbits-inference.svg
  5. 83 0
      web/app/components/base/icons/src/public/llm/Openllm.json
  6. 14 0
      web/app/components/base/icons/src/public/llm/Openllm.tsx
  7. 143 0
      web/app/components/base/icons/src/public/llm/OpenllmText.json
  8. 14 0
      web/app/components/base/icons/src/public/llm/OpenllmText.tsx
  9. 176 0
      web/app/components/base/icons/src/public/llm/XorbitsInference.json
  10. 14 0
      web/app/components/base/icons/src/public/llm/XorbitsInference.tsx
  11. 329 0
      web/app/components/base/icons/src/public/llm/XorbitsInferenceText.json
  12. 14 0
      web/app/components/base/icons/src/public/llm/XorbitsInferenceText.tsx
  13. 4 0
      web/app/components/base/icons/src/public/llm/index.ts
  14. 1 1
      web/app/components/base/icons/src/vender/line/general/DotsHorizontal.json
  15. 4 0
      web/app/components/header/account-setting/model-page/configs/index.ts
  16. 89 0
      web/app/components/header/account-setting/model-page/configs/openllm.tsx
  17. 128 0
      web/app/components/header/account-setting/model-page/configs/xinference.tsx
  18. 2 0
      web/app/components/header/account-setting/model-page/declarations.ts
  19. 4 0
      web/app/components/header/account-setting/model-page/index.tsx
  20. 2 1
      web/app/components/header/account-setting/model-page/model-item/Setting.tsx
  21. 1 1
      web/app/components/header/account-setting/model-page/utils.ts

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 19 - 0
web/app/components/base/icons/assets/public/llm/openllm-text.svg


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 12 - 0
web/app/components/base/icons/assets/public/llm/openllm.svg


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 42 - 0
web/app/components/base/icons/assets/public/llm/xorbits-inference-text.svg


+ 24 - 0
web/app/components/base/icons/assets/public/llm/xorbits-inference.svg

@@ -0,0 +1,24 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="Xorbits Square" clip-path="url(#clip0_9850_26870)">
+<path id="Vector" d="M8.00391 12.3124C8.69334 13.0754 9.47526 13.7494 10.3316 14.3188C11.0667 14.8105 11.8509 15.2245 12.6716 15.5541C14.1617 14.1465 15.3959 12.4907 16.3192 10.6606L21.7051 0L12.3133 7.38353C10.5832 8.74456 9.12178 10.416 8.00391 12.3124Z" fill="url(#paint0_linear_9850_26870)"/>
+<path id="Vector_2" d="M7.23504 18.9512C6.56092 18.5012 5.92386 18.0265 5.3221 17.5394L2.06445 24L7.91975 19.3959C7.69034 19.2494 7.46092 19.103 7.23504 18.9512Z" fill="url(#paint1_linear_9850_26870)"/>
+<path id="Vector_3" d="M19.3161 8.57474C21.0808 10.9147 21.5961 13.5159 20.3996 15.3053C18.6526 17.9189 13.9161 17.8183 9.82024 15.0812C5.72435 12.3441 3.82024 8.0065 5.56729 5.39297C6.76377 3.60356 9.36318 3.0865 12.2008 3.81886C7.29318 1.73474 2.62376 1.94121 0.813177 4.64474C-1.45976 8.04709 1.64435 14.1177 7.74494 18.1889C13.8455 22.26 20.6361 22.8124 22.9091 19.4118C24.7179 16.703 23.1173 12.3106 19.3161 8.57474Z" fill="url(#paint2_linear_9850_26870)"/>
+</g>
+<defs>
+<linearGradient id="paint0_linear_9850_26870" x1="2.15214" y1="24.3018" x2="21.2921" y2="0.0988218" gradientUnits="userSpaceOnUse">
+<stop stop-color="#E9A85E"/>
+<stop offset="1" stop-color="#F52B76"/>
+</linearGradient>
+<linearGradient id="paint1_linear_9850_26870" x1="2.06269" y1="24.2294" x2="21.2027" y2="0.028252" gradientUnits="userSpaceOnUse">
+<stop stop-color="#E9A85E"/>
+<stop offset="1" stop-color="#F52B76"/>
+</linearGradient>
+<linearGradient id="paint2_linear_9850_26870" x1="-0.613606" y1="3.843" x2="21.4449" y2="18.7258" gradientUnits="userSpaceOnUse">
+<stop stop-color="#6A0CF5"/>
+<stop offset="1" stop-color="#AB66F3"/>
+</linearGradient>
+<clipPath id="clip0_9850_26870">
+<rect width="24" height="24" fill="white"/>
+</clipPath>
+</defs>
+</svg>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 83 - 0
web/app/components/base/icons/src/public/llm/Openllm.json


+ 14 - 0
web/app/components/base/icons/src/public/llm/Openllm.tsx

@@ -0,0 +1,14 @@
+// GENERATE BY script
+// DON NOT EDIT IT MANUALLY
+
+import * as React from 'react'
+import data from './Openllm.json'
+import IconBase from '@/app/components/base/icons/IconBase'
+import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
+
+const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
+  props,
+  ref,
+) => <IconBase {...props} ref={ref} data={data as IconData} />)
+
+export default Icon

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 143 - 0
web/app/components/base/icons/src/public/llm/OpenllmText.json


+ 14 - 0
web/app/components/base/icons/src/public/llm/OpenllmText.tsx

@@ -0,0 +1,14 @@
+// GENERATE BY script
+// DON NOT EDIT IT MANUALLY
+
+import * as React from 'react'
+import data from './OpenllmText.json'
+import IconBase from '@/app/components/base/icons/IconBase'
+import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
+
+const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
+  props,
+  ref,
+) => <IconBase {...props} ref={ref} data={data as IconData} />)
+
+export default Icon

+ 176 - 0
web/app/components/base/icons/src/public/llm/XorbitsInference.json

@@ -0,0 +1,176 @@
+{
+	"icon": {
+		"type": "element",
+		"isRootNode": true,
+		"name": "svg",
+		"attributes": {
+			"width": "24",
+			"height": "24",
+			"viewBox": "0 0 24 24",
+			"fill": "none",
+			"xmlns": "http://www.w3.org/2000/svg"
+		},
+		"children": [
+			{
+				"type": "element",
+				"name": "g",
+				"attributes": {
+					"id": "Xorbits Square",
+					"clip-path": "url(#clip0_9850_26870)"
+				},
+				"children": [
+					{
+						"type": "element",
+						"name": "path",
+						"attributes": {
+							"id": "Vector",
+							"d": "M8.00391 12.3124C8.69334 13.0754 9.47526 13.7494 10.3316 14.3188C11.0667 14.8105 11.8509 15.2245 12.6716 15.5541C14.1617 14.1465 15.3959 12.4907 16.3192 10.6606L21.7051 0L12.3133 7.38353C10.5832 8.74456 9.12178 10.416 8.00391 12.3124Z",
+							"fill": "url(#paint0_linear_9850_26870)"
+						},
+						"children": []
+					},
+					{
+						"type": "element",
+						"name": "path",
+						"attributes": {
+							"id": "Vector_2",
+							"d": "M7.23504 18.9512C6.56092 18.5012 5.92386 18.0265 5.3221 17.5394L2.06445 24L7.91975 19.3959C7.69034 19.2494 7.46092 19.103 7.23504 18.9512Z",
+							"fill": "url(#paint1_linear_9850_26870)"
+						},
+						"children": []
+					},
+					{
+						"type": "element",
+						"name": "path",
+						"attributes": {
+							"id": "Vector_3",
+							"d": "M19.3161 8.57474C21.0808 10.9147 21.5961 13.5159 20.3996 15.3053C18.6526 17.9189 13.9161 17.8183 9.82024 15.0812C5.72435 12.3441 3.82024 8.0065 5.56729 5.39297C6.76377 3.60356 9.36318 3.0865 12.2008 3.81886C7.29318 1.73474 2.62376 1.94121 0.813177 4.64474C-1.45976 8.04709 1.64435 14.1177 7.74494 18.1889C13.8455 22.26 20.6361 22.8124 22.9091 19.4118C24.7179 16.703 23.1173 12.3106 19.3161 8.57474Z",
+							"fill": "url(#paint2_linear_9850_26870)"
+						},
+						"children": []
+					}
+				]
+			},
+			{
+				"type": "element",
+				"name": "defs",
+				"attributes": {},
+				"children": [
+					{
+						"type": "element",
+						"name": "linearGradient",
+						"attributes": {
+							"id": "paint0_linear_9850_26870",
+							"x1": "2.15214",
+							"y1": "24.3018",
+							"x2": "21.2921",
+							"y2": "0.0988218",
+							"gradientUnits": "userSpaceOnUse"
+						},
+						"children": [
+							{
+								"type": "element",
+								"name": "stop",
+								"attributes": {
+									"stop-color": "#E9A85E"
+								},
+								"children": []
+							},
+							{
+								"type": "element",
+								"name": "stop",
+								"attributes": {
+									"offset": "1",
+									"stop-color": "#F52B76"
+								},
+								"children": []
+							}
+						]
+					},
+					{
+						"type": "element",
+						"name": "linearGradient",
+						"attributes": {
+							"id": "paint1_linear_9850_26870",
+							"x1": "2.06269",
+							"y1": "24.2294",
+							"x2": "21.2027",
+							"y2": "0.028252",
+							"gradientUnits": "userSpaceOnUse"
+						},
+						"children": [
+							{
+								"type": "element",
+								"name": "stop",
+								"attributes": {
+									"stop-color": "#E9A85E"
+								},
+								"children": []
+							},
+							{
+								"type": "element",
+								"name": "stop",
+								"attributes": {
+									"offset": "1",
+									"stop-color": "#F52B76"
+								},
+								"children": []
+							}
+						]
+					},
+					{
+						"type": "element",
+						"name": "linearGradient",
+						"attributes": {
+							"id": "paint2_linear_9850_26870",
+							"x1": "-0.613606",
+							"y1": "3.843",
+							"x2": "21.4449",
+							"y2": "18.7258",
+							"gradientUnits": "userSpaceOnUse"
+						},
+						"children": [
+							{
+								"type": "element",
+								"name": "stop",
+								"attributes": {
+									"stop-color": "#6A0CF5"
+								},
+								"children": []
+							},
+							{
+								"type": "element",
+								"name": "stop",
+								"attributes": {
+									"offset": "1",
+									"stop-color": "#AB66F3"
+								},
+								"children": []
+							}
+						]
+					},
+					{
+						"type": "element",
+						"name": "clipPath",
+						"attributes": {
+							"id": "clip0_9850_26870"
+						},
+						"children": [
+							{
+								"type": "element",
+								"name": "rect",
+								"attributes": {
+									"width": "24",
+									"height": "24",
+									"fill": "white"
+								},
+								"children": []
+							}
+						]
+					}
+				]
+			}
+		]
+	},
+	"name": "XorbitsInference"
+}

+ 14 - 0
web/app/components/base/icons/src/public/llm/XorbitsInference.tsx

@@ -0,0 +1,14 @@
+// GENERATE BY script
+// DON NOT EDIT IT MANUALLY
+
+import * as React from 'react'
+import data from './XorbitsInference.json'
+import IconBase from '@/app/components/base/icons/IconBase'
+import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
+
+const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
+  props,
+  ref,
+) => <IconBase {...props} ref={ref} data={data as IconData} />)
+
+export default Icon

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 329 - 0
web/app/components/base/icons/src/public/llm/XorbitsInferenceText.json


+ 14 - 0
web/app/components/base/icons/src/public/llm/XorbitsInferenceText.tsx

@@ -0,0 +1,14 @@
+// GENERATE BY script
+// DON NOT EDIT IT MANUALLY
+
+import * as React from 'react'
+import data from './XorbitsInferenceText.json'
+import IconBase from '@/app/components/base/icons/IconBase'
+import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
+
+const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
+  props,
+  ref,
+) => <IconBase {...props} ref={ref} data={data as IconData} />)
+
+export default Icon

+ 4 - 0
web/app/components/base/icons/src/public/llm/index.ts

@@ -21,5 +21,9 @@ export { default as OpenaiGreen } from './OpenaiGreen'
 export { default as OpenaiText } from './OpenaiText'
 export { default as OpenaiTransparent } from './OpenaiTransparent'
 export { default as OpenaiViolet } from './OpenaiViolet'
+export { default as OpenllmText } from './OpenllmText'
+export { default as Openllm } from './Openllm'
 export { default as ReplicateText } from './ReplicateText'
 export { default as Replicate } from './Replicate'
+export { default as XorbitsInferenceText } from './XorbitsInferenceText'
+export { default as XorbitsInference } from './XorbitsInference'

+ 1 - 1
web/app/components/base/icons/src/vender/line/general/DotsHorizontal.json

@@ -68,4 +68,4 @@
 		]
 	},
 	"name": "DotsHorizontal"
-}
+}

+ 4 - 0
web/app/components/header/account-setting/model-page/configs/index.ts

@@ -8,6 +8,8 @@ import tongyi from './tongyi'
 import spark from './spark'
 import minimax from './minimax'
 import chatglm from './chatglm'
+import xinference from './xinference'
+import openllm from './openllm'
 
 export default {
   openai,
@@ -20,4 +22,6 @@ export default {
   spark,
   minimax,
   chatglm,
+  xinference,
+  openllm,
 }

+ 89 - 0
web/app/components/header/account-setting/model-page/configs/openllm.tsx

@@ -0,0 +1,89 @@
+import { ProviderEnum } from '../declarations'
+import type { ProviderConfig } from '../declarations'
+import { Openllm, OpenllmText } from '@/app/components/base/icons/src/public/llm'
+
+const config: ProviderConfig = {
+  selector: {
+    name: {
+      'en': 'OpenLLM',
+      'zh-Hans': 'OpenLLM',
+    },
+    icon: <Openllm className='w-full h-full' />,
+  },
+  item: {
+    key: ProviderEnum.openllm,
+    titleIcon: {
+      'en': <OpenllmText className='h-6' />,
+      'zh-Hans': <OpenllmText className='h-6' />,
+    },
+    disable: {
+      tip: {
+        'en': 'Only supports the ',
+        'zh-Hans': '仅支持',
+      },
+      link: {
+        href: {
+          'en': 'https://docs.dify.ai/getting-started/install-self-hosted',
+          'zh-Hans': 'https://docs.dify.ai/v/zh-hans/getting-started/install-self-hosted',
+        },
+        label: {
+          'en': 'community open-source version',
+          'zh-Hans': '社区开源版本',
+        },
+      },
+    },
+  },
+  modal: {
+    key: ProviderEnum.openllm,
+    title: {
+      'en': 'OpenLLM',
+      'zh-Hans': 'OpenLLM',
+    },
+    icon: <Openllm className='h-6' />,
+    link: {
+      href: 'https://github.com/bentoml/OpenLLM',
+      label: {
+        'en': 'How to deploy OpenLLM',
+        'zh-Hans': '如何部署 OpenLLM',
+      },
+    },
+    defaultValue: {
+      model_type: 'text-generation',
+    },
+    validateKeys: [
+      'model_type',
+      'model_name',
+      'server_url',
+    ],
+    fields: [
+      {
+        type: 'text',
+        key: 'model_name',
+        required: true,
+        label: {
+          'en': 'Model Name',
+          'zh-Hans': '模型名称',
+        },
+        placeholder: {
+          'en': 'Enter your Model Name here',
+          'zh-Hans': '在此输入您的模型名称',
+        },
+      },
+      {
+        type: 'text',
+        key: 'server_url',
+        required: true,
+        label: {
+          'en': 'Server url',
+          'zh-Hans': 'Server url',
+        },
+        placeholder: {
+          'en': 'Enter your Server Url, eg: https://example.com/xxx',
+          'zh-Hans': '在此输入您的 Server Url,如:https://example.com/xxx',
+        },
+      },
+    ],
+  },
+}
+
+export default config

+ 128 - 0
web/app/components/header/account-setting/model-page/configs/xinference.tsx

@@ -0,0 +1,128 @@
+import { ProviderEnum } from '../declarations'
+import type { ProviderConfig } from '../declarations'
+import { XorbitsInference, XorbitsInferenceText } from '@/app/components/base/icons/src/public/llm'
+
+const config: ProviderConfig = {
+  selector: {
+    name: {
+      'en': 'Xinference',
+      'zh-Hans': 'Xinference',
+    },
+    icon: <XorbitsInference className='w-full h-full' />,
+  },
+  item: {
+    key: ProviderEnum.xinference,
+    titleIcon: {
+      'en': <XorbitsInferenceText className='h-6' />,
+      'zh-Hans': <XorbitsInferenceText className='h-6' />,
+    },
+    disable: {
+      tip: {
+        'en': 'Only supports the ',
+        'zh-Hans': '仅支持',
+      },
+      link: {
+        href: {
+          'en': 'https://docs.dify.ai/getting-started/install-self-hosted',
+          'zh-Hans': 'https://docs.dify.ai/v/zh-hans/getting-started/install-self-hosted',
+        },
+        label: {
+          'en': 'community open-source version',
+          'zh-Hans': '社区开源版本',
+        },
+      },
+    },
+  },
+  modal: {
+    key: ProviderEnum.xinference,
+    title: {
+      'en': 'Xinference',
+      'zh-Hans': 'Xinference',
+    },
+    icon: <XorbitsInference className='h-6' />,
+    link: {
+      href: 'https://github.com/xorbitsai/inference',
+      label: {
+        'en': 'How to deploy Xinference',
+        'zh-Hans': '如何部署 Xinference',
+      },
+    },
+    defaultValue: {
+      model_type: 'text-generation',
+    },
+    validateKeys: [
+      'model_type',
+      'model_name',
+      'server_url',
+      'model_uid',
+    ],
+    fields: [
+      {
+        type: 'radio',
+        key: 'model_type',
+        required: true,
+        label: {
+          'en': 'Model Type',
+          'zh-Hans': '模型类型',
+        },
+        options: [
+          {
+            key: 'text-generation',
+            label: {
+              'en': 'Text Generation',
+              'zh-Hans': '文本生成',
+            },
+          },
+          {
+            key: 'embeddings',
+            label: {
+              'en': 'Embeddings',
+              'zh-Hans': 'Embeddings',
+            },
+          },
+        ],
+      },
+      {
+        type: 'text',
+        key: 'model_name',
+        required: true,
+        label: {
+          'en': 'Model Name',
+          'zh-Hans': '模型名称',
+        },
+        placeholder: {
+          'en': 'Enter your Model Name here',
+          'zh-Hans': '在此输入您的模型名称',
+        },
+      },
+      {
+        type: 'text',
+        key: 'server_url',
+        required: true,
+        label: {
+          'en': 'Server Url',
+          'zh-Hans': 'Server Url',
+        },
+        placeholder: {
+          'en': 'Enter your Server url, eg: https://example.com/xxx',
+          'zh-Hans': '在此输入您的 Server url,如:https://example.com/xxx',
+        },
+      },
+      {
+        type: 'text',
+        key: 'model_uid',
+        required: true,
+        label: {
+          'en': 'Model UID',
+          'zh-Hans': 'Model UID',
+        },
+        placeholder: {
+          'en': 'Enter your Model UID',
+          'zh-Hans': '在此输入您的 Model UID',
+        },
+      },
+    ],
+  },
+}
+
+export default config

+ 2 - 0
web/app/components/header/account-setting/model-page/declarations.ts

@@ -39,6 +39,8 @@ export enum ProviderEnum {
   'spark' = 'spark',
   'minimax' = 'minimax',
   'chatglm' = 'chatglm',
+  'xinference' = 'xinference',
+  'openllm' = 'openllm',
 }
 
 export type ProviderConfigItem = {

+ 4 - 0
web/app/components/header/account-setting/model-page/index.tsx

@@ -83,6 +83,8 @@ const ModelPage = () => {
       config.tongyi,
       config.wenxin,
       config.chatglm,
+      config.xinference,
+      config.openllm,
     ]
   }
   else {
@@ -95,6 +97,8 @@ const ModelPage = () => {
       config.tongyi,
       config.wenxin,
       config.chatglm,
+      config.xinference,
+      config.openllm,
     ]
   }
 

+ 2 - 1
web/app/components/header/account-setting/model-page/model-item/Setting.tsx

@@ -59,8 +59,9 @@ const Setting: FC<SettingProps> = ({
       {
         configurable && (
           <Button
-            className={`!px-3 !h-7 rounded-md bg-white !text-xs font-medium text-gray-700 ${!!modelItem.disable && '!text-gray-300'}`}
+            className={`!px-3 !h-7 rounded-md bg-white !text-xs font-medium text-gray-700 ${!!modelItem.disable && !IS_CE_EDITION && '!text-gray-300'}`}
             onClick={() => onOpenModal()}
+            disabled={!!modelItem.disable && !IS_CE_EDITION}
           >
             {t('common.operation.add')}
           </Button>

+ 1 - 1
web/app/components/header/account-setting/model-page/utils.ts

@@ -2,7 +2,7 @@ import { ValidatedStatus } from '../key-validator/declarations'
 import { ProviderEnum } from './declarations'
 import { validateModelProvider } from '@/service/common'
 
-export const ConfigurableProviders = [ProviderEnum.azure_openai, ProviderEnum.replicate, ProviderEnum.huggingface_hub]
+export const ConfigurableProviders = [ProviderEnum.azure_openai, ProviderEnum.replicate, ProviderEnum.huggingface_hub, ProviderEnum.xinference, ProviderEnum.openllm]
 
 export const validateModelProviderFn = async (providerName: ProviderEnum, v: any) => {
   let body, url