Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import time
|
3 |
import ctypes #to run on C api directly
|
4 |
import llama_cpp
|
@@ -19,16 +20,13 @@ def generate_text(input_text, history):
|
|
19 |
input_text_with_history = history[-1][1]+ "\n"
|
20 |
input_text_with_history += f"Q: {input_text} \n A:"
|
21 |
print("new input", input_text_with_history)
|
22 |
-
output = llm(input_text_with_history, max_tokens=1024, stop=["Q:", "\n"],
|
23 |
response = output['choices'][0]['text'] + "\n"
|
24 |
print("response", response)
|
25 |
history =["init",input_text_with_history]
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
33 |
demo = gr.ChatInterface(generate_text)
|
34 |
demo.queue(concurrency_count=1, max_size=5)
|
@@ -36,3 +34,4 @@ demo.launch()
|
|
36 |
|
37 |
|
38 |
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import jason
|
3 |
import time
|
4 |
import ctypes #to run on C api directly
|
5 |
import llama_cpp
|
|
|
20 |
input_text_with_history = history[-1][1]+ "\n"
|
21 |
input_text_with_history += f"Q: {input_text} \n A:"
|
22 |
print("new input", input_text_with_history)
|
23 |
+
output = llm(input_text_with_history, max_tokens=1024, stop=["Q:", "\n"], stream=True)
|
24 |
response = output['choices'][0]['text'] + "\n"
|
25 |
print("response", response)
|
26 |
history =["init",input_text_with_history]
|
27 |
+
return response
|
28 |
+
for out in output
|
29 |
+
print(jason.dump(out, indent=2))
|
|
|
|
|
|
|
30 |
|
31 |
demo = gr.ChatInterface(generate_text)
|
32 |
demo.queue(concurrency_count=1, max_size=5)
|
|
|
34 |
|
35 |
|
36 |
|
37 |
+
|