mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-16 16:13:56 +00:00
feat: support claude and gemini in vertex ai (#1621)
* feat: support claude and gemini in vertex ai * fix: do not show api key field in channel page when the type is VertexAI * fix: update getToken function to include channelId in cache key
This commit is contained in:
@@ -161,6 +161,12 @@ export const CHANNEL_OPTIONS = {
|
||||
value: 39,
|
||||
color: 'primary'
|
||||
},
|
||||
42: {
|
||||
key: 42,
|
||||
text: 'VertexAI',
|
||||
value: 42,
|
||||
color: 'primary'
|
||||
},
|
||||
41: {
|
||||
key: 41,
|
||||
text: 'Novita',
|
||||
|
@@ -165,6 +165,8 @@ const EditModal = ({ open, channelId, onCancel, onOk }) => {
|
||||
if (values.key === '') {
|
||||
if (values.config.ak && values.config.sk && values.config.region) {
|
||||
values.key = `${values.config.ak}|${values.config.sk}|${values.config.region}`;
|
||||
} else if (values.config.region && values.config.vertex_ai_project_id && values.config.vertex_ai_adc) {
|
||||
values.key = `${values.config.region}|${values.config.vertex_ai_project_id}|${values.config.vertex_ai_adc}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -203,7 +203,26 @@ const typeConfig = {
|
||||
}
|
||||
},
|
||||
modelGroup: 'Coze'
|
||||
}
|
||||
},
|
||||
42: {
|
||||
inputLabel: {
|
||||
key: '',
|
||||
config: {
|
||||
region: 'Vertex AI Region',
|
||||
vertex_ai_project_id: 'Vertex AI Project ID',
|
||||
vertex_ai_adc: 'Google Cloud Application Default Credentials JSON'
|
||||
}
|
||||
},
|
||||
prompt: {
|
||||
key: '',
|
||||
config: {
|
||||
region: 'Vertex AI Region.g. us-east5',
|
||||
vertex_ai_project_id: 'Vertex AI Project ID',
|
||||
vertex_ai_adc: 'Google Cloud Application Default Credentials JSON: https://cloud.google.com/docs/authentication/application-default-credentials'
|
||||
}
|
||||
},
|
||||
modelGroup: 'anthropic'
|
||||
},
|
||||
};
|
||||
|
||||
export { defaultConfig, typeConfig };
|
||||
|
@@ -27,6 +27,7 @@ export const CHANNEL_OPTIONS = [
|
||||
{key: 37, text: 'Cloudflare', value: 37, color: 'orange'},
|
||||
{key: 38, text: 'DeepL', value: 38, color: 'black'},
|
||||
{key: 39, text: 'together.ai', value: 39, color: 'blue'},
|
||||
{key: 42, text: 'VertexAI', value: 42, color: 'blue'},
|
||||
{key: 8, text: '自定义渠道', value: 8, color: 'pink'},
|
||||
{key: 22, text: '知识库:FastGPT', value: 22, color: 'blue'},
|
||||
{key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple'},
|
||||
|
@@ -58,7 +58,9 @@ const EditChannel = () => {
|
||||
region: '',
|
||||
sk: '',
|
||||
ak: '',
|
||||
user_id: ''
|
||||
user_id: '',
|
||||
vertex_ai_project_id: '',
|
||||
vertex_ai_adc: ''
|
||||
});
|
||||
const handleInputChange = (e, { name, value }) => {
|
||||
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
||||
@@ -160,6 +162,8 @@ const EditChannel = () => {
|
||||
if (inputs.key === '') {
|
||||
if (config.ak !== '' && config.sk !== '' && config.region !== '') {
|
||||
inputs.key = `${config.ak}|${config.sk}|${config.region}`;
|
||||
} else if (config.region !== '' && config.vertex_ai_project_id !== '' && config.vertex_ai_adc !== '') {
|
||||
inputs.key = `${config.region}|${config.vertex_ai_project_id}|${config.vertex_ai_adc}`;
|
||||
}
|
||||
}
|
||||
if (!isEdit && (inputs.name === '' || inputs.key === '')) {
|
||||
@@ -456,6 +460,39 @@ const EditChannel = () => {
|
||||
</Form.Field>
|
||||
)
|
||||
}
|
||||
{
|
||||
inputs.type === 42 && (
|
||||
<Form.Field>
|
||||
<Form.Input
|
||||
label='Region'
|
||||
name='region'
|
||||
required
|
||||
placeholder={'Vertex AI Region.g. us-east5'}
|
||||
onChange={handleConfigChange}
|
||||
value={config.region}
|
||||
autoComplete=''
|
||||
/>
|
||||
<Form.Input
|
||||
label='Vertex AI Project ID'
|
||||
name='vertex_ai_project_id'
|
||||
required
|
||||
placeholder={'Vertex AI Project ID'}
|
||||
onChange={handleConfigChange}
|
||||
value={config.vertex_ai_project_id}
|
||||
autoComplete=''
|
||||
/>
|
||||
<Form.Input
|
||||
label='Google Cloud Application Default Credentials JSON'
|
||||
name='vertex_ai_adc'
|
||||
required
|
||||
placeholder={'Google Cloud Application Default Credentials JSON'}
|
||||
onChange={handleConfigChange}
|
||||
value={config.vertex_ai_adc}
|
||||
autoComplete=''
|
||||
/>
|
||||
</Form.Field>
|
||||
)
|
||||
}
|
||||
{
|
||||
inputs.type === 34 && (
|
||||
<Form.Input
|
||||
@@ -469,7 +506,7 @@ const EditChannel = () => {
|
||||
/>)
|
||||
}
|
||||
{
|
||||
inputs.type !== 33 && (batch ? <Form.Field>
|
||||
inputs.type !== 33 && inputs.type !== 42 && (batch ? <Form.Field>
|
||||
<Form.TextArea
|
||||
label='密钥'
|
||||
name='key'
|
||||
|
Reference in New Issue
Block a user