Merge pull request #5247 from open-webui/dev

refac: enable /api/embed
This commit is contained in:
Timothy Jaeryang Baek 2024-09-07 06:13:02 +02:00 committed by GitHub
commit 71a2bd2fea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -543,6 +543,8 @@ class GenerateEmbeddingsForm(BaseModel):
keep_alive: Optional[Union[int, str]] = None keep_alive: Optional[Union[int, str]] = None
@app.post("/api/embed")
@app.post("/api/embed/{url_idx}")
@app.post("/api/embeddings") @app.post("/api/embeddings")
@app.post("/api/embeddings/{url_idx}") @app.post("/api/embeddings/{url_idx}")
async def generate_embeddings( async def generate_embeddings(
@ -569,7 +571,7 @@ async def generate_embeddings(
r = requests.request( r = requests.request(
method="POST", method="POST",
url=f"{url}/api/embeddings", url=f"{url}/api/embed",
headers={"Content-Type": "application/json"}, headers={"Content-Type": "application/json"},
data=form_data.model_dump_json(exclude_none=True).encode(), data=form_data.model_dump_json(exclude_none=True).encode(),
) )