Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,11 @@ hf_hub_download(repo_id="TheBloke/Mistral-7B-Instruct-v0.1-GGUF", local_dir=".",
|
|
50 |
mistral_model_path="./mistral-7b-instruct-v0.1.Q5_K_M.gguf"
|
51 |
mistral_llm = Llama(model_path=mistral_model_path,n_gpu_layers=35,max_new_tokens=256, context_window=4096, n_ctx=4096,n_batch=128,verbose=False)
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
# Load XTTS Model
|
55 |
print("Loading XTTS model")
|
@@ -71,13 +76,13 @@ xtts_model.cuda()
|
|
71 |
|
72 |
###### Set up Gradio Interface ######
|
73 |
|
74 |
-
with gr.Blocks(title="Voice chat with
|
75 |
-
DESCRIPTION = """# Voice chat with
|
76 |
gr.Markdown(DESCRIPTION)
|
77 |
|
78 |
# Define chatbot component
|
79 |
chatbot = gr.Chatbot(
|
80 |
-
value=[(None, "Hi friend, I'm
|
81 |
elem_id="chatbot",
|
82 |
avatar_images=("examples/hf-logo.png", "examples/ai-chat-logo.png"),
|
83 |
bubble_full_width=False,
|
@@ -152,7 +157,7 @@ with gr.Blocks(title="Voice chat with LLM") as demo:
|
|
152 |
yield from handle_speech_generation(sentence, chatbot_history, chatbot_voice)
|
153 |
else:
|
154 |
# Continuously get and process sentences from a generator function
|
155 |
-
for sentence, chatbot_history in get_sentence(chatbot_history,
|
156 |
print("Inserting sentence to queue")
|
157 |
yield from handle_speech_generation(sentence, chatbot_history, chatbot_voice)
|
158 |
|
@@ -170,6 +175,7 @@ with gr.Blocks(title="Voice chat with LLM") as demo:
|
|
170 |
This Space demonstrates how to speak to an llm chatbot, based solely on open accessible models.
|
171 |
It relies on the following models :
|
172 |
- Speech to Text Model: [Faster-Whisper-large-v3](https://huggingface.co/Systran/faster-whisper-large-v3) an ASR model, to transcribe recorded audio to text.
|
|
|
173 |
- Large Language Model: [Mistral-7b-instruct-v0.1-quantized](https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF) a LLM to generate the chatbot responses.
|
174 |
- Text to Speech Model: [XTTS-v2](https://huggingface.co/spaces/coqui/xtts) a TTS model, to generate the voice of the chatbot.
|
175 |
|
|
|
50 |
mistral_model_path="./mistral-7b-instruct-v0.1.Q5_K_M.gguf"
|
51 |
mistral_llm = Llama(model_path=mistral_model_path,n_gpu_layers=35,max_new_tokens=256, context_window=4096, n_ctx=4096,n_batch=128,verbose=False)
|
52 |
|
53 |
+
# Load Saul-Instruct-v1-GGUF.Q4_K_M
|
54 |
+
print("Loading Saul-Instruct-v1-GGUF.Q4_K_M")
|
55 |
+
hf_hub_download(repo_id="MaziyarPanahi/Saul-Instruct-v1-GGUF", local_dir=".", filename="Saul-Instruct-v1-GGUF.Q4_K_M.gguf")
|
56 |
+
saul_model_path="./Saul-Instruct-v1-GGUF.Q4_K_M.gguf"
|
57 |
+
saul_instruct_llm = Llama(model_path=saul_model_path,n_gpu_layers=35,max_new_tokens=256, context_window=4096, n_ctx=32768,n_batch=128,verbose=False)
|
58 |
|
59 |
# Load XTTS Model
|
60 |
print("Loading XTTS model")
|
|
|
76 |
|
77 |
###### Set up Gradio Interface ######
|
78 |
|
79 |
+
with gr.Blocks(title="Voice chat with Saul-Instruct-v1-GGUF") as demo:
|
80 |
+
DESCRIPTION = """# Voice chat with Saul-Instruct-v1-GGUF"""
|
81 |
gr.Markdown(DESCRIPTION)
|
82 |
|
83 |
# Define chatbot component
|
84 |
chatbot = gr.Chatbot(
|
85 |
+
value=[(None, "Hi friend, I'm you data protection assistant. How can I help you today?")], # Initial greeting from the chatbot
|
86 |
elem_id="chatbot",
|
87 |
avatar_images=("examples/hf-logo.png", "examples/ai-chat-logo.png"),
|
88 |
bubble_full_width=False,
|
|
|
157 |
yield from handle_speech_generation(sentence, chatbot_history, chatbot_voice)
|
158 |
else:
|
159 |
# Continuously get and process sentences from a generator function
|
160 |
+
for sentence, chatbot_history in get_sentence(chatbot_history, saul_instruct_llm):
|
161 |
print("Inserting sentence to queue")
|
162 |
yield from handle_speech_generation(sentence, chatbot_history, chatbot_voice)
|
163 |
|
|
|
175 |
This Space demonstrates how to speak to an llm chatbot, based solely on open accessible models.
|
176 |
It relies on the following models :
|
177 |
- Speech to Text Model: [Faster-Whisper-large-v3](https://huggingface.co/Systran/faster-whisper-large-v3) an ASR model, to transcribe recorded audio to text.
|
178 |
+
- Legal Large Language Model: [MaziyarPanahi/Saul-Instruct-v1-GGUF](https://huggingface.co/MaziyarPanahi/Saul-Instruct-v1-GGUF/blob/main/Saul-Instruct-v1.Q4_K_M.gguf) a LLM to generate legal chatbot responses.
|
179 |
- Large Language Model: [Mistral-7b-instruct-v0.1-quantized](https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF) a LLM to generate the chatbot responses.
|
180 |
- Text to Speech Model: [XTTS-v2](https://huggingface.co/spaces/coqui/xtts) a TTS model, to generate the voice of the chatbot.
|
181 |
|