mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 16:54:31 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -3,8 +3,12 @@ import { describe, expect, it } from "vitest";
|
||||
import { transcribeDeepgramAudio } from "./audio.js";
|
||||
|
||||
const resolveRequestUrl = (input: RequestInfo | URL) => {
|
||||
if (typeof input === "string") return input;
|
||||
if (input instanceof URL) return input.toString();
|
||||
if (typeof input === "string") {
|
||||
return input;
|
||||
}
|
||||
if (input instanceof URL) {
|
||||
return input.toString();
|
||||
}
|
||||
return input.url;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,10 +28,14 @@ export async function transcribeDeepgramAudio(
|
||||
|
||||
const url = new URL(`${baseUrl}/listen`);
|
||||
url.searchParams.set("model", model);
|
||||
if (params.language?.trim()) url.searchParams.set("language", params.language.trim());
|
||||
if (params.language?.trim()) {
|
||||
url.searchParams.set("language", params.language.trim());
|
||||
}
|
||||
if (params.query) {
|
||||
for (const [key, value] of Object.entries(params.query)) {
|
||||
if (value === undefined) continue;
|
||||
if (value === undefined) {
|
||||
continue;
|
||||
}
|
||||
url.searchParams.set(key, String(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ const DEFAULT_GOOGLE_AUDIO_PROMPT = "Transcribe the audio.";
|
||||
|
||||
function resolveModel(model?: string): string {
|
||||
const trimmed = model?.trim();
|
||||
if (!trimmed) return DEFAULT_GOOGLE_AUDIO_MODEL;
|
||||
if (!trimmed) {
|
||||
return DEFAULT_GOOGLE_AUDIO_MODEL;
|
||||
}
|
||||
return normalizeGoogleModelId(trimmed);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,12 @@ import { describe, expect, it } from "vitest";
|
||||
import { describeGeminiVideo } from "./video.js";
|
||||
|
||||
const resolveRequestUrl = (input: RequestInfo | URL) => {
|
||||
if (typeof input === "string") return input;
|
||||
if (input instanceof URL) return input.toString();
|
||||
if (typeof input === "string") {
|
||||
return input;
|
||||
}
|
||||
if (input instanceof URL) {
|
||||
return input.toString();
|
||||
}
|
||||
return input.url;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ const DEFAULT_GOOGLE_VIDEO_PROMPT = "Describe the video.";
|
||||
|
||||
function resolveModel(model?: string): string {
|
||||
const trimmed = model?.trim();
|
||||
if (!trimmed) return DEFAULT_GOOGLE_VIDEO_MODEL;
|
||||
if (!trimmed) {
|
||||
return DEFAULT_GOOGLE_VIDEO_MODEL;
|
||||
}
|
||||
return normalizeGoogleModelId(trimmed);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ const PROVIDERS: MediaUnderstandingProvider[] = [
|
||||
|
||||
export function normalizeMediaProviderId(id: string): string {
|
||||
const normalized = normalizeProviderId(id);
|
||||
if (normalized === "gemini") return "google";
|
||||
if (normalized === "gemini") {
|
||||
return "google";
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,12 @@ import { describe, expect, it } from "vitest";
|
||||
import { transcribeOpenAiCompatibleAudio } from "./audio.js";
|
||||
|
||||
const resolveRequestUrl = (input: RequestInfo | URL) => {
|
||||
if (typeof input === "string") return input;
|
||||
if (input instanceof URL) return input.toString();
|
||||
if (typeof input === "string") {
|
||||
return input;
|
||||
}
|
||||
if (input instanceof URL) {
|
||||
return input.toString();
|
||||
}
|
||||
return input.url;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,8 +27,12 @@ export async function transcribeOpenAiCompatibleAudio(
|
||||
});
|
||||
form.append("file", blob, fileName);
|
||||
form.append("model", model);
|
||||
if (params.language?.trim()) form.append("language", params.language.trim());
|
||||
if (params.prompt?.trim()) form.append("prompt", params.prompt.trim());
|
||||
if (params.language?.trim()) {
|
||||
form.append("language", params.language.trim());
|
||||
}
|
||||
if (params.prompt?.trim()) {
|
||||
form.append("prompt", params.prompt.trim());
|
||||
}
|
||||
|
||||
const headers = new Headers(params.headers);
|
||||
if (!headers.has("authorization")) {
|
||||
|
||||
@@ -24,8 +24,12 @@ export async function readErrorResponse(res: Response): Promise<string | undefin
|
||||
try {
|
||||
const text = await res.text();
|
||||
const collapsed = text.replace(/\s+/g, " ").trim();
|
||||
if (!collapsed) return undefined;
|
||||
if (collapsed.length <= MAX_ERROR_CHARS) return collapsed;
|
||||
if (!collapsed) {
|
||||
return undefined;
|
||||
}
|
||||
if (collapsed.length <= MAX_ERROR_CHARS) {
|
||||
return collapsed;
|
||||
}
|
||||
return `${collapsed.slice(0, MAX_ERROR_CHARS)}…`;
|
||||
} catch {
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user