Rendering an image in the response
from typing import AsyncIterable
from modal import Image, Stub, asgi_app
import fastapi_poe as fp
IMAGE_URL = "https://images.pexels.com/photos/46254/leopard-wildcat-big-cat-botswana-46254.jpeg"
class SampleImageResponseBot(fp.PoeBot):
async def get_response(
self, request: fp.QueryRequest
) -> AsyncIterable[fp.PartialResponse]:
yield fp.PartialResponse(text=f"This is a test image. ")
REQUIREMENTS = ["fastapi-poe==0.0.24"]
image = Image.debian_slim().pip_install(*REQUIREMENTS)
stub = Stub("image-response-poe")
@stub.function(image=image)
@asgi_app()
def fastapi_app():
bot = SampleImageResponseBot()
app = fp.make_app(bot, allow_without_key=True)
return app
Last updated