Spaces:
Runtime error
Runtime error
fix
Browse files- app/rag.py +16 -16
app/rag.py
CHANGED
@@ -30,25 +30,25 @@ class ChatPDF:
|
|
30 |
# model_url = "https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat-GGUF/resolve/main/qwen1_5-1_8b-chat-q8_0.gguf"
|
31 |
model_url = "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf/resolve/main/Phi-3-mini-4k-instruct-q4.gguf"
|
32 |
|
33 |
-
def messages_to_prompt(messages):
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
|
48 |
-
|
49 |
|
50 |
-
def completion_to_prompt(completion):
|
51 |
-
|
52 |
|
53 |
|
54 |
def __init__(self):
|
@@ -68,7 +68,7 @@ class ChatPDF:
|
|
68 |
max_new_tokens=256,
|
69 |
context_window=3900,
|
70 |
# generate_kwargs={},
|
71 |
-
model_kwargs={"n_gpu_layers": -1},
|
72 |
messages_to_prompt=self.messages_to_prompt,
|
73 |
completion_to_prompt=self.completion_to_prompt,
|
74 |
verbose=True,
|
|
|
30 |
# model_url = "https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat-GGUF/resolve/main/qwen1_5-1_8b-chat-q8_0.gguf"
|
31 |
model_url = "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf/resolve/main/Phi-3-mini-4k-instruct-q4.gguf"
|
32 |
|
33 |
+
# def messages_to_prompt(messages):
|
34 |
+
# prompt = ""
|
35 |
+
# for message in messages:
|
36 |
+
# if message.role == 'system':
|
37 |
+
# prompt += f"<|system|>\n{message.content}</s>\n"
|
38 |
+
# elif message.role == 'user':
|
39 |
+
# prompt += f"<|user|>\n{message.content}</s>\n"
|
40 |
+
# elif message.role == 'assistant':
|
41 |
+
# prompt += f"<|assistant|>\n{message.content}</s>\n"
|
42 |
|
43 |
+
# if not prompt.startswith("<|system|>\n"):
|
44 |
+
# prompt = "<|system|>\n</s>\n" + prompt
|
45 |
|
46 |
+
# prompt = prompt + "<|assistant|>\n"
|
47 |
|
48 |
+
# return prompt
|
49 |
|
50 |
+
# def completion_to_prompt(completion):
|
51 |
+
# return f"<|system|>\n</s>\n<|user|>\n{completion}</s>\n<|assistant|>\n"
|
52 |
|
53 |
|
54 |
def __init__(self):
|
|
|
68 |
max_new_tokens=256,
|
69 |
context_window=3900,
|
70 |
# generate_kwargs={},
|
71 |
+
# model_kwargs={"n_gpu_layers": -1},
|
72 |
messages_to_prompt=self.messages_to_prompt,
|
73 |
completion_to_prompt=self.completion_to_prompt,
|
74 |
verbose=True,
|