Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import re
|
3 |
import logging
|
@@ -11,7 +41,7 @@ openai.api_key = os.environ.get("OPENAI_API_KEY")
|
|
11 |
BASE_SYSTEM_MESSAGE = """"""
|
12 |
|
13 |
def make_prediction(prompt, max_tokens=None, temperature=None, top_p=None, top_k=None, repetition_penalty=None):
|
14 |
-
completion = openai.Completion.create(model="wizardcoder-python-34b-v1.0.Q5_K_M.gguf", prompt=prompt, max_tokens=max_tokens, temperature=temperature, top_p=top_p, top_k=top_k, repetition_penalty=repetition_penalty, stream=True, stop=["</s>", "<|im_end|>"])
|
15 |
for chunk in completion:
|
16 |
yield chunk["choices"][0]["text"]
|
17 |
|
@@ -68,6 +98,8 @@ CSS ="""
|
|
68 |
.gradio-container { height: 100vh !important; }
|
69 |
#component-0 { height: 100%; }
|
70 |
#chatbot { flex-grow: 1; overflow: auto; resize: vertical; }
|
|
|
|
|
71 |
"""
|
72 |
|
73 |
#with gr.Blocks() as demo:
|
@@ -80,8 +112,11 @@ with gr.Blocks(css=CSS) as demo:
|
|
80 |
with gr.Row():
|
81 |
gr.Markdown("# π WizardCoder-Python-34B-V1.0-GGUF Playground Space! π")
|
82 |
with gr.Row():
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
with gr.Row():
|
86 |
message = gr.Textbox(
|
87 |
label="What do you want to chat about?",
|
@@ -106,13 +141,15 @@ with gr.Blocks(css=CSS) as demo:
|
|
106 |
|
107 |
chat_history_state = gr.State()
|
108 |
clear.click(clear_chat, inputs=[chat_history_state, message], outputs=[chat_history_state, message], queue=False)
|
109 |
-
clear.click(lambda: None, None,
|
|
|
110 |
|
111 |
submit_click_event = submit.click(
|
112 |
fn=user, inputs=[message, chat_history_state], outputs=[message, chat_history_state], queue=True
|
113 |
).then(
|
114 |
-
fn=chat, inputs=[chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty], outputs=[
|
115 |
)
|
116 |
stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event], queue=False)
|
117 |
|
118 |
demo.queue(max_size=48, concurrency_count=8).launch(debug=True, server_name="0.0.0.0", server_port=7860)
|
|
|
|
1 |
+
|
2 |
+
Hugging Face's logo Hugging Face
|
3 |
+
|
4 |
+
Models
|
5 |
+
Datasets
|
6 |
+
Spaces
|
7 |
+
Docs
|
8 |
+
Pricing
|
9 |
+
|
10 |
+
Spaces:
|
11 |
+
bleysg
|
12 |
+
/
|
13 |
+
WizardCoder-Python-34b-v1.0
|
14 |
+
private
|
15 |
+
App
|
16 |
+
Files
|
17 |
+
Community
|
18 |
+
Settings
|
19 |
+
WizardCoder-Python-34b-v1.0
|
20 |
+
/ app.py
|
21 |
+
bleysg's picture
|
22 |
+
bleysg
|
23 |
+
Update app.py
|
24 |
+
7a84795
|
25 |
+
about 1 hour ago
|
26 |
+
raw
|
27 |
+
history
|
28 |
+
blame
|
29 |
+
No virus
|
30 |
+
5.52 kB
|
31 |
import os
|
32 |
import re
|
33 |
import logging
|
|
|
41 |
BASE_SYSTEM_MESSAGE = """"""
|
42 |
|
43 |
def make_prediction(prompt, max_tokens=None, temperature=None, top_p=None, top_k=None, repetition_penalty=None):
|
44 |
+
completion = openai.Completion.create(model="/workspace/text-generation-webui/models/wizardcoder-python-34b-v1.0.Q5_K_M.gguf", prompt=prompt, max_tokens=max_tokens, temperature=temperature, top_p=top_p, top_k=top_k, repetition_penalty=repetition_penalty, stream=True, stop=["</s>", "<|im_end|>"])
|
45 |
for chunk in completion:
|
46 |
yield chunk["choices"][0]["text"]
|
47 |
|
|
|
98 |
.gradio-container { height: 100vh !important; }
|
99 |
#component-0 { height: 100%; }
|
100 |
#chatbot { flex-grow: 1; overflow: auto; resize: vertical; }
|
101 |
+
#chatbot1 { flex-grow: 1; overflow: auto; resize: vertical; }
|
102 |
+
#chatbot2 { flex-grow: 1; overflow: auto; resize: vertical; }
|
103 |
"""
|
104 |
|
105 |
#with gr.Blocks() as demo:
|
|
|
112 |
with gr.Row():
|
113 |
gr.Markdown("# π WizardCoder-Python-34B-V1.0-GGUF Playground Space! π")
|
114 |
with gr.Row():
|
115 |
+
with gr.Column():
|
116 |
+
#chatbot = gr.Chatbot().style(height=500)
|
117 |
+
chatbot1 = gr.Chatbot(label="Chatbot1", elem_id="chatbot1")
|
118 |
+
with gr.Column():
|
119 |
+
chatbot2 = gr.Chatbot(label="Chatbot2", elem_id="chatbot2")
|
120 |
with gr.Row():
|
121 |
message = gr.Textbox(
|
122 |
label="What do you want to chat about?",
|
|
|
141 |
|
142 |
chat_history_state = gr.State()
|
143 |
clear.click(clear_chat, inputs=[chat_history_state, message], outputs=[chat_history_state, message], queue=False)
|
144 |
+
clear.click(lambda: None, None, chatbot_gguf, queue=False)
|
145 |
+
clear.click(lambda: None, None, chatbot_gguf2, queue=False)
|
146 |
|
147 |
submit_click_event = submit.click(
|
148 |
fn=user, inputs=[message, chat_history_state], outputs=[message, chat_history_state], queue=True
|
149 |
).then(
|
150 |
+
fn=chat, inputs=[chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty], outputs=[chatbot_gguf, chat_history_state, message], queue=True
|
151 |
)
|
152 |
stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event], queue=False)
|
153 |
|
154 |
demo.queue(max_size=48, concurrency_count=8).launch(debug=True, server_name="0.0.0.0", server_port=7860)
|
155 |
+
|