Spaces:
Sleeping
Sleeping
Staticaliza
commited on
Commit
•
0094eb2
1
Parent(s):
b319475
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,8 @@ for model_name, model_endpoint in API_ENDPOINTS.items():
|
|
23 |
CHOICES.append(model_name)
|
24 |
CLIENTS[model_name] = InferenceClient(model_endpoint, headers = { "Authorization": f"Bearer {API_TOKEN}" })
|
25 |
|
26 |
-
def format(instruction = "", history =
|
|
|
27 |
sy_l, sy_r = SPECIAL_SYMBOLS[0], SPECIAL_SYMBOLS[1]
|
28 |
formatted_history = '\n'.join(f"{sy_l}{message}{sy_r}" for message in history)
|
29 |
formatted_input = f"System: {sy_l}{instruction}{sy_r}\n{formatted_history}\n{sy_l}{input}{sy_r}\n{preinput}"
|
@@ -54,18 +55,16 @@ def predict(instruction, history, input, preinput, access_key, model, temperatur
|
|
54 |
return_full_text = False
|
55 |
)
|
56 |
|
57 |
-
print(response)
|
58 |
sy_l, sy_r = SPECIAL_SYMBOLS[0], SPECIAL_SYMBOLS[1]
|
59 |
pre_result = f"{sy_l}{response}{sy_r}{''.join(SPECIAL_SYMBOLS)}"
|
60 |
-
print(pre_result)
|
61 |
pattern = re.compile(f"{sy_l}(.*?){sy_r}", re.DOTALL)
|
62 |
match = pattern.search(pre_result)
|
63 |
get_result = match.group(1).strip() if match else ""
|
64 |
-
|
65 |
history = history + [[input, get_result]]
|
66 |
|
67 |
print(f"---\nUSER: {input}\nBOT: {get_result}\n---")
|
68 |
-
|
69 |
return (get_result, input, history)
|
70 |
|
71 |
def clear_history():
|
|
|
23 |
CHOICES.append(model_name)
|
24 |
CLIENTS[model_name] = InferenceClient(model_endpoint, headers = { "Authorization": f"Bearer {API_TOKEN}" })
|
25 |
|
26 |
+
def format(instruction = "", history = [], input = "", preinput = ""):
|
27 |
+
print(history)
|
28 |
sy_l, sy_r = SPECIAL_SYMBOLS[0], SPECIAL_SYMBOLS[1]
|
29 |
formatted_history = '\n'.join(f"{sy_l}{message}{sy_r}" for message in history)
|
30 |
formatted_input = f"System: {sy_l}{instruction}{sy_r}\n{formatted_history}\n{sy_l}{input}{sy_r}\n{preinput}"
|
|
|
55 |
return_full_text = False
|
56 |
)
|
57 |
|
|
|
58 |
sy_l, sy_r = SPECIAL_SYMBOLS[0], SPECIAL_SYMBOLS[1]
|
59 |
pre_result = f"{sy_l}{response}{sy_r}{''.join(SPECIAL_SYMBOLS)}"
|
|
|
60 |
pattern = re.compile(f"{sy_l}(.*?){sy_r}", re.DOTALL)
|
61 |
match = pattern.search(pre_result)
|
62 |
get_result = match.group(1).strip() if match else ""
|
63 |
+
|
64 |
history = history + [[input, get_result]]
|
65 |
|
66 |
print(f"---\nUSER: {input}\nBOT: {get_result}\n---")
|
67 |
+
print(history)
|
68 |
return (get_result, input, history)
|
69 |
|
70 |
def clear_history():
|