chore: add undici as a dependency

This commit is contained in:
feie9454 2025-11-29 21:26:22 +08:00
parent 823df2cbf6
commit edd0a85439
6 changed files with 2437 additions and 100 deletions

View File

@ -6,6 +6,12 @@ import { downloadFile } from "@/lib/minio";
import { extractAudio } from "../media"; import { extractAudio } from "../media";
import { z } from "zod"; import { z } from "zod";
import { zodResponseFormat } from "openai/helpers/zod"; import { zodResponseFormat } from "openai/helpers/zod";
import { ProxyAgent, setGlobalDispatcher } from "undici";
const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
if (proxy) {
setGlobalDispatcher(new ProxyAgent(proxy));
}
const client = new OpenAI({ const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY, apiKey: process.env.OPENAI_API_KEY,
@ -49,14 +55,16 @@ async function transcriptAudio(audio: Buffer | string) {
}); });
const data = completion.choices?.[0]?.message const data = completion.choices?.[0]?.message
if (!data) { console.log("转写结果", data.content);
if (!data || !data.content) {
throw new Error("No STT result returned from model"); throw new Error("No STT result returned from model");
} }
const parsed = SttSchema.safeParse(data?.content).data; try {
if (!parsed) { return JSON.parse(data.content) as SttResult;
throw new Error("Failed to parse STT result with zod"); } catch (e) {
throw new Error("Failed to parse STT result JSON");
} }
return parsed;
} }
export async function transcriptAweme(awemeId: string): Promise<SttResult> { export async function transcriptAweme(awemeId: string): Promise<SttResult> {

View File

@ -1,3 +1,4 @@
export const runtime = "nodejs";
import { NextRequest, NextResponse } from 'next/server'; import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma'; import { prisma } from '@/lib/prisma';
import type { FeedItem, FeedResponse } from '@/app/types/feed'; import type { FeedItem, FeedResponse } from '@/app/types/feed';

View File

@ -6,7 +6,7 @@ export const BackgroundCanvas = forwardRef<HTMLCanvasElement, BackgroundCanvasPr
return ( return (
<canvas <canvas
ref={ref} ref={ref}
className="fixed inset-0 w-full h-full -z-10" className="fixed inset-0 w-full h-full -z-10 scale-110"
style={{ filter: "blur(40px)" }} style={{ filter: "blur(40px)" }}
/> />
); );

View File

@ -123,7 +123,7 @@ export default async function AwemeDetail({ params }: { params: Promise<{ awemeI
const neighbors: { prev: { aweme_id: string } | null; next: { aweme_id: string } | null } = { prev: pickPrev, next: pickNext }; const neighbors: { prev: { aweme_id: string } | null; next: { aweme_id: string } | null } = { prev: pickPrev, next: pickNext };
return ( return (
<main className="min-h-screen w-full overflow-hidden"> <main className="min-h-screen w-full">
{/* 顶部条改为悬浮在媒体区域之上,避免 sticky 造成 Y 方向滚动条 */} {/* 顶部条改为悬浮在媒体区域之上,避免 sticky 造成 Y 方向滚动条 */}
<div className="fixed left-3 top-3 z-30"> <div className="fixed left-3 top-3 z-30">
<BackButton <BackButton

2511
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@
"puppeteer-extra-plugin-stealth": "^2.11.2", "puppeteer-extra-plugin-stealth": "^2.11.2",
"react": "19.1.0", "react": "19.1.0",
"react-dom": "19.1.0", "react-dom": "19.1.0",
"undici": "^7.16.0",
"zod": "^4.1.12" "zod": "^4.1.12"
}, },
"devDependencies": { "devDependencies": {