mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-29 16:20:27 +00:00
fix: allow messages dispatch for composite groups
This commit is contained in:
@@ -1614,9 +1614,9 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- OpenAI Messages 调度配置(仅 openai 平台) -->
|
||||
<!-- OpenAI Messages 调度配置(OpenAI 与 Composite 平台) -->
|
||||
<div
|
||||
v-if="createForm.platform === 'openai'"
|
||||
v-if="supportsMessagesDispatchPlatform(createForm.platform)"
|
||||
class="border-t border-gray-200 dark:border-dark-400 pt-4 mt-4"
|
||||
>
|
||||
<h4 class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">
|
||||
@@ -1655,7 +1655,13 @@
|
||||
{{ t("admin.groups.openaiMessages.allowDispatchHint") }}
|
||||
</p>
|
||||
|
||||
<div v-if="createForm.allow_messages_dispatch" class="mt-3">
|
||||
<div
|
||||
v-if="
|
||||
createForm.platform === 'openai' &&
|
||||
createForm.allow_messages_dispatch
|
||||
"
|
||||
class="mt-3"
|
||||
>
|
||||
<div
|
||||
class="relative overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-dark-600 dark:bg-dark-800"
|
||||
>
|
||||
@@ -3336,9 +3342,9 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- OpenAI Messages 调度配置(仅 openai 平台) -->
|
||||
<!-- OpenAI Messages 调度配置(OpenAI 与 Composite 平台) -->
|
||||
<div
|
||||
v-if="editForm.platform === 'openai'"
|
||||
v-if="supportsMessagesDispatchPlatform(editForm.platform)"
|
||||
class="border-t border-gray-200 dark:border-dark-400 pt-4 mt-4"
|
||||
>
|
||||
<h4 class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-3">
|
||||
@@ -3377,7 +3383,12 @@
|
||||
{{ t("admin.groups.openaiMessages.allowDispatchHint") }}
|
||||
</p>
|
||||
|
||||
<div v-if="editForm.allow_messages_dispatch" class="mt-3">
|
||||
<div
|
||||
v-if="
|
||||
editForm.platform === 'openai' && editForm.allow_messages_dispatch
|
||||
"
|
||||
class="mt-3"
|
||||
>
|
||||
<div
|
||||
class="relative overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-dark-600 dark:bg-dark-800"
|
||||
>
|
||||
@@ -4462,6 +4473,7 @@ import {
|
||||
messagesDispatchConfigToFormState,
|
||||
messagesDispatchFormStateToConfig,
|
||||
resetMessagesDispatchFormState,
|
||||
supportsMessagesDispatchPlatform,
|
||||
type MessagesDispatchMappingRow,
|
||||
} from "./groupsMessagesDispatch";
|
||||
import {
|
||||
@@ -6646,7 +6658,7 @@ watch(
|
||||
if (!["anthropic", "antigravity"].includes(newVal)) {
|
||||
createForm.fallback_group_id_on_invalid_request = null;
|
||||
}
|
||||
if (newVal !== "openai") {
|
||||
if (!supportsMessagesDispatchPlatform(newVal)) {
|
||||
resetMessagesDispatchFormState(createForm);
|
||||
}
|
||||
if (!supportsLivePlatform(newVal)) {
|
||||
@@ -6696,7 +6708,7 @@ watch(
|
||||
if (!["anthropic", "antigravity"].includes(newVal)) {
|
||||
editForm.fallback_group_id_on_invalid_request = null;
|
||||
}
|
||||
if (newVal !== "openai") {
|
||||
if (!supportsMessagesDispatchPlatform(newVal)) {
|
||||
resetMessagesDispatchFormState(editForm);
|
||||
}
|
||||
if (!supportsLivePlatform(newVal)) {
|
||||
@@ -6748,7 +6760,7 @@ watch(
|
||||
if (!['anthropic', 'antigravity'].includes(newVal)) {
|
||||
editForm.fallback_group_id_on_invalid_request = null
|
||||
}
|
||||
if (newVal !== 'openai') {
|
||||
if (!supportsMessagesDispatchPlatform(newVal)) {
|
||||
editForm.allow_messages_dispatch = false
|
||||
editForm.default_mapped_model = ''
|
||||
}
|
||||
|
||||
@@ -5,9 +5,16 @@ import {
|
||||
messagesDispatchConfigToFormState,
|
||||
messagesDispatchFormStateToConfig,
|
||||
resetMessagesDispatchFormState,
|
||||
supportsMessagesDispatchPlatform,
|
||||
} from "../groupsMessagesDispatch";
|
||||
|
||||
describe("groupsMessagesDispatch", () => {
|
||||
it("supports OpenAI and composite groups", () => {
|
||||
expect(supportsMessagesDispatchPlatform("openai")).toBe(true);
|
||||
expect(supportsMessagesDispatchPlatform("composite")).toBe(true);
|
||||
expect(supportsMessagesDispatchPlatform("anthropic")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns the expected default form state", () => {
|
||||
expect(createDefaultMessagesDispatchFormState()).toEqual({
|
||||
allow_messages_dispatch: false,
|
||||
|
||||
@@ -13,6 +13,10 @@ export interface MessagesDispatchFormState {
|
||||
exact_model_mappings: MessagesDispatchMappingRow[];
|
||||
}
|
||||
|
||||
export function supportsMessagesDispatchPlatform(platform: string): boolean {
|
||||
return platform === "openai" || platform === "composite";
|
||||
}
|
||||
|
||||
export function createDefaultMessagesDispatchFormState(): MessagesDispatchFormState {
|
||||
return {
|
||||
allow_messages_dispatch: false,
|
||||
|
||||
Reference in New Issue
Block a user