Spaces:
Sleeping
Sleeping
Commit
·
e78ae74
1
Parent(s):
003d8ec
Update src/backend/chatbot.py
Browse files- src/backend/chatbot.py +22 -21
src/backend/chatbot.py
CHANGED
@@ -26,27 +26,28 @@ model = 'Llama2-7B_CPP'
|
|
26 |
|
27 |
|
28 |
# initialize model
|
29 |
-
if
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
50 |
|
51 |
def parse_and_evaluate_text(text):
|
52 |
# Find the indices of the opening and closing brackets
|
|
|
26 |
|
27 |
|
28 |
# initialize model
|
29 |
+
if st.session_state.demo_lite = False:
|
30 |
+
if model == 'Llama2-7B_CPP':
|
31 |
+
model_path = "/Users/dheym/Library/CloudStorage/OneDrive-Personal/Documents/side_projects/GRDN/src/models/llama-2-7b-chat.Q4_K_M.gguf"
|
32 |
+
llm = LlamaCPP(
|
33 |
+
# You can pass in the URL to a GGML model to download it automatically
|
34 |
+
#model_url=model_url,
|
35 |
+
# optionally, you can set the path to a pre-downloaded model instead of model_url
|
36 |
+
model_path=model_path,
|
37 |
+
temperature=0.1,
|
38 |
+
max_new_tokens=1000,
|
39 |
+
# llama2 has a context window of 4096 tokens, but we set it lower to allow for some wiggle room
|
40 |
+
context_window=3000,
|
41 |
+
# kwargs to pass to __call__()
|
42 |
+
generate_kwargs={},
|
43 |
+
# kwargs to pass to __init__()
|
44 |
+
# set to at least 1 to use GPU
|
45 |
+
model_kwargs={"n_gpu_layers": 1},
|
46 |
+
# transform inputs into Llama2 format
|
47 |
+
messages_to_prompt=messages_to_prompt,
|
48 |
+
completion_to_prompt=completion_to_prompt,
|
49 |
+
verbose=True,
|
50 |
+
)
|
51 |
|
52 |
def parse_and_evaluate_text(text):
|
53 |
# Find the indices of the opening and closing brackets
|