mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 13:13:06 +00:00
refactor: reuse shared openai model prefix helper
This commit is contained in:
@@ -1,16 +1,11 @@
|
||||
import { findCatalogTemplate } from "openclaw/plugin-sdk/provider-catalog-shared";
|
||||
import { cloneFirstTemplateModel } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import {
|
||||
cloneFirstTemplateModel,
|
||||
matchesExactOrPrefix,
|
||||
} from "openclaw/plugin-sdk/provider-model-shared";
|
||||
|
||||
export const OPENAI_API_BASE_URL = "https://api.openai.com/v1";
|
||||
|
||||
export function matchesExactOrPrefix(id: string, values: readonly string[]): boolean {
|
||||
const normalizedId = id.trim().toLowerCase();
|
||||
return values.some((value) => {
|
||||
const normalizedValue = value.trim().toLowerCase();
|
||||
return normalizedId === normalizedValue || normalizedId.startsWith(normalizedValue);
|
||||
});
|
||||
}
|
||||
|
||||
export function isOpenAIApiBaseUrl(baseUrl?: string): boolean {
|
||||
const trimmed = baseUrl?.trim();
|
||||
if (!trimmed) {
|
||||
@@ -19,4 +14,4 @@ export function isOpenAIApiBaseUrl(baseUrl?: string): boolean {
|
||||
return /^https?:\/\/api\.openai\.com(?:\/v1)?\/?$/i.test(trimmed);
|
||||
}
|
||||
|
||||
export { cloneFirstTemplateModel, findCatalogTemplate };
|
||||
export { cloneFirstTemplateModel, findCatalogTemplate, matchesExactOrPrefix };
|
||||
|
||||
Reference in New Issue
Block a user