Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,24 +11,16 @@ llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-
|
|
| 11 |
history = []
|
| 12 |
|
| 13 |
def generate_text(input_text, history):
|
| 14 |
-
|
| 15 |
conversation_context = " ".join([f"{pair[0]} {pair[1]}" for pair in history])
|
| 16 |
full_conversation = f"{conversation_context} Q: {input_text} \n A:"
|
| 17 |
-
|
| 18 |
output = llm(full_conversation, max_tokens=1024, stop=["Q:", "\n"], echo=True)
|
| 19 |
response = output['choices'][0]['text']
|
| 20 |
history.append([input_text, response])
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
|
| 27 |
-
with gr.Blocks() as demo:
|
| 28 |
-
chatbot = gr.Chatbot()
|
| 29 |
-
msg = gr.Textbox()
|
| 30 |
-
clear = gr.ClearButton([msg, chatbot])
|
| 31 |
-
|
| 32 |
demo = gr.ChatInterface(generate_text)
|
| 33 |
demo.queue(concurrency_count=1, max_size=5)
|
| 34 |
demo.launch()
|
|
|
|
| 11 |
history = []
|
| 12 |
|
| 13 |
def generate_text(input_text, history):
|
|
|
|
| 14 |
conversation_context = " ".join([f"{pair[0]} {pair[1]}" for pair in history])
|
| 15 |
full_conversation = f"{conversation_context} Q: {input_text} \n A:"
|
|
|
|
| 16 |
output = llm(full_conversation, max_tokens=1024, stop=["Q:", "\n"], echo=True)
|
| 17 |
response = output['choices'][0]['text']
|
| 18 |
history.append([input_text, response])
|
| 19 |
+
for i in range(len(output)):
|
| 20 |
+
time.sleep(0.3)
|
| 21 |
+
yield "You typed: " + output[: i+1]
|
|
|
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
demo = gr.ChatInterface(generate_text)
|
| 25 |
demo.queue(concurrency_count=1, max_size=5)
|
| 26 |
demo.launch()
|