feat: fe anthropic
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
|||||||
useMessage,
|
useMessage,
|
||||||
type FormRules,
|
type FormRules,
|
||||||
} from "naive-ui";
|
} from "naive-ui";
|
||||||
import { reactive, ref, watch } from "vue";
|
import { computed, reactive, ref, watch } from "vue";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
@@ -51,7 +51,7 @@ interface GroupFormData {
|
|||||||
display_name: string;
|
display_name: string;
|
||||||
description: string;
|
description: string;
|
||||||
upstreams: UpstreamInfo[];
|
upstreams: UpstreamInfo[];
|
||||||
channel_type: "openai" | "gemini";
|
channel_type: "openai" | "gemini" | "anthropic";
|
||||||
sort: number;
|
sort: number;
|
||||||
test_model: string;
|
test_model: string;
|
||||||
param_overrides: string;
|
param_overrides: string;
|
||||||
@@ -83,6 +83,33 @@ const configOptions = ref<GroupConfigOption[]>([]);
|
|||||||
const channelTypesFetched = ref(false);
|
const channelTypesFetched = ref(false);
|
||||||
const configOptionsFetched = ref(false);
|
const configOptionsFetched = ref(false);
|
||||||
|
|
||||||
|
// 根据渠道类型动态生成占位符提示
|
||||||
|
const testModelPlaceholder = computed(() => {
|
||||||
|
switch (formData.channel_type) {
|
||||||
|
case "openai":
|
||||||
|
return "如:gpt-4.1-nano";
|
||||||
|
case "gemini":
|
||||||
|
return "如:gemini-2.0-flash-lite";
|
||||||
|
case "anthropic":
|
||||||
|
return "如:claude-3-haiku-20240307";
|
||||||
|
default:
|
||||||
|
return "请输入模型名称";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const upstreamPlaceholder = computed(() => {
|
||||||
|
switch (formData.channel_type) {
|
||||||
|
case "openai":
|
||||||
|
return "https://api.openai.com";
|
||||||
|
case "gemini":
|
||||||
|
return "https://generativelanguage.googleapis.com";
|
||||||
|
case "anthropic":
|
||||||
|
return "https://api.anthropic.com";
|
||||||
|
default:
|
||||||
|
return "请输入上游地址";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const rules: FormRules = {
|
const rules: FormRules = {
|
||||||
name: [
|
name: [
|
||||||
@@ -330,10 +357,7 @@ async function handleSubmit() {
|
|||||||
<h4 class="section-title">基础信息</h4>
|
<h4 class="section-title">基础信息</h4>
|
||||||
|
|
||||||
<n-form-item label="分组名称" path="name">
|
<n-form-item label="分组名称" path="name">
|
||||||
<n-input
|
<n-input v-model:value="formData.name" placeholder="作为路由的一部分,如:gemini" />
|
||||||
v-model:value="formData.name"
|
|
||||||
placeholder="作为路由的一部分,如:gemini-pro-group"
|
|
||||||
/>
|
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
|
||||||
<n-form-item label="显示名称" path="display_name">
|
<n-form-item label="显示名称" path="display_name">
|
||||||
@@ -349,7 +373,7 @@ async function handleSubmit() {
|
|||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
|
||||||
<n-form-item label="测试模型" path="test_model">
|
<n-form-item label="测试模型" path="test_model">
|
||||||
<n-input v-model:value="formData.test_model" placeholder="如:gpt-3.5-turbo" />
|
<n-input v-model:value="formData.test_model" :placeholder="testModelPlaceholder" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
|
||||||
<n-form-item label="排序" path="sort">
|
<n-form-item label="排序" path="sort">
|
||||||
@@ -390,7 +414,7 @@ async function handleSubmit() {
|
|||||||
<div class="flex items-center gap-2" style="width: 100%">
|
<div class="flex items-center gap-2" style="width: 100%">
|
||||||
<n-input
|
<n-input
|
||||||
v-model:value="upstream.url"
|
v-model:value="upstream.url"
|
||||||
placeholder="https://api.openai.com"
|
:placeholder="upstreamPlaceholder"
|
||||||
style="flex: 1"
|
style="flex: 1"
|
||||||
/>
|
/>
|
||||||
<span class="form-label">权重</span>
|
<span class="form-label">权重</span>
|
||||||
|
@@ -50,6 +50,8 @@ function getChannelTagType(channelType: string) {
|
|||||||
return "success";
|
return "success";
|
||||||
case "gemini":
|
case "gemini":
|
||||||
return "info";
|
return "info";
|
||||||
|
case "anthropic":
|
||||||
|
return "warning";
|
||||||
default:
|
default:
|
||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
@@ -94,6 +96,7 @@ function handleGroupCreated() {
|
|||||||
<div class="group-icon">
|
<div class="group-icon">
|
||||||
<span v-if="group.channel_type === 'openai'">🤖</span>
|
<span v-if="group.channel_type === 'openai'">🤖</span>
|
||||||
<span v-else-if="group.channel_type === 'gemini'">💎</span>
|
<span v-else-if="group.channel_type === 'gemini'">💎</span>
|
||||||
|
<span v-else-if="group.channel_type === 'anthropic'">🧠</span>
|
||||||
<span v-else>🔧</span>
|
<span v-else>🔧</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="group-content">
|
<div class="group-content">
|
||||||
|
@@ -36,7 +36,7 @@ export interface Group {
|
|||||||
description: string;
|
description: string;
|
||||||
sort: number;
|
sort: number;
|
||||||
test_model: string;
|
test_model: string;
|
||||||
channel_type: "openai" | "gemini";
|
channel_type: "openai" | "gemini" | "anthropic";
|
||||||
upstreams: UpstreamInfo[];
|
upstreams: UpstreamInfo[];
|
||||||
config: Record<string, unknown>;
|
config: Record<string, unknown>;
|
||||||
api_keys?: APIKey[];
|
api_keys?: APIKey[];
|
||||||
|
Reference in New Issue
Block a user