This commit is contained in:
parent
10fa1637ea
commit
b1ce04b5d6
|
|
@ -16,6 +16,7 @@ import OpenAI from "openai"
|
|||
import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
|
||||
|
||||
export async function POST(req: Request) {
|
||||
console.log("......[process] Starting file processing request")
|
||||
try {
|
||||
const supabaseAdmin = createClient<Database>(
|
||||
getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000",
|
||||
|
|
@ -88,6 +89,7 @@ export async function POST(req: Request) {
|
|||
chunks = await processMarkdown(blob)
|
||||
break
|
||||
case "pdf":
|
||||
console.log("......[process] Processing PDF...")
|
||||
chunks = await processPdf(blob)
|
||||
break
|
||||
case "txt":
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export const createFile = async (
|
|||
} else {
|
||||
fileRecord.name = baseName + "." + extension
|
||||
}
|
||||
|
||||
console.log("......[createFile] Inserting file record:", fileRecord);
|
||||
const { data: createdFile, error } = await supabase
|
||||
.from("files")
|
||||
.insert([fileRecord])
|
||||
|
|
@ -119,7 +119,7 @@ export const createFile = async (
|
|||
file_id: createdFile.id,
|
||||
workspace_id
|
||||
})
|
||||
|
||||
console.log("......[createFile] Uploading file to storage:", createdFile.name);
|
||||
const filePath = await uploadFile(file, {
|
||||
name: createdFile.name,
|
||||
user_id: createdFile.user_id,
|
||||
|
|
@ -134,11 +134,20 @@ export const createFile = async (
|
|||
formData.append("file_id", createdFile.id)
|
||||
formData.append("embeddingsProvider", embeddingsProvider)
|
||||
|
||||
console.log(
|
||||
`......[createFile] Sending process request for file ${createdFile.id}, provider: ${embeddingsProvider}`
|
||||
);
|
||||
|
||||
const response = await fetch("/api/retrieval/process", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
|
||||
console.log(
|
||||
`......[createFile] /api/retrieval/process responded status=${response.status}`
|
||||
);
|
||||
|
||||
|
||||
if (!response.ok) {
|
||||
const jsonText = await response.text()
|
||||
const json = JSON.parse(jsonText)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export async function generateBgeM3Embedding(text: string): Promise<number[] | n
|
|||
const { protocol, host } = window.location;
|
||||
const hostname = host.split(":")[0];
|
||||
const apiUrl = `${protocol}//${hostname}:8001/v1/embeddings`;
|
||||
|
||||
console.log("......generateBgeM3Embedding", apiUrl);
|
||||
const response = await fetch(apiUrl, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
|
|
|||
Loading…
Reference in New Issue