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(...)
래핑해서 사용