Fastapi 에서 Jina async Client 사용

yslee·2023년 5월 22일
0
from fastapi import FastAPI
from jina import Client, Document


app = FastAPI()

client = Client(host="localhost:8087", asyncio=True)


@app.get("/")
async def test(prompt: str = ""):
    async for response in client.post(
        on="/predict/embedding/prompts", inputs=Document(text=prompt)
    ):
        return response[0].embedding.tolist()


import uvicorn


if __name__ == "__main__":
    uvicorn.run(app, port=8888)

response = client.post(...)async for response in client.post(...) 래핑해서 사용

profile
지식보다 지혜를

0개의 댓글

Powered by GraphCDN, the GraphQL CDN