Spaces:
Running
Running
Update chat_demo.py
Browse files- chat_demo.py +9 -6
chat_demo.py
CHANGED
@@ -33,7 +33,7 @@ def start_server(command):
|
|
33 |
|
34 |
return process
|
35 |
|
36 |
-
server_process = start_server(["./llama.cpp/build/bin/llama-server", "-m" ,"./llama.cpp/build/ERNIE-4.5-0.3B-PT-UD-Q8_K_XL.gguf", "-c", "32000", "--jinja", "--no-mmap", "--port", "5100"])
|
37 |
|
38 |
|
39 |
cli = OpenAI(api_key="sk-nokey", base_url=BASE_URL)
|
@@ -93,9 +93,11 @@ with gr.Blocks() as demo:
|
|
93 |
#download=gr.DownloadButton(label="Download Conversation", value=None)
|
94 |
conv_state = gr.State()
|
95 |
orig_path = gr.State()
|
|
|
96 |
chat = gr.ChatInterface(
|
97 |
openai_call,
|
98 |
type="messages",
|
|
|
99 |
additional_inputs=[
|
100 |
gr.Textbox("You are a helpful AI assistant.", label="System Prompt"),
|
101 |
gr.Slider(30, 8192, value=2048, label="Max new tokens"),
|
@@ -104,11 +106,12 @@ with gr.Blocks() as demo:
|
|
104 |
title="Edge level LLM Chat demo",
|
105 |
description="In this demo, you can chat with sub-1B param range LLM - they are small enough to run with reasonable speed on most end user device. **Warning:** Do not input sensitive info - assume everything is public!"
|
106 |
)
|
107 |
-
|
108 |
-
|
109 |
-
.
|
110 |
-
|
111 |
-
|
|
|
112 |
|
113 |
try:
|
114 |
demo.queue(max_size=10, api_open=True).launch(server_name='0.0.0.0')
|
|
|
33 |
|
34 |
return process
|
35 |
|
36 |
+
server_process = start_server(["./llama.cpp/build/bin/llama-server", "-m" ,"./llama.cpp/build/ERNIE-4.5-0.3B-PT-UD-Q8_K_XL.gguf", "-c", "32000", "--jinja", "--no-mmap", "--port", "5100", "--threads", "2"])
|
37 |
|
38 |
|
39 |
cli = OpenAI(api_key="sk-nokey", base_url=BASE_URL)
|
|
|
93 |
#download=gr.DownloadButton(label="Download Conversation", value=None)
|
94 |
conv_state = gr.State()
|
95 |
orig_path = gr.State()
|
96 |
+
chatbot = gr.Chatbot(placeholder="Have fun with the AI!")
|
97 |
chat = gr.ChatInterface(
|
98 |
openai_call,
|
99 |
type="messages",
|
100 |
+
chatbot=chatbot,
|
101 |
additional_inputs=[
|
102 |
gr.Textbox("You are a helpful AI assistant.", label="System Prompt"),
|
103 |
gr.Slider(30, 8192, value=2048, label="Max new tokens"),
|
|
|
106 |
title="Edge level LLM Chat demo",
|
107 |
description="In this demo, you can chat with sub-1B param range LLM - they are small enough to run with reasonable speed on most end user device. **Warning:** Do not input sensitive info - assume everything is public!"
|
108 |
)
|
109 |
+
with gr.Accordion("Export Conversations"):
|
110 |
+
download_file = gr.File()
|
111 |
+
download_btn = gr.Button("Export Conversation for Download") \
|
112 |
+
.click(fn=gen_file, inputs=[conv_state], outputs=[download_file, orig_path]) \
|
113 |
+
.success(fn=clean_file, inputs=[orig_path])
|
114 |
+
download_file.download(on_download, None, None)
|
115 |
|
116 |
try:
|
117 |
demo.queue(max_size=10, api_open=True).launch(server_name='0.0.0.0')
|