ex510 commited on
Commit
2f03c22
·
verified ·
1 Parent(s): d012f83

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -2
main.py CHANGED
@@ -38,6 +38,10 @@ app = FastAPI(
38
 
39
  class TextRequest(BaseModel):
40
  text: str = Field(..., min_length=1, description="Text to embed")
 
 
 
 
41
 
42
  async def send_to_webhook(url: str, data: dict):
43
  """Sends data to a webhook URL asynchronously."""
@@ -97,7 +101,8 @@ async def embed_text(request: TextRequest, background_tasks: BackgroundTasks):
97
  if webhook_url:
98
  payload = {
99
  "text": request.text,
100
- "embedding": embedding
 
101
  }
102
  background_tasks.add_task(send_to_webhook, webhook_url, payload)
103
 
@@ -111,4 +116,4 @@ async def embed_text(request: TextRequest, background_tasks: BackgroundTasks):
111
  raise HTTPException(status_code=500, detail=str(e))
112
 
113
  if __name__ == "__main__":
114
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
38
 
39
  class TextRequest(BaseModel):
40
  text: str = Field(..., min_length=1, description="Text to embed")
41
+ request_id: str | None = Field(None, description="Optional unique identifier for the request")
42
+
43
+
44
+
45
 
46
  async def send_to_webhook(url: str, data: dict):
47
  """Sends data to a webhook URL asynchronously."""
 
101
  if webhook_url:
102
  payload = {
103
  "text": request.text,
104
+ "embedding": embedding,
105
+ "request_id": request.request_id
106
  }
107
  background_tasks.add_task(send_to_webhook, webhook_url, payload)
108
 
 
116
  raise HTTPException(status_code=500, detail=str(e))
117
 
118
  if __name__ == "__main__":
119
+ uvicorn.run(app, host="0.0.0.0", port=7860)