Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import json
|
|
3 |
|
4 |
from fastapi import FastAPI
|
5 |
from fastapi.responses import StreamingResponse
|
|
|
6 |
from gradio_client import Client
|
7 |
|
8 |
app = FastAPI()
|
@@ -34,17 +35,21 @@ def make_chunk_obj(i, delta, fr):
|
|
34 |
]
|
35 |
}
|
36 |
|
37 |
-
@app.get('/
|
38 |
async def index():
|
|
|
|
|
|
|
|
|
39 |
def streamer():
|
40 |
text = ""
|
41 |
result = client.submit(
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
)
|
49 |
for i, item in enumerate(result):
|
50 |
delta = item[len(text):]
|
@@ -57,5 +62,3 @@ async def index():
|
|
57 |
yield "data: [END]"
|
58 |
|
59 |
return StreamingResponse(streamer())
|
60 |
-
|
61 |
-
print(result)
|
|
|
3 |
|
4 |
from fastapi import FastAPI
|
5 |
from fastapi.responses import StreamingResponse
|
6 |
+
|
7 |
from gradio_client import Client
|
8 |
|
9 |
app = FastAPI()
|
|
|
35 |
]
|
36 |
}
|
37 |
|
38 |
+
@app.get('/')
|
39 |
async def index():
|
40 |
+
return { "message": "hello" }
|
41 |
+
|
42 |
+
@app.post('/chat/completions')
|
43 |
+
async def c_cmp():
|
44 |
def streamer():
|
45 |
text = ""
|
46 |
result = client.submit(
|
47 |
+
"Hello!!",
|
48 |
+
0.9, # float (numeric value between 0.0 and 1.0) in 'Temperature' Slider component
|
49 |
+
4096, # float (numeric value between 0 and 1048) in 'Max new tokens' Slider component
|
50 |
+
.9, # float (numeric value between 0.0 and 1) in 'Top-p (nucleus sampling)' Slider component
|
51 |
+
1, # float (numeric value between 1.0 and 2.0) in 'Repetition penalty' Slider component
|
52 |
+
api_name="/chat"
|
53 |
)
|
54 |
for i, item in enumerate(result):
|
55 |
delta = item[len(text):]
|
|
|
62 |
yield "data: [END]"
|
63 |
|
64 |
return StreamingResponse(streamer())
|
|
|
|