Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,6 +26,8 @@ model = f"./Models/{repo_id}/{filename}"
|
|
| 26 |
max_length = 8192
|
| 27 |
pipeline = chatglm_cpp.Pipeline(model, max_length=max_length)
|
| 28 |
|
|
|
|
|
|
|
| 29 |
def respond(
|
| 30 |
message,
|
| 31 |
history: list[tuple[str, str]],
|
|
@@ -34,6 +36,8 @@ def respond(
|
|
| 34 |
temperature,
|
| 35 |
top_p,
|
| 36 |
):
|
|
|
|
|
|
|
| 37 |
generation_kwargs = dict(
|
| 38 |
max_length=max_length,
|
| 39 |
max_context_length=max_tokens,
|
|
@@ -44,14 +48,15 @@ def respond(
|
|
| 44 |
repetition_penalty=1.0,
|
| 45 |
stream=True,
|
| 46 |
)
|
| 47 |
-
|
| 48 |
-
messages = [chatglm_cpp.ChatMessage(role="system", content=system_message)]
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
messages.append(chatglm_cpp.ChatMessage(role="user", content=message))
|
| 57 |
|
|
|
|
| 26 |
max_length = 8192
|
| 27 |
pipeline = chatglm_cpp.Pipeline(model, max_length=max_length)
|
| 28 |
|
| 29 |
+
messages = []
|
| 30 |
+
|
| 31 |
def respond(
|
| 32 |
message,
|
| 33 |
history: list[tuple[str, str]],
|
|
|
|
| 36 |
temperature,
|
| 37 |
top_p,
|
| 38 |
):
|
| 39 |
+
global messages
|
| 40 |
+
|
| 41 |
generation_kwargs = dict(
|
| 42 |
max_length=max_length,
|
| 43 |
max_context_length=max_tokens,
|
|
|
|
| 48 |
repetition_penalty=1.0,
|
| 49 |
stream=True,
|
| 50 |
)
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
if messages == []:
|
| 53 |
+
messages = [chatglm_cpp.ChatMessage(role="system", content=system_message)]
|
| 54 |
+
|
| 55 |
+
# for val in history:
|
| 56 |
+
# if val[0]:
|
| 57 |
+
# messages.append(chatglm_cpp.ChatMessage(role="user", content=val[0]))
|
| 58 |
+
# if val[1]:
|
| 59 |
+
# messages.append(chatglm_cpp.ChatMessage(role="assistant", content=val[0]))
|
| 60 |
|
| 61 |
messages.append(chatglm_cpp.ChatMessage(role="user", content=message))
|
| 62 |
|