Update app.py
Browse files
app.py
CHANGED
@@ -7,15 +7,14 @@ description = "This is a demo of Synthia 7B GGUF running on spaces cpu basic har
|
|
7 |
|
8 |
model_path = "models"
|
9 |
model_name = "synthia-7b-v2.0-16k.Q4_K_M.gguf"
|
10 |
-
hf_hub_download(repo_id="TheBloke/SynthIA-7B-v2.0-16k-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=False)
|
11 |
|
12 |
try:
|
13 |
-
model = GPT4All(
|
14 |
print("Model loaded successfully.")
|
15 |
except Exception as e:
|
16 |
print("Error loading the model:", str(e))
|
17 |
|
18 |
-
|
19 |
model.config["promptTemplate"] = "[INST] {0} [/INST]"
|
20 |
model.config["systemPrompt"] = ""
|
21 |
model._is_chat_session_activated = False
|
@@ -31,9 +30,7 @@ def generater(message, history, temperature, top_p, top_k):
|
|
31 |
outputs = []
|
32 |
for token in model.generate(prompt=prompt, temp=temperature, top_k = top_k, top_p = top_p, max_tokens = max_new_tokens, streaming=True):
|
33 |
outputs.append(token)
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
def vote(data: gr.LikeData):
|
39 |
if data.liked:
|
@@ -93,7 +90,7 @@ iface = gr.ChatInterface(
|
|
93 |
|
94 |
with gr.Blocks(css="resourse/style/custom.css") as demo:
|
95 |
chatbot.like(vote, None, None)
|
96 |
-
iface.
|
97 |
|
98 |
if __name__ == "__main__":
|
99 |
demo.queue(max_size=3).launch()
|
|
|
7 |
|
8 |
model_path = "models"
|
9 |
model_name = "synthia-7b-v2.0-16k.Q4_K_M.gguf"
|
10 |
+
model_path = hf_hub_download(repo_id="TheBloke/SynthIA-7B-v2.0-16k-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=False)
|
11 |
|
12 |
try:
|
13 |
+
model = GPT4All(model_path, allow_download=False, device="cpu")
|
14 |
print("Model loaded successfully.")
|
15 |
except Exception as e:
|
16 |
print("Error loading the model:", str(e))
|
17 |
|
|
|
18 |
model.config["promptTemplate"] = "[INST] {0} [/INST]"
|
19 |
model.config["systemPrompt"] = ""
|
20 |
model._is_chat_session_activated = False
|
|
|
30 |
outputs = []
|
31 |
for token in model.generate(prompt=prompt, temp=temperature, top_k = top_k, top_p = top_p, max_tokens = max_new_tokens, streaming=True):
|
32 |
outputs.append(token)
|
33 |
+
return "".join(outputs)
|
|
|
|
|
34 |
|
35 |
def vote(data: gr.LikeData):
|
36 |
if data.liked:
|
|
|
90 |
|
91 |
with gr.Blocks(css="resourse/style/custom.css") as demo:
|
92 |
chatbot.like(vote, None, None)
|
93 |
+
iface.launch()
|
94 |
|
95 |
if __name__ == "__main__":
|
96 |
demo.queue(max_size=3).launch()
|