Update app.py
Browse files
app.py
CHANGED
@@ -7,25 +7,27 @@ description = """
|
|
7 |
Is it really that good? Let's see... (Note: This is a Q4 gguf so thst I can run it on the free cpu. Clone and upgrade for a getter version)
|
8 |
"""
|
9 |
|
10 |
-
model_path = "TheBloke/
|
11 |
-
model_name = "
|
12 |
-
hf_hub_download(repo_id="TheBloke/
|
13 |
|
14 |
print("Start the model init process")
|
15 |
model = model = GPT4All(model_name, model_path, allow_download = True, device="cpu")
|
16 |
print("Finish the model init process")
|
17 |
|
18 |
-
model.config["promptTemplate"] = "
|
19 |
-
|
|
|
|
|
20 |
model._is_chat_session_activated = True
|
21 |
|
22 |
max_new_tokens = 2048
|
23 |
|
24 |
def generater(message, history, temperature, top_p, top_k):
|
25 |
-
prompt = "
|
26 |
for user_message, assistant_message in history:
|
27 |
prompt += model.config["promptTemplate"].format(user_message)
|
28 |
-
prompt += assistant_message + "
|
29 |
prompt += model.config["promptTemplate"].format(message)
|
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):
|
|
|
7 |
Is it really that good? Let's see... (Note: This is a Q4 gguf so thst I can run it on the free cpu. Clone and upgrade for a getter version)
|
8 |
"""
|
9 |
|
10 |
+
model_path = "TheBloke/openchat-3.5-0106-GGUF"
|
11 |
+
model_name = "openchat-3.5-0106.Q4_K_S.gguf"
|
12 |
+
hf_hub_download(repo_id="TheBloke/openchat-3.5-0106-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=True)
|
13 |
|
14 |
print("Start the model init process")
|
15 |
model = model = GPT4All(model_name, model_path, allow_download = True, device="cpu")
|
16 |
print("Finish the model init process")
|
17 |
|
18 |
+
model.config["promptTemplate"] = "GPT4 Correct User: {0}<|end_of_turn|>GPT4 Correct Assistant:
|
19 |
+
|
20 |
+
"
|
21 |
+
model.config["systemPrompt"] = "You are a helpful assistant named 兮辞."
|
22 |
model._is_chat_session_activated = True
|
23 |
|
24 |
max_new_tokens = 2048
|
25 |
|
26 |
def generater(message, history, temperature, top_p, top_k):
|
27 |
+
prompt = ""
|
28 |
for user_message, assistant_message in history:
|
29 |
prompt += model.config["promptTemplate"].format(user_message)
|
30 |
+
prompt += assistant_message + "<|end_of_turn|>"
|
31 |
prompt += model.config["promptTemplate"].format(message)
|
32 |
outputs = []
|
33 |
for token in model.generate(prompt=prompt, temp=temperature, top_k = top_k, top_p = top_p, max_tokens = max_new_tokens, streaming=True):
|