fix
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session, selectinload
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session, selectinload
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import math
|
||||
import uuid
|
||||
from collections import defaultdict
|
||||
|
||||
from qdrant_client import QdrantClient, models
|
||||
@@ -46,7 +47,7 @@ class LightRAGAdapter:
|
||||
collection_name=self.settings.qdrant_collection,
|
||||
points=[
|
||||
models.PointStruct(
|
||||
id=job.job_id,
|
||||
id=self._point_id(job.job_id),
|
||||
vector=self._vectorize(payload["document"]),
|
||||
payload=payload,
|
||||
)
|
||||
@@ -69,7 +70,7 @@ class LightRAGAdapter:
|
||||
collection_name=self.settings.qdrant_collection,
|
||||
points=[
|
||||
models.PointStruct(
|
||||
id=worker.worker_id,
|
||||
id=self._point_id(worker.worker_id),
|
||||
vector=self._vectorize(payload["document"]),
|
||||
payload=payload,
|
||||
)
|
||||
@@ -141,3 +142,7 @@ class LightRAGAdapter:
|
||||
if chunk:
|
||||
tokens.append(chunk)
|
||||
return tokens
|
||||
|
||||
def _point_id(self, entity_id: str) -> str:
|
||||
# Qdrant v1.14 accepts point IDs as UUID or unsigned int.
|
||||
return str(uuid.uuid5(uuid.NAMESPACE_URL, entity_id))
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
const API_BASE = import.meta.env.VITE_API_BASE ?? "/api";
|
||||
|
||||
type ExtractResponse<T> = { data: T };
|
||||
type MatchResponse<T> = { items: T[] };
|
||||
type ListResponse<T> = { items: T[] };
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const response = await fetch(`${API_BASE}${path}`, {
|
||||
headers: {
|
||||
@@ -16,18 +20,33 @@ async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
}
|
||||
|
||||
export const api = {
|
||||
health: () => request("/health"),
|
||||
extractJob: (text: string) => request("/poc/extract/job", { method: "POST", body: JSON.stringify({ text }) }),
|
||||
extractWorker: (text: string) => request("/poc/extract/worker", { method: "POST", body: JSON.stringify({ text }) }),
|
||||
ingestJob: (job: unknown) => request("/poc/ingest/job", { method: "POST", body: JSON.stringify({ job }) }),
|
||||
ingestWorker: (worker: unknown) => request("/poc/ingest/worker", { method: "POST", body: JSON.stringify({ worker }) }),
|
||||
bootstrap: () => request("/poc/ingest/bootstrap", { method: "POST" }),
|
||||
health: () => request<unknown>("/health"),
|
||||
extractJob: (text: string) =>
|
||||
request<ExtractResponse<Record<string, unknown>>>("/poc/extract/job", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ text })
|
||||
}),
|
||||
extractWorker: (text: string) =>
|
||||
request<ExtractResponse<Record<string, unknown>>>("/poc/extract/worker", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ text })
|
||||
}),
|
||||
ingestJob: (job: unknown) => request<unknown>("/poc/ingest/job", { method: "POST", body: JSON.stringify({ job }) }),
|
||||
ingestWorker: (worker: unknown) =>
|
||||
request<unknown>("/poc/ingest/worker", { method: "POST", body: JSON.stringify({ worker }) }),
|
||||
bootstrap: () => request<unknown>("/poc/ingest/bootstrap", { method: "POST" }),
|
||||
matchWorkers: (job: unknown, top_n = 10) =>
|
||||
request("/poc/match/workers", { method: "POST", body: JSON.stringify({ job, top_n }) }),
|
||||
request<MatchResponse<Record<string, unknown>>>("/poc/match/workers", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ job, top_n })
|
||||
}),
|
||||
matchJobs: (worker: unknown, top_n = 10) =>
|
||||
request("/poc/match/jobs", { method: "POST", body: JSON.stringify({ worker, top_n }) }),
|
||||
jobs: () => request("/poc/jobs"),
|
||||
workers: () => request("/poc/workers"),
|
||||
job: (jobId: string) => request(`/poc/jobs/${jobId}`),
|
||||
worker: (workerId: string) => request(`/poc/workers/${workerId}`)
|
||||
request<MatchResponse<Record<string, unknown>>>("/poc/match/jobs", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ worker, top_n })
|
||||
}),
|
||||
jobs: () => request<ListResponse<Record<string, unknown>>>("/poc/jobs"),
|
||||
workers: () => request<ListResponse<Record<string, unknown>>>("/poc/workers"),
|
||||
job: (jobId: string) => request<Record<string, unknown>>(`/poc/jobs/${jobId}`),
|
||||
worker: (workerId: string) => request<Record<string, unknown>>(`/poc/workers/${workerId}`)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user