File size: 645 Bytes
b8a907e 67780da b8a907e 67780da b8a907e e0b6fc3 61d0503 ff2c49e 61d0503 f17241e 454db78 67780da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from fastapi import FastAPI
import asyncio
from Linlada import Chatbot, ConversationStyle
app = FastAPI()
async def generate(prompt):
bot = await Chatbot.create()
result = await bot.ask(prompt=prompt, conversation_style=ConversationStyle.precise)
return result
@app.get("/")
def read_root():
return "Hello, I'm Linlada"
@app.get("/test/{hello}")
def hi(hello: str):
return {"text": Hello}
@app.get('/linlada/{prompt}')
def generate_image_route(prompt: str):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
result = loop.run_until_complete(generate(prompt))
loop.close()
return result |