diff --git a/api/ingest.py b/api/ingest.py index e984072f..ba8c1753 100644 --- a/api/ingest.py +++ b/api/ingest.py @@ -1,9 +1,12 @@ +import requests + from typing import Dict from fastapi import APIRouter, Depends from models.ingest import RequestPayload from service.embedding import EmbeddingService from auth.user import get_current_api_user + router = APIRouter() @@ -19,4 +22,10 @@ async def ingest( documents = await embedding_service.generate_documents() chunks = await embedding_service.generate_chunks(documents=documents) await embedding_service.generate_embeddings(nodes=chunks) + + if payload.webhook_url: + requests.post( + url=payload.webhook_url, + json={"index_name": payload.index_name, "status": "completed"}, + ) return {"success": True} diff --git a/models/ingest.py b/models/ingest.py index a02c8037..7246d487 100644 --- a/models/ingest.py +++ b/models/ingest.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Optional from pydantic import BaseModel from models.file import File from models.vector_database import VectorDatabase @@ -8,3 +8,4 @@ class RequestPayload(BaseModel): files: List[File] vector_database: VectorDatabase index_name: str + webhook_url: Optional[str]