ChemApi / main.py
ka1kuk's picture
Update main.py
f17241e
raw
history blame
645 Bytes
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