Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webhooks #20

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]