Spaces:
Runtime error
Runtime error
Chaow Wu commited on
Commit ·
0f1d1a4
1
Parent(s): 7007853
fuck perisaaaa
Browse files
app.py
CHANGED
|
@@ -1,7 +1,27 @@
|
|
| 1 |
from h2o_wave import main, app, Q, ui, data
|
| 2 |
from gradio_client import Client
|
| 3 |
import ast
|
| 4 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
async def init_ui(q: Q) -> None:
|
|
@@ -63,7 +83,7 @@ async def serve(q: Q):
|
|
| 63 |
# Append bot response.
|
| 64 |
kwargs = dict(instruction_nochat=q.args.chatbot)
|
| 65 |
try:
|
| 66 |
-
history =
|
| 67 |
bot_res = history["visible"][-1][-1]
|
| 68 |
q.page['chatbot'].data += [bot_res, False]
|
| 69 |
except:
|
|
|
|
| 1 |
from h2o_wave import main, app, Q, ui, data
|
| 2 |
from gradio_client import Client
|
| 3 |
import ast
|
| 4 |
+
import requests
|
| 5 |
+
import json
|
| 6 |
+
import html
|
| 7 |
+
# For local streaming, the websockets are hosted without ssl - http://
|
| 8 |
+
HOST = '127.0.0.1:5000'
|
| 9 |
+
|
| 10 |
+
URI = f'https://proper-good-twisted-results.trycloudflare.com/api/v1/chat'
|
| 11 |
+
#URI = f'http://127.0.0.1:5000/api/v1/chat'
|
| 12 |
+
def run(user_input, history):
|
| 13 |
+
request = {
|
| 14 |
+
'user_input': user_input,
|
| 15 |
+
'history': history,
|
| 16 |
+
'max_new_tokens': 810,
|
| 17 |
+
'presets': 'simple-1'
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
response = requests.post(URI, json=request)
|
| 21 |
+
if response.status_code == 200:
|
| 22 |
+
result = response.json()['results'][0]['history']
|
| 23 |
+
return history
|
| 24 |
+
|
| 25 |
|
| 26 |
|
| 27 |
async def init_ui(q: Q) -> None:
|
|
|
|
| 83 |
# Append bot response.
|
| 84 |
kwargs = dict(instruction_nochat=q.args.chatbot)
|
| 85 |
try:
|
| 86 |
+
history = run(q.args.charbot, history)
|
| 87 |
bot_res = history["visible"][-1][-1]
|
| 88 |
q.page['chatbot'].data += [bot_res, False]
|
| 89 |
except:
|