This commit is contained in:
parent
285ac31ceb
commit
467884c0df
|
|
@ -1,10 +1,15 @@
|
||||||
|
import { getRuntimeEnv } from "@/lib/ipconfig"
|
||||||
|
|
||||||
export async function generateBgeM3Embedding(text: string): Promise<number[] | null> {
|
export async function generateBgeM3Embedding(text: string): Promise<number[] | null> {
|
||||||
try {
|
try {
|
||||||
// 动态获取当前协议和主机(不含端口),然后指定后端端口 8001
|
// 取 Supabase URL 或本地默认
|
||||||
const { protocol, host } = window.location;
|
const supaUrl = getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000"
|
||||||
const hostname = host.split(":")[0];
|
// 构造 Embedding 服务地址:同 host + 8001 端口
|
||||||
const apiUrl = `${protocol}//${hostname}:8001/v1/embeddings`;
|
const urlObj = new URL(supaUrl)
|
||||||
console.log("......generateBgeM3Embedding", apiUrl);
|
urlObj.port = "8001" // 强制改成 8001
|
||||||
|
const apiUrl = `${urlObj.origin}/v1/embeddings`
|
||||||
|
console.debug("......[generateBgeM3Embedding] apiUrl =", apiUrl)
|
||||||
|
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue