File size: 853 Bytes
8b90ad5
ecd9090
82d866a
ecd9090
2eb1363
967efaf
 
0250d76
 
 
 
 
 
 
 
fac22d0
fce8087
b9c73b1
696db06
654794a
 
82d866a
32b76d6
82d866a
 
 
 
45779b7
 
32b76d6
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
27
28
29
30
31
import Linlada
from fastapi import FastAPI
import asyncio
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

app.add_middleware(  # add the middleware
    CORSMiddleware,
    allow_credentials=True,  # allow credentials
    allow_origins=["*"],  # allow all origins
    allow_methods=["*"],  # allow all methods
    allow_headers=["*"],  # allow all headers
)

@app.get("/")
def hello():
    return "Hello, I'm Artist"

def generate(prompt):
        response =  Linlada._create_completion(model='gpt-4', messages=[
                                        {"role": "user", "content": prompt}], stream=True)
        chat = list(response)
        sentence = ''.join(chat)        
        return sentence    

@app.get('/linlada/{prompt}')
async def generate_image_route(prompt: str):
    result = await generate(prompt)
    return result