Compare commits
126 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8083090414 | |||
| 77d0d9bfb8 | |||
| e434c7867f | |||
| 2574b2814b | |||
| 1564bd977e | |||
| da85269c9f | |||
| 15f803a511 | |||
| 414308802c | |||
| 7333e4fda3 | |||
| 1cdaa29764 | |||
| 9d270b7b0e | |||
| fdd1cd32a8 | |||
| 6210a06d43 | |||
| 807132014a | |||
| 041817cc3c | |||
| acb0ceb9a9 | |||
| 417dab7ddc | |||
| 3a9a07c109 | |||
| a02d505e2e | |||
| a0266b061f | |||
| f22738ec2b | |||
| fed8e62965 | |||
| ced2143a6e | |||
| a58e2c4e67 | |||
| 64c59e4886 | |||
| 49f353033c | |||
| eb7b9acb26 | |||
| 093c698cf0 | |||
| 977665fac7 | |||
| a153bfef02 | |||
| ccca43f3dc | |||
| bde2cca414 | |||
| d29d198c88 | |||
| cfafd043e9 | |||
| 4723114bf5 | |||
| 11e74fd08e | |||
| afc8fe4167 | |||
| f1333b68b6 | |||
| 69bbdb3d02 | |||
| 7645134b35 | |||
| 0250e65959 | |||
| fecfea5dad | |||
| cac95019b6 | |||
| 88022a8edd | |||
| b6ededa2c4 | |||
| b098a09425 | |||
| a1dcbd23b7 | |||
| b71615597b | |||
| 32b5f90e86 | |||
| 7ff4b77505 | |||
| 75a5416fad | |||
| 4c415a47f8 | |||
| 954c7f2192 | |||
| 1aa95fb972 | |||
| 5d71a8d7c5 | |||
| 4f7ca8018c | |||
| c167712b0e | |||
| a8b4599c4f | |||
| 25ad26ad55 | |||
| cf27da94a7 | |||
| a43880fbcc | |||
| e04282e3a4 | |||
| 98bde0a1c0 | |||
| 3e3227755b | |||
| 5c58283264 | |||
| 2c7680bedc | |||
| db2e05889d | |||
| 517ac1eeac | |||
| 63fbd35c63 | |||
| 6d55676aa9 | |||
| 48f8bc0c8e | |||
| 463f063932 | |||
| 11bc0331cf | |||
| 6af33ee5b7 | |||
| e289537fd9 | |||
| 7adbbc31c2 | |||
| 2e383282c8 | |||
| 7c913a4cb6 | |||
| 42e3384ebb | |||
| 8610cd5770 | |||
| 1f240581d2 | |||
| a0b2148b65 | |||
| 2619493362 | |||
| da37970a43 | |||
| 6879a97e36 | |||
| dd7f9c9f5f | |||
| 31a1703ba8 | |||
| 81a9c35cda | |||
| bd9e99890d | |||
| fe30521c24 | |||
| 06e7d96f67 | |||
| 666acb6241 | |||
| 1c499ae805 | |||
| 0153612020 | |||
| d27f7eba4d | |||
| 4c60acb5bb | |||
| 3de5221b4a | |||
| 3e0070db80 | |||
| b347d8f08c | |||
| 11ae2969b4 | |||
| b6d2abaa64 | |||
| 3e79f117a3 | |||
| 13517c835c | |||
| 8ec82bc9ba | |||
| 5205764fae | |||
| 16d1e8f3d7 | |||
| e6684244d1 | |||
| 976f3505bf | |||
| f91b83385f | |||
| 6797ff023d | |||
| 528bb727ad | |||
| e0c482efbc | |||
| cf285f0637 | |||
| d4c697d680 | |||
| d90dc847ef | |||
| 8707a01fd3 | |||
| 2c95e440d1 | |||
| b06c880a9c | |||
| b5d70ca524 | |||
| d41afdd2da | |||
| 5253a62f9a | |||
| 125f59b1e1 | |||
| e18a6ef1c6 | |||
| f65a908661 | |||
| 93f1a76efb | |||
| c36ff21b91 |
@@ -56,7 +56,7 @@ body:
|
||||
label: Environment
|
||||
description: Share your environment details. Reports without proper environment details will likely be closed.
|
||||
value: |
|
||||
- APINTO Dashboard version:
|
||||
- ApiPark version:
|
||||
- Operating system (run `uname -a`):
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,7 +1,7 @@
|
||||
provider: bailian
|
||||
label:
|
||||
zh_Hans: 阿里云百炼
|
||||
en_US: bailian
|
||||
en_US: BaiLian
|
||||
icon_small:
|
||||
en_US: icon_s_en.svg
|
||||
icon_large:
|
||||
|
||||
@@ -89,7 +89,7 @@ provider_credential_schema:
|
||||
zh_Hans: 为了进行验证,请输入一个您可用的模型名称 (例如:amazon.titan-text-lite-v1)
|
||||
model_config:
|
||||
access_configuration_status: true
|
||||
access_configuration_demo: "{}"
|
||||
access_configuration_demo: "{\"region\":\"\",\"model\":\"\"}"
|
||||
address: https://bedrock-runtime.amazonaws.com
|
||||
sort: 4
|
||||
recommend: true
|
||||
@@ -1,11 +1 @@
|
||||
<svg width="80" height="22" viewBox="0 0 80 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="Group">
|
||||
<path id="Vector" d="M25.1152 10.5768C25.1152 14.1739 27.4253 16.6819 30.6264 16.6819C33.8274 16.6819 36.1375 14.1739 36.1375 10.5768C36.1375 6.97973 33.8274 4.47168 30.6264 4.47168C27.4253 4.47168 25.1152 6.97973 25.1152 10.5768ZM34.0254 10.5768C34.0254 13.1509 32.6229 14.8174 30.6264 14.8174C28.6298 14.8174 27.2273 13.1509 27.2273 10.5768C27.2273 8.00275 28.6298 6.33622 30.6264 6.33622C32.6229 6.33622 34.0254 8.00275 34.0254 10.5768Z" fill="black"/>
|
||||
<path id="Vector_2" d="M42.0868 16.682C44.5124 16.682 45.8984 14.636 45.8984 12.1774C45.8984 9.71889 44.5124 7.67285 42.0868 7.67285C40.9648 7.67285 40.1398 8.11836 39.5953 8.76188V7.83786H37.6152V19.4706H39.5953V15.593C40.1398 16.2365 40.9648 16.682 42.0868 16.682ZM39.5458 11.9299C39.5458 10.2964 40.4698 9.40539 41.6908 9.40539C43.1264 9.40539 43.9019 10.5274 43.9019 12.1774C43.9019 13.8275 43.1264 14.9495 41.6908 14.9495C40.4698 14.9495 39.5458 14.042 39.5458 12.4415V11.9299Z" fill="black"/>
|
||||
<path id="Vector_3" d="M51.2545 16.682C52.987 16.682 54.3565 15.7745 54.967 14.2565L53.2675 13.613C53.0035 14.504 52.228 14.999 51.2545 14.999C49.9839 14.999 49.0929 14.0915 48.9444 12.6065H55.0165V11.9464C55.0165 9.57039 53.68 7.67285 51.172 7.67285C48.6639 7.67285 47.0469 9.63639 47.0469 12.1774C47.0469 14.8505 48.7794 16.682 51.2545 16.682ZM51.1555 9.33939C52.4095 9.33939 53.0035 10.1644 53.02 11.1214H49.0434C49.3404 9.9499 50.1324 9.33939 51.1555 9.33939Z" fill="black"/>
|
||||
<path id="Vector_4" d="M56.5038 16.5005H58.4838V11.4184C58.4838 10.1809 59.3913 9.52089 60.2824 9.52089C61.3714 9.52089 61.8004 10.2964 61.8004 11.3689V16.5005H63.7804V10.7914C63.7804 8.92688 62.6914 7.67285 60.8764 7.67285C59.7544 7.67285 58.9788 8.18436 58.4838 8.76188V7.83786H56.5038V16.5005Z" fill="black"/>
|
||||
<path id="Vector_5" d="M69.5799 4.65332L65.0918 16.5006H67.1873L68.1939 13.7945H73.309L74.332 16.5006H76.4605L71.9724 4.65332H69.5799ZM70.7349 6.99637L72.616 11.9465H68.8869L70.7349 6.99637Z" fill="black"/>
|
||||
<path id="Vector_6" d="M79.8581 4.6875H77.7461V16.5348H79.8581V4.6875Z" fill="black"/>
|
||||
<path id="Vector_7" d="M20.2769 9.00448C20.776 7.50639 20.6041 5.86529 19.8059 4.50264C18.6055 2.41259 16.1924 1.33732 13.8356 1.84333C12.7871 0.662179 11.2808 -0.00952316 9.70154 0.000102043C7.29248 -0.00539807 5.155 1.54563 4.41386 3.83781C2.86626 4.15475 1.53042 5.12346 0.748717 6.49643C-0.460621 8.58097 -0.184928 11.2087 1.43073 12.9962C0.931596 14.4943 1.10348 16.1354 1.90168 17.498C3.10208 19.5881 5.51526 20.6634 7.87206 20.1573C8.91983 21.3385 10.4269 22.0102 12.0061 21.9999C14.4165 22.0061 16.5547 20.4537 17.2958 18.1594C18.8434 17.8425 20.1793 16.8738 20.961 15.5008C22.1689 13.4163 21.8925 10.7906 20.2776 9.00311L20.2769 9.00448ZM12.0075 20.5623C11.0429 20.5637 10.1085 20.2261 9.36809 19.608C9.40178 19.5901 9.46022 19.5578 9.49803 19.5345L13.8789 17.0044C14.103 16.8772 14.2405 16.6386 14.2391 16.3808V10.2049L16.0906 11.274C16.1105 11.2836 16.1236 11.3028 16.1264 11.3248V16.4393C16.1236 18.7136 14.2818 20.5575 12.0075 20.5623ZM3.14952 16.7789C2.6662 15.9443 2.49225 14.9659 2.65795 14.0165C2.69026 14.0357 2.74732 14.0708 2.78789 14.0942L7.16873 16.6242C7.3908 16.7541 7.6658 16.7541 7.88856 16.6242L13.2367 13.5359V15.6741C13.2381 15.6961 13.2278 15.7174 13.2106 15.7311L8.78233 18.288C6.80985 19.4238 4.29079 18.7486 3.15021 16.7789H3.14952ZM1.99656 7.21626C2.47782 6.38024 3.23752 5.74085 4.14229 5.40878C4.14229 5.44659 4.14023 5.51328 4.14023 5.56003V10.6208C4.13885 10.878 4.27636 11.1165 4.4998 11.2437L9.84798 14.3313L7.9965 15.4004C7.97794 15.4128 7.95456 15.4149 7.93393 15.4059L3.50496 12.847C1.53661 11.7071 0.86147 9.18874 1.99587 7.21694L1.99656 7.21626ZM17.2085 10.7563L11.8603 7.66795L13.7118 6.59956C13.7304 6.58718 13.7537 6.58512 13.7744 6.59406L18.2033 9.15092C20.1751 10.2901 20.851 12.8126 19.7118 14.7844C19.2298 15.6191 18.4708 16.2584 17.5667 16.5912V11.3792C17.5688 11.122 17.432 10.8841 17.2092 10.7563H17.2085ZM19.0511 7.98284C19.0187 7.9629 18.9617 7.92852 18.9211 7.90515L14.5403 5.37509C14.3182 5.24515 14.0432 5.24515 13.8204 5.37509L8.47226 8.46341V6.32524C8.47088 6.30324 8.4812 6.28192 8.49838 6.26817L12.9267 3.71337C14.8991 2.57553 17.4209 3.25273 18.5581 5.2259C19.0387 6.05917 19.2126 7.03475 19.0497 7.98284H19.0511ZM7.46574 11.7937L5.61357 10.7246C5.59363 10.715 5.58057 10.6958 5.57782 10.6738V5.55935C5.5792 3.2823 7.42655 1.43701 9.7036 1.43838C10.6668 1.43838 11.5991 1.77664 12.3395 2.39265C12.3058 2.41053 12.2481 2.44284 12.2096 2.46622L7.82874 4.99627C7.60461 5.12346 7.46711 5.36134 7.46849 5.61916L7.46574 11.7924V11.7937ZM8.47157 9.62531L10.8538 8.24959L13.236 9.62462V12.3754L10.8538 13.7504L8.47157 12.3754V9.62531Z" fill="black"/>
|
||||
</g>
|
||||
</svg>
|
||||
<svg fill="currentColor" fill-rule="evenodd" height="56" viewBox="0 0 24 24" width="56" xmlns="http://www.w3.org/2000/svg" style="flex: 0 0 auto; line-height: 1;"><title>LM Studio</title><path d="M2.84 2a1.273 1.273 0 100 2.547h14.107a1.273 1.273 0 100-2.547H2.84zM7.935 5.33a1.273 1.273 0 000 2.548H22.04a1.274 1.274 0 000-2.547H7.935zM3.624 9.935c0-.704.57-1.274 1.274-1.274h14.106a1.274 1.274 0 010 2.547H4.898c-.703 0-1.274-.57-1.274-1.273zM1.273 12.188a1.273 1.273 0 100 2.547H15.38a1.274 1.274 0 000-2.547H1.273zM3.624 16.792c0-.704.57-1.274 1.274-1.274h14.106a1.273 1.273 0 110 2.547H4.898c-.703 0-1.274-.57-1.274-1.273zM13.029 18.849a1.273 1.273 0 100 2.547h9.698a1.273 1.273 0 100-2.547h-9.698z" fill-opacity=".3"></path><path d="M2.84 2a1.273 1.273 0 100 2.547h10.287a1.274 1.274 0 000-2.547H2.84zM7.935 5.33a1.273 1.273 0 000 2.548H18.22a1.274 1.274 0 000-2.547H7.935zM3.624 9.935c0-.704.57-1.274 1.274-1.274h10.286a1.273 1.273 0 010 2.547H4.898c-.703 0-1.274-.57-1.274-1.273zM1.273 12.188a1.273 1.273 0 100 2.547H11.56a1.274 1.274 0 000-2.547H1.273zM3.624 16.792c0-.704.57-1.274 1.274-1.274h10.286a1.273 1.273 0 110 2.547H4.898c-.703 0-1.274-.57-1.274-1.273zM13.029 18.849a1.273 1.273 0 100 2.547h5.78a1.273 1.273 0 100-2.547h-5.78z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 17 KiB |
@@ -29,12 +29,12 @@ provider_credential_schema:
|
||||
placeholder:
|
||||
zh_Hans: 在此输入您的 API Key
|
||||
en_US: Enter your API Key
|
||||
- variable: base_url
|
||||
- variable: dashscope_api_base
|
||||
label:
|
||||
en_US: https://api.baichuan-ai.com/v1
|
||||
en_US: https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
type: text-input
|
||||
required: false
|
||||
placeholder:
|
||||
zh_Hans: 在此输入您的 Base URL
|
||||
en_US: Enter your Base URL
|
||||
address: https://api.baichuan-ai.com/v1
|
||||
address: https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
@@ -81,7 +81,7 @@ func convertInt(value interface{}) int {
|
||||
|
||||
func genAIKey(key string, provider string) string {
|
||||
keys := strings.Split(key, "@")
|
||||
return strings.TrimSuffix(keys[0], fmt.Sprintf("-%s", provider))
|
||||
return strings.TrimPrefix(keys[0], fmt.Sprintf("%s-", provider))
|
||||
}
|
||||
|
||||
// HandleMessage 处理从 NSQ 读取的消息
|
||||
|
||||
@@ -267,7 +267,7 @@ func (i *imlLocalModelController) initAILocalService(ctx context.Context, model
|
||||
})
|
||||
|
||||
return func() error {
|
||||
path := fmt.Sprintf("/%s/chat", strings.Trim(prefix, "/"))
|
||||
path := fmt.Sprintf("/%s/chat/completions", strings.Trim(prefix, "/"))
|
||||
timeout := 300000
|
||||
retry := 0
|
||||
aiPrompt := &ai_api_dto.AiPrompt{
|
||||
|
||||
@@ -354,7 +354,8 @@ func (i *imlServiceController) createAIService(ctx *gin.Context, teamID string,
|
||||
if !has {
|
||||
return nil, fmt.Errorf("model %s not found", pv.DefaultLLM)
|
||||
}
|
||||
modelId = m.ID()
|
||||
//modelId = m.ID()
|
||||
modelId = m.Name()
|
||||
modelCfg = m.DefaultConfig()
|
||||
|
||||
}
|
||||
|
||||
@@ -395,36 +395,36 @@ func (i *imlInitController) createAIService(ctx context.Context, teamID string,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := fmt.Sprintf("/%s/demo_translation_api", strings.Trim(input.Prefix, "/"))
|
||||
path := fmt.Sprintf("/%s/chat/completions", strings.Trim(input.Prefix, "/"))
|
||||
timeout := 300000
|
||||
retry := 0
|
||||
aiPrompt := &ai_api_dto.AiPrompt{
|
||||
Variables: []*ai_api_dto.AiPromptVariable{
|
||||
{
|
||||
Key: "source_lang",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
{
|
||||
Key: "target_lang",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
{
|
||||
Key: "text",
|
||||
Description: "",
|
||||
Require: true,
|
||||
},
|
||||
},
|
||||
Prompt: "You need to translate {{source_lang}} into {{target_lang}}, and the following is the content that needs to be translated.\n---\n{{text}}",
|
||||
//Variables: []*ai_api_dto.AiPromptVariable{
|
||||
// {
|
||||
// Key: "source_lang",
|
||||
// Description: "",
|
||||
// Require: true,
|
||||
// },
|
||||
// {
|
||||
// Key: "target_lang",
|
||||
// Description: "",
|
||||
// Require: true,
|
||||
// },
|
||||
// {
|
||||
// Key: "text",
|
||||
// Description: "",
|
||||
// Require: true,
|
||||
// },
|
||||
//},
|
||||
//Prompt: "You need to translate {{source_lang}} into {{target_lang}}, and the following is the content that needs to be translated.\n---\n{{text}}",
|
||||
}
|
||||
aiModel := &ai_api_dto.AiModel{
|
||||
Id: m.ID(),
|
||||
Config: m.DefaultConfig(),
|
||||
Provider: providerId,
|
||||
}
|
||||
name := "Demo Translation API"
|
||||
description := "A demo that shows you how to use a prompt to create a Translation API."
|
||||
name := "Demo Chat API"
|
||||
description := "A demo that shows you how to use a prompt to create a Chat API."
|
||||
apiId := uuid.New().String()
|
||||
err = i.aiAPIModule.Create(
|
||||
ctx,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { App, Col, Form, Input, Row, Table, Tooltip } from 'antd'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react'
|
||||
import {
|
||||
PublishApprovalInfoType,
|
||||
PublishApprovalModalHandle,
|
||||
@@ -36,6 +36,7 @@ export const PublishApprovalModalContent = forwardRef<PublishApprovalModalHandle
|
||||
const [form] = Form.useForm()
|
||||
const { fetchData } = useFetch()
|
||||
const { state } = useGlobalContext()
|
||||
const versionInputRef = useRef<Input>(null)
|
||||
|
||||
const save: (operate: 'pass' | 'refuse') => Promise<boolean | string> = (operate) => {
|
||||
if (type === 'view') {
|
||||
@@ -140,6 +141,12 @@ export const PublishApprovalModalContent = forwardRef<PublishApprovalModalHandle
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({ opinion: '', ...data })
|
||||
// 如果是添加模式且insidePage为true,自动聚焦版本号输入框
|
||||
if (type === 'add' && insidePage && versionInputRef.current) {
|
||||
setTimeout(() => {
|
||||
versionInputRef.current?.focus()
|
||||
}, 100)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const translatedUpstreamColumns = useMemo(
|
||||
@@ -335,7 +342,12 @@ export const PublishApprovalModalContent = forwardRef<PublishApprovalModalHandle
|
||||
{insidePage && (
|
||||
<>
|
||||
<Form.Item label={$t('版本号')} name="version" rules={[{ required: true, whitespace: true }]}>
|
||||
<Input className="w-INPUT_NORMAL" disabled={type !== 'add'} placeholder={$t(PLACEHOLDER.input)} />
|
||||
<Input
|
||||
className="w-INPUT_NORMAL"
|
||||
disabled={type !== 'add'}
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
ref={versionInputRef}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label={$t('版本说明')} name="versionRemark">
|
||||
|
||||
@@ -91,8 +91,15 @@ const AIProviderSelect: React.FC<AIProviderSelectProps> = ({ value, onChange, so
|
||||
label: (
|
||||
<Space className="flex items-center">
|
||||
<span
|
||||
className="flex items-center h-[20px] w-[20px]"
|
||||
dangerouslySetInnerHTML={{ __html: provider.logo }}
|
||||
className="flex items-center justify-center h-[20px] w-[20px] overflow-hidden"
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center'
|
||||
}}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: provider.logo.replace(/<svg/, '<svg style="max-width:100%;max-height:100%;width:auto;height:auto;"')
|
||||
}}
|
||||
></span>
|
||||
<span>{provider.name}</span>
|
||||
</Space>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { DefaultOptionType } from 'antd/es/select'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
|
||||
export type AiServiceRouterModelConfigHandle = {
|
||||
save: () => Promise<{ id: string; config: string, type: string, provider: string }>
|
||||
save: () => Promise<{ id: string; config: string; type: string; provider: string }>
|
||||
}
|
||||
|
||||
export type AiServiceRouterModelConfigProps = {
|
||||
@@ -49,7 +49,7 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
|
||||
|
||||
/**
|
||||
* 获取本地模型列表
|
||||
* @param setDefaultValue
|
||||
* @param setDefaultValue
|
||||
*/
|
||||
const getLocalLlmList = (setDefaultValue?: boolean) => {
|
||||
fetchData<LocalLlmType[]>('simple/ai/models/local/configured', {
|
||||
@@ -113,12 +113,11 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setProviderList(
|
||||
data.providers
|
||||
?.map((x: SimpleAiProviderItem) => {
|
||||
return { ...x, label: x.name, value: x.id }
|
||||
})
|
||||
data.providers?.map((x: SimpleAiProviderItem) => {
|
||||
return { ...x, label: x.name, value: x.id }
|
||||
})
|
||||
)
|
||||
if (setDefaultValue && data.providers.length) {
|
||||
if (setDefaultValue && data.providers.length) {
|
||||
const id = data.providers[0].id
|
||||
form.setFieldValue('provider', id)
|
||||
getLlmList(id)
|
||||
@@ -179,9 +178,14 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
className="w-INPUT_NORMAL"
|
||||
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
options={providerList}
|
||||
options={providerList.map((x) => ({
|
||||
...x,
|
||||
searchText: x.name.toLowerCase()
|
||||
}))}
|
||||
onChange={(e) => {
|
||||
getLlmList(e)
|
||||
}}
|
||||
@@ -191,19 +195,20 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
|
||||
|
||||
<Form.Item<AiServiceRouterModelConfigField> label={$t('模型')} name="id" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
options={
|
||||
llmList?.map((x) => ({
|
||||
value: x.id,
|
||||
label: (
|
||||
<div className="flex items-center gap-[10px]" key={x.id}>
|
||||
<span>{x.name || x.id}</span>
|
||||
{modelType === 'online' && x?.scopes?.map((s: any) => <Tag>{s?.toLocaleUpperCase()}</Tag>)}
|
||||
</div>
|
||||
)
|
||||
}))
|
||||
}
|
||||
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
|
||||
options={llmList?.map((x) => ({
|
||||
value: x.id,
|
||||
label: (
|
||||
<div className="flex items-center gap-[10px]" key={x.id}>
|
||||
<span>{x.name || x.id}</span>
|
||||
{modelType === 'online' && x?.scopes?.map((s: any) => <Tag>{s?.toLocaleUpperCase()}</Tag>)}
|
||||
</div>
|
||||
),
|
||||
searchText: x.name.toLowerCase()
|
||||
}))}
|
||||
onChange={(e) => {
|
||||
form.setFieldValue('config', llmList.find((x) => x.id === e)?.config)
|
||||
}}
|
||||
|
||||
@@ -182,7 +182,9 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
|
||||
{modelType === 'online' && (
|
||||
<Form.Item<LoadModelDetailData> label={$t('模型供应商')} name="provider" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
className="w-INPUT_NORMAL"
|
||||
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
loading={modelProviderLoading}
|
||||
options={modelProviderData?.map((x) => ({
|
||||
@@ -191,7 +193,8 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
|
||||
<div className="flex items-center gap-[10px]">
|
||||
<span>{x.name}</span>
|
||||
</div>
|
||||
)
|
||||
),
|
||||
searchText: x.name.toLowerCase()
|
||||
}))}
|
||||
onChange={(e) => {
|
||||
modelProviderChange(e)
|
||||
@@ -201,8 +204,10 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
|
||||
)}
|
||||
<Form.Item label={$t('模型')} name="model" className="mt-[16px]" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
|
||||
loading={llmListLoading}
|
||||
options={
|
||||
llmList?.map((x) => ({
|
||||
@@ -212,7 +217,8 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
|
||||
<span>{x.name || x.id}</span>
|
||||
{ modelType === 'online' &&x?.scopes?.map((s: any) => <Tag key={s}>{s?.toLocaleUpperCase()}</Tag>)}
|
||||
</div>
|
||||
)
|
||||
),
|
||||
searchText: x.name.toLowerCase()
|
||||
}))
|
||||
}
|
||||
onChange={(value) => {
|
||||
|
||||
@@ -450,9 +450,14 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
>
|
||||
{providerOptionList && providerOptionList.length > 0 ? (
|
||||
<Select
|
||||
showSearch
|
||||
className="w-INPUT_NORMAL"
|
||||
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
options={providerOptionList}
|
||||
options={providerOptionList.map((x) => ({
|
||||
...x,
|
||||
searchText: x.name.toLowerCase()
|
||||
}))}
|
||||
onChange={(e) => {
|
||||
modelProviderChange(e)
|
||||
}}
|
||||
@@ -467,7 +472,16 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item<AiServiceConfigFieldType> label={$t('默认模型')} name="model" rules={[{ required: true }]}>
|
||||
<Select className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)} options={modelList}></Select>
|
||||
<Select
|
||||
showSearch
|
||||
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
options={modelList ? modelList.map((x) => ({
|
||||
...x,
|
||||
searchText: x.name.toLowerCase()
|
||||
})) : []}
|
||||
></Select>
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -23,12 +23,32 @@ func genOperation(summary string, description string, variables []*ai_api_dto.Ai
|
||||
operation := openapi3.NewOperation()
|
||||
operation.Summary = summary
|
||||
operation.Description = description
|
||||
operation.AddParameter(&openapi3.Parameter{
|
||||
Name: "Authorization",
|
||||
In: "header",
|
||||
Required: true,
|
||||
Example: "{your_apipark_apikey}",
|
||||
})
|
||||
operation.RequestBody = genRequestBody(variables)
|
||||
operation.Responses = &openapi3.Responses{}
|
||||
operation.Responses.Set("200", genResponse())
|
||||
return operation
|
||||
}
|
||||
|
||||
func genRequestHeaders() openapi3.Parameters {
|
||||
return openapi3.Parameters{
|
||||
{
|
||||
Value: &openapi3.Parameter{
|
||||
Name: "Authorization",
|
||||
In: "header",
|
||||
Description: "your_apipark_apikey", // 替换Prompt的变量列表
|
||||
Required: true,
|
||||
Example: "your_apipark_apikey",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func genRequestParameters(variables []*ai_api_dto.AiPromptVariable) openapi3.Parameters {
|
||||
return openapi3.Parameters{
|
||||
{
|
||||
|
||||
@@ -220,7 +220,8 @@ func (i *imlBalanceModule) Delete(ctx context.Context, id string) error {
|
||||
return i.syncGateway(ctx, cluster.DefaultClusterID, []*gateway.DynamicRelease{
|
||||
{
|
||||
BasicItem: &gateway.BasicItem{
|
||||
ID: id,
|
||||
ID: id,
|
||||
Resource: "ai-provider",
|
||||
},
|
||||
},
|
||||
}, false)
|
||||
@@ -267,7 +268,8 @@ func (i *imlBalanceModule) getLocalBalances(ctx context.Context, v string) ([]*g
|
||||
var has bool
|
||||
v, has = i.settingService.Get(ctx, "system.ai_model.ollama_address")
|
||||
if !has {
|
||||
return nil, fmt.Errorf("ollama address not found")
|
||||
//return nil, fmt.Errorf("ollama address not found")
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +295,8 @@ func (i *imlBalanceModule) getBalances(ctx context.Context) ([]*gateway.DynamicR
|
||||
}
|
||||
v, has := i.settingService.Get(ctx, "system.ai_model.ollama_address")
|
||||
if !has {
|
||||
return nil, fmt.Errorf("ollama address not found")
|
||||
//return nil, fmt.Errorf("ollama address not found")
|
||||
return nil, nil
|
||||
}
|
||||
releases := make([]*gateway.DynamicRelease, 0, len(balances))
|
||||
for _, item := range balances {
|
||||
@@ -304,6 +307,10 @@ func (i *imlBalanceModule) getBalances(ctx context.Context) ([]*gateway.DynamicR
|
||||
continue
|
||||
}
|
||||
base = fmt.Sprintf("%s://%s%s", p.URI().Scheme(), p.URI().Host(), p.URI().Path())
|
||||
} else {
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
releases = append(releases, newRelease(item, base))
|
||||
}
|
||||
|
||||
@@ -383,12 +383,12 @@ func (i *imlKeyModule) UpdateKeyStatus(ctx context.Context, providerId string, i
|
||||
}
|
||||
releases := []*gateway.DynamicRelease{{
|
||||
BasicItem: &gateway.BasicItem{
|
||||
ID: id,
|
||||
ID: fmt.Sprintf("%s-%s", providerId, id),
|
||||
Resource: "ai-key",
|
||||
},
|
||||
Attr: nil,
|
||||
}}
|
||||
return i.syncGateway(ctx, providerId, releases, false)
|
||||
return i.syncGateway(ctx, cluster.DefaultClusterID, releases, false)
|
||||
}
|
||||
if info.Status == ai_key_dto.KeyDisable.Int() || info.Status == ai_key_dto.KeyExceed.Int() {
|
||||
// 超额 或 停用状态,可启用
|
||||
@@ -411,7 +411,7 @@ func (i *imlKeyModule) UpdateKeyStatus(ctx context.Context, providerId string, i
|
||||
return err
|
||||
}
|
||||
releases := []*gateway.DynamicRelease{newKey(info)}
|
||||
return i.syncGateway(ctx, providerId, releases, true)
|
||||
return i.syncGateway(ctx, cluster.DefaultClusterID, releases, true)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
ai_balance "github.com/APIParkLab/APIPark/service/ai-balance"
|
||||
|
||||
@@ -60,6 +61,7 @@ func (i *imlLocalModel) SyncLocalModels(ctx context.Context, address string) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return i.syncGateway(ctx, cluster.DefaultClusterID, releases, true)
|
||||
}
|
||||
|
||||
@@ -246,7 +248,7 @@ func (i *imlLocalModel) pullHook(fn ...func() error) func(msg ai_provider_local.
|
||||
v, _ := i.settingService.Get(ctx, "system.ai_model.ollama_address")
|
||||
|
||||
cfg := make(map[string]interface{})
|
||||
cfg["provider"] = "ollama"
|
||||
cfg["provider"] = ai_provider_local.ProviderLocal
|
||||
cfg["model"] = msg.Model
|
||||
cfg["model_config"] = ai_provider_local.LocalConfig
|
||||
cfg["priority"] = 0
|
||||
@@ -448,7 +450,7 @@ func (i *imlLocalModel) Enable(ctx context.Context, model string) error {
|
||||
}
|
||||
v, _ := i.settingService.Get(ctx, "system.ai_model.ollama_address")
|
||||
cfg := make(map[string]interface{})
|
||||
cfg["provider"] = "ollama"
|
||||
cfg["provider"] = ai_provider_local.ProviderLocal
|
||||
cfg["model"] = info.Id
|
||||
cfg["model_config"] = ai_provider_local.LocalConfig
|
||||
cfg["priority"] = 0
|
||||
@@ -512,8 +514,8 @@ func (i *imlLocalModel) OnInit() {
|
||||
})
|
||||
models, version := ai_provider_local.ModelsCanInstall()
|
||||
for _, model := range models {
|
||||
|
||||
if v, ok := oldModels[model.Id]; ok {
|
||||
delete(oldModels, model.Id)
|
||||
if v.Version == version {
|
||||
continue
|
||||
}
|
||||
@@ -541,7 +543,7 @@ func (i *imlLocalModel) OnInit() {
|
||||
return
|
||||
}
|
||||
}
|
||||
delete(oldModels, model.Id)
|
||||
|
||||
}
|
||||
for id := range oldModels {
|
||||
err = i.localModelPackageService.Delete(ctx, id)
|
||||
@@ -612,17 +614,18 @@ func (i *imlLocalModel) getLocalModels(ctx context.Context, v string) ([]*gatewa
|
||||
var has bool
|
||||
v, has = i.settingService.Get(ctx, "system.ai_model.ollama_address")
|
||||
if !has {
|
||||
return nil, errors.New("ollama_address not set")
|
||||
//return nil, errors.New("ollama_address not set")
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
provider := ai_provider_local.ProviderLocal
|
||||
releases := make([]*gateway.DynamicRelease, 0, len(list))
|
||||
for _, l := range list {
|
||||
if l.State != ai_local_dto.LocalModelStateNormal.Int() {
|
||||
continue
|
||||
}
|
||||
cfg := make(map[string]interface{})
|
||||
cfg["provider"] = "ollama"
|
||||
cfg["provider"] = provider
|
||||
cfg["model"] = l.Id
|
||||
cfg["model_config"] = ai_provider_local.LocalConfig
|
||||
cfg["base"] = v
|
||||
@@ -639,6 +642,25 @@ func (i *imlLocalModel) getLocalModels(ctx context.Context, v string) ([]*gatewa
|
||||
Attr: cfg,
|
||||
})
|
||||
}
|
||||
releases = append(releases, &gateway.DynamicRelease{
|
||||
BasicItem: &gateway.BasicItem{
|
||||
ID: fmt.Sprintf("%s-key", ai_provider_local.ProviderLocal),
|
||||
Description: "auto generate key",
|
||||
Resource: "ai-key",
|
||||
Version: time.Now().Format("20060102150405"),
|
||||
MatchLabels: map[string]string{
|
||||
"module": "ai-key",
|
||||
},
|
||||
},
|
||||
Attr: map[string]interface{}{
|
||||
"expired": 0,
|
||||
"config": fmt.Sprintf("{\"base\":\"%s\"}", v),
|
||||
"provider": provider,
|
||||
"priority": 1,
|
||||
"disabled": true,
|
||||
},
|
||||
})
|
||||
|
||||
return releases, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
ai_model "github.com/APIParkLab/APIPark/service/ai-model"
|
||||
@@ -200,6 +201,10 @@ func (i *imlProviderModule) Delete(ctx context.Context, id string) error {
|
||||
}
|
||||
|
||||
func (i *imlProviderModule) AddProvider(ctx context.Context, input *ai_dto.NewProvider) (*ai_dto.SimpleProvider, error) {
|
||||
_, has := model_runtime.GetProvider(strings.ToLower(input.Name))
|
||||
if has {
|
||||
return nil, fmt.Errorf("provider `%s` duplicate", input.Name)
|
||||
}
|
||||
// uuid = name
|
||||
if has := i.providerService.CheckUuidDuplicate(ctx, input.Name); has {
|
||||
return nil, fmt.Errorf("provider `%s` duplicate", input.Name)
|
||||
@@ -241,7 +246,7 @@ func (i *imlProviderModule) SimpleProvider(ctx context.Context, id string) (*ai_
|
||||
|
||||
func (i *imlProviderModule) ConfiguredProviders(ctx context.Context, keyword string) ([]*ai_dto.ConfiguredProviderItem, error) {
|
||||
// 获取已配置的AI服务商
|
||||
list, err := i.providerService.Search(ctx, keyword, nil, "update_at")
|
||||
list, err := i.providerService.Search(ctx, keyword, nil, "update_at desc")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get provider list error:%v", err)
|
||||
}
|
||||
@@ -694,7 +699,6 @@ func (i *imlProviderModule) UpdateProviderConfig(ctx context.Context, id string,
|
||||
}, newKey(defaultKey),
|
||||
}, true)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -596,9 +596,9 @@ func (i *imlMonitorStatisticModule) TopAPIStatistics(ctx context.Context, limit
|
||||
} else {
|
||||
statisticItem.IsRed = true
|
||||
if key == "-" {
|
||||
statisticItem.Name = "无API"
|
||||
statisticItem.Name = "Unknown API"
|
||||
} else {
|
||||
statisticItem.Name = fmt.Sprintf("未知API-%s", key)
|
||||
statisticItem.Name = fmt.Sprintf("Unknow-%s", key)
|
||||
}
|
||||
}
|
||||
result = append(result, statisticItem)
|
||||
|
||||
@@ -396,15 +396,36 @@ func (i *imlServiceModule) Create(ctx context.Context, teamID string, input *ser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err := i.serviceModelMappingService.Save(ctx, &service_model_mapping.Save{
|
||||
Sid: input.Id,
|
||||
Content: input.ModelMapping,
|
||||
})
|
||||
err := i.serviceService.Create(ctx, mo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return i.serviceService.Create(ctx, mo)
|
||||
if input.ModelMapping != "" {
|
||||
m := make(map[string]string)
|
||||
err = json.Unmarshal([]byte(input.ModelMapping), &m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = i.serviceModelMappingService.Save(ctx, &service_model_mapping.Save{
|
||||
Sid: input.Id,
|
||||
Content: input.ModelMapping,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := i.clusterService.GatewayClient(ctx, cluster.DefaultClusterID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = client.Hash().Online(ctx, &gateway.HashRelease{
|
||||
HashKey: fmt.Sprintf("%s:%s", gateway.KeyServiceMapping, input.Id),
|
||||
HashMap: m,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -473,7 +494,7 @@ func (i *imlServiceModule) Edit(ctx context.Context, id string, input *service_d
|
||||
|
||||
}
|
||||
}
|
||||
if input.ModelMapping != nil {
|
||||
if input.ModelMapping != nil && *input.ModelMapping != "" {
|
||||
m := make(map[string]string)
|
||||
err = json.Unmarshal([]byte(*input.ModelMapping), &m)
|
||||
if err != nil {
|
||||
|
||||
@@ -76,6 +76,7 @@ func FromEntity(e *api.AiAPIInfo) *API {
|
||||
Updater: e.Updater,
|
||||
Disable: e.Disable,
|
||||
UseToken: e.UseToken,
|
||||
Provider: e.Provider,
|
||||
Type: e.Type,
|
||||
AdditionalConfig: cfg,
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type imlLocalModelService struct {
|
||||
}
|
||||
|
||||
func (i *imlLocalModelService) UpdateProvider(ctx context.Context, provider string, ids ...string) error {
|
||||
_, err := i.store.UpdateWhere(ctx, map[string]interface{}{"provider": provider}, map[string]interface{}{"uuid": ids})
|
||||
_, err := i.store.UpdateField(ctx, "provider", provider, "uuid in (?)", ids)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,8 @@ type LocalModelPackage struct {
|
||||
Name string `gorm:"type:varchar(100);not null;column:name;comment:名称"`
|
||||
Size string `gorm:"type:varchar(100);not null;column:size;comment:模型大小"`
|
||||
Hash string `gorm:"type:varchar(100);not null;column:hash;comment:模型hash"`
|
||||
Description string `gorm:"type:varchar(255);not null;column:description;comment:描述"`
|
||||
Description string `gorm:"type:varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;not null;column:description;comment:描述"`
|
||||
Text string `gorm:"type:varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;not null;column:text;comment:描述"`
|
||||
Version string `gorm:"type:varchar(100);not null;column:version;comment:版本"`
|
||||
IsPopular bool `gorm:"type:tinyint(1);not null;column:is_popular;comment:是否热门"`
|
||||
}
|
||||
@@ -187,4 +188,3 @@ func (i *ProviderModel) TableName() string {
|
||||
func (i *ProviderModel) IdValue() int64 {
|
||||
return i.Id
|
||||
}
|
||||
|
||||
|
||||