Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ from huggingface_hub import hf_hub_download #load from huggingfaces
|
|
| 9 |
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-m2.0-GGML", filename="airoboros-l2-13b-gpt4-m2.0.ggmlv3.q6_K.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
|
| 10 |
|
| 11 |
history = []
|
| 12 |
-
h = []
|
| 13 |
history.append(["Hi there!", "Hello, how can I help you?"])
|
| 14 |
|
| 15 |
def generate_text(input_text, history):
|
|
@@ -20,30 +19,26 @@ def generate_text(input_text, history):
|
|
| 20 |
response = output['choices'][0]['text']
|
| 21 |
history.append([input_text, response])
|
| 22 |
|
| 23 |
-
return "",
|
| 24 |
-
|
| 25 |
-
def bot(history):
|
| 26 |
-
bot_message = history
|
| 27 |
-
h[-1][1] = ""
|
| 28 |
-
for character in bot_message:
|
| 29 |
-
history[-1][1] += character
|
| 30 |
-
time.sleep(0.05)
|
| 31 |
-
yield h
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
with gr.Blocks() as demo:
|
| 35 |
chatbot = gr.Chatbot()
|
| 36 |
msg = gr.Textbox()
|
| 37 |
clear = gr.ClearButton([msg, chatbot])
|
| 38 |
|
| 39 |
-
|
| 40 |
bot, chatbot, chatbot
|
| 41 |
)
|
| 42 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
| 43 |
|
|
|
|
| 44 |
demo.launch()
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 9 |
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-m2.0-GGML", filename="airoboros-l2-13b-gpt4-m2.0.ggmlv3.q6_K.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
|
| 10 |
|
| 11 |
history = []
|
|
|
|
| 12 |
history.append(["Hi there!", "Hello, how can I help you?"])
|
| 13 |
|
| 14 |
def generate_text(input_text, history):
|
|
|
|
| 19 |
response = output['choices'][0]['text']
|
| 20 |
history.append([input_text, response])
|
| 21 |
|
| 22 |
+
return "", response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
def bot(response):
|
| 25 |
+
history[-1][1] = ""
|
| 26 |
+
for character in response:
|
| 27 |
+
history[-1][1] += character
|
| 28 |
+
time.sleep(0.05)
|
| 29 |
+
yield history
|
| 30 |
|
| 31 |
with gr.Blocks() as demo:
|
| 32 |
chatbot = gr.Chatbot()
|
| 33 |
msg = gr.Textbox()
|
| 34 |
clear = gr.ClearButton([msg, chatbot])
|
| 35 |
|
| 36 |
+
msg.submit(generate_text, [msg, chatbot], [msg, chatbot], queue=False).then(
|
| 37 |
bot, chatbot, chatbot
|
| 38 |
)
|
|
|
|
| 39 |
|
| 40 |
+
demo.queue()
|
| 41 |
demo.launch()
|
| 42 |
|
| 43 |
|
| 44 |
|
|
|
|
|
|