Update main.py
Browse files
main.py
CHANGED
|
@@ -1,11 +1,22 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
|
|
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
@app.get("/")
|
| 6 |
def read_root():
|
| 7 |
return "Hello, I'm Linlada"
|
| 8 |
|
| 9 |
-
@app.get(
|
| 10 |
-
def
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
import asyncio
|
| 3 |
+
from Linlada import Chatbot, ConversationStyle
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
+
async def generate(prompt):
|
| 8 |
+
bot = await Chatbot.create()
|
| 9 |
+
result = await bot.ask(prompt=prompt, conversation_style=ConversationStyle.precise)
|
| 10 |
+
return result
|
| 11 |
+
|
| 12 |
@app.get("/")
|
| 13 |
def read_root():
|
| 14 |
return "Hello, I'm Linlada"
|
| 15 |
|
| 16 |
+
@app.get('/linlada/{prompt}')
|
| 17 |
+
def generate_image_route(prompt: str):
|
| 18 |
+
loop = asyncio.new_event_loop()
|
| 19 |
+
asyncio.set_event_loop(loop)
|
| 20 |
+
result = loop.run_until_complete(generate(prompt))
|
| 21 |
+
loop.close()
|
| 22 |
+
return result
|