Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ DESCRIPTION = os.environ.get("DESCRIPTION")
|
|
| 25 |
DISCORD_WEBHOOK = os.environ.get("DISCORD_WEBHOOK")
|
| 26 |
TOKEN = os.environ.get("TOKEN")
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
def send_discord(i,o):
|
| 31 |
url = DISCORD_WEBHOOK
|
|
@@ -116,7 +116,7 @@ def predict(message, history, system_prompt, temperature, max_new_tokens, top_k,
|
|
| 116 |
send_discord(instruction, "".join(outputs))
|
| 117 |
|
| 118 |
|
| 119 |
-
|
| 120 |
day=datetime.now().strftime("%Y-%m-%d")
|
| 121 |
timestamp=datetime.now().timestamp()
|
| 122 |
dd={
|
|
@@ -162,25 +162,70 @@ async()=>{
|
|
| 162 |
}
|
| 163 |
"""
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
# Create Gradio interface
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
gr.
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
DISCORD_WEBHOOK = os.environ.get("DISCORD_WEBHOOK")
|
| 26 |
TOKEN = os.environ.get("TOKEN")
|
| 27 |
|
| 28 |
+
api = HfApi()
|
| 29 |
|
| 30 |
def send_discord(i,o):
|
| 31 |
url = DISCORD_WEBHOOK
|
|
|
|
| 116 |
send_discord(instruction, "".join(outputs))
|
| 117 |
|
| 118 |
|
| 119 |
+
|
| 120 |
day=datetime.now().strftime("%Y-%m-%d")
|
| 121 |
timestamp=datetime.now().timestamp()
|
| 122 |
dd={
|
|
|
|
| 162 |
}
|
| 163 |
"""
|
| 164 |
|
| 165 |
+
def vote(chatbot, data: gr.LikeData):
|
| 166 |
+
day=datetime.now().strftime("%Y-%m-%d")
|
| 167 |
+
timestamp=datetime.now().timestamp()
|
| 168 |
+
api.upload_file(
|
| 169 |
+
path_or_fileobj=json.dumps({"history":chatbot, 'index': data.index, 'liked': data.liked}, indent=2, ensure_ascii=False).encode('utf-8'),
|
| 170 |
+
path_in_repo=f"liked/{day}/{timestamp}.json",
|
| 171 |
+
repo_id="speakleash/bielik-logs",
|
| 172 |
+
repo_type="dataset",
|
| 173 |
+
commit_message=f"L",
|
| 174 |
+
token=TOKEN,
|
| 175 |
+
run_as_future=True
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
# Create Gradio interface
|
| 179 |
+
|
| 180 |
+
with gr.Blocks() as demo:
|
| 181 |
+
chatbot = gr.Chatbot(label="Chatbot", likeable=True, render=False)
|
| 182 |
+
chatbot.like(vote, [chatbot], None)
|
| 183 |
+
gr.ChatInterface(
|
| 184 |
+
predict,
|
| 185 |
+
chatbot=chatbot,
|
| 186 |
+
title=EMOJI + " " + MODEL_NAME,
|
| 187 |
+
description=DESCRIPTION,
|
| 188 |
+
examples=[
|
| 189 |
+
["Kim jeste艣?"],
|
| 190 |
+
["Ile to jest 9+2-1?"],
|
| 191 |
+
["Napisz mi co艣 mi艂ego."]
|
| 192 |
+
],
|
| 193 |
+
additional_inputs_accordion=gr.Accordion(label="鈿欙笍 Parameters", open=False, render=False),
|
| 194 |
+
additional_inputs=[
|
| 195 |
+
gr.Textbox("", label="System prompt", render=False),
|
| 196 |
+
gr.Slider(0, 1, 0.6, label="Temperature", render=False),
|
| 197 |
+
gr.Slider(128, 4096, 1024, label="Max new tokens", render=False),
|
| 198 |
+
gr.Slider(1, 80, 40, label="Top K sampling", render=False),
|
| 199 |
+
gr.Slider(0, 2, 1.1, label="Repetition penalty", render=False),
|
| 200 |
+
gr.Slider(0, 1, 0.95, label="Top P sampling", render=False),
|
| 201 |
+
],
|
| 202 |
+
theme=gr.themes.Soft(primary_hue=COLOR),
|
| 203 |
+
js=on_load,
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
demo.queue().launch()
|
| 207 |
+
|
| 208 |
+
# chatbot = gr.Chatbot(label="Chatbot", likeable=True)
|
| 209 |
+
# chatbot.like(vote, None, None)
|
| 210 |
+
# gr.ChatInterface(
|
| 211 |
+
# predict,
|
| 212 |
+
# chatbot=chatbot,
|
| 213 |
+
# title=EMOJI + " " + MODEL_NAME,
|
| 214 |
+
# description=DESCRIPTION,
|
| 215 |
+
# examples=[
|
| 216 |
+
# ["Kim jeste艣?"],
|
| 217 |
+
# ["Ile to jest 9+2-1?"],
|
| 218 |
+
# ["Napisz mi co艣 mi艂ego."]
|
| 219 |
+
# ],
|
| 220 |
+
# additional_inputs_accordion=gr.Accordion(label="鈿欙笍 Parameters", open=False),
|
| 221 |
+
# additional_inputs=[
|
| 222 |
+
# gr.Textbox("", label="System prompt"),
|
| 223 |
+
# gr.Slider(0, 1, 0.6, label="Temperature"),
|
| 224 |
+
# gr.Slider(128, 4096, 1024, label="Max new tokens"),
|
| 225 |
+
# gr.Slider(1, 80, 40, label="Top K sampling"),
|
| 226 |
+
# gr.Slider(0, 2, 1.1, label="Repetition penalty"),
|
| 227 |
+
# gr.Slider(0, 1, 0.95, label="Top P sampling"),
|
| 228 |
+
# ],
|
| 229 |
+
# theme=gr.themes.Soft(primary_hue=COLOR),
|
| 230 |
+
# js=on_load,
|
| 231 |
+
# ).queue().launch()
|