Update main.py
Browse files
main.py
CHANGED
|
@@ -25,16 +25,16 @@ pipe.safety_checker = dummy
|
|
| 25 |
def hello():
|
| 26 |
return "Hello, I'm Artist"
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
for message in response:
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
@app.get("/gen/{prompt}")
|
| 35 |
-
def generate_image(prompt: str):
|
| 36 |
-
loop = asyncio.new_event_loop()
|
| 37 |
-
asyncio.set_event_loop(loop)
|
| 38 |
-
result = loop.run_until_complete(generate(prompt))
|
| 39 |
-
loop.close()
|
| 40 |
return result
|
|
|
|
| 25 |
def hello():
|
| 26 |
return "Hello, I'm Artist"
|
| 27 |
|
| 28 |
+
@app.post('/generate_completion')
|
| 29 |
+
async def generate_completion(
|
| 30 |
+
model: str = Query('gpt-4', description='The model to use for generating the completion'),
|
| 31 |
+
messages: List[Dict[str, str]] = Query(..., description='The list of messages to generate the completion for'),
|
| 32 |
+
stream: bool = Query(False, description='Whether to stream the response')
|
| 33 |
+
):
|
| 34 |
+
response = index._create_completion(model=model, messages=messages, stream=stream)
|
| 35 |
+
|
| 36 |
+
result = []
|
| 37 |
for message in response:
|
| 38 |
+
result.append(message)
|
| 39 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
return result
|