Skip to content

Commit

Permalink
Add webhooks (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
homanp authored Jan 18, 2024
1 parent 6b9abc0 commit f36ffa5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions api/ingest.py
Original file line number Diff line number Diff line change
@@ -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()


Expand All @@ -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}
3 changes: 2 additions & 1 deletion models/ingest.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,3 +8,4 @@ class RequestPayload(BaseModel):
files: List[File]
vector_database: VectorDatabase
index_name: str
webhook_url: Optional[str]

0 comments on commit f36ffa5

Please sign in to comment.