sparkleman commited on
Commit ·
e5f4bff
1
Parent(s): 606a355
UPDATE
Browse files
app.py
CHANGED
|
@@ -14,6 +14,7 @@ from utils import (
|
|
| 14 |
parse_think_response,
|
| 15 |
remove_nested_think_tags_stack,
|
| 16 |
format_bytes,
|
|
|
|
| 17 |
)
|
| 18 |
|
| 19 |
import copy, types, gc, sys, re, time, collections, asyncio
|
|
@@ -635,6 +636,17 @@ async def chatResponseStream(
|
|
| 635 |
"gen_tps": round(completionTokenCount / (genenrateTime - prefillTime), 2),
|
| 636 |
}
|
| 637 |
logger.info(f"[RES] {completionId} - {responseLog}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
|
| 639 |
del buffer
|
| 640 |
|
|
|
|
| 14 |
parse_think_response,
|
| 15 |
remove_nested_think_tags_stack,
|
| 16 |
format_bytes,
|
| 17 |
+
log,
|
| 18 |
)
|
| 19 |
|
| 20 |
import copy, types, gc, sys, re, time, collections, asyncio
|
|
|
|
| 636 |
"gen_tps": round(completionTokenCount / (genenrateTime - prefillTime), 2),
|
| 637 |
}
|
| 638 |
logger.info(f"[RES] {completionId} - {responseLog}")
|
| 639 |
+
request.messages.append(
|
| 640 |
+
ChatMessage(role="Assistant", content=responseLog["content"])
|
| 641 |
+
)
|
| 642 |
+
log(
|
| 643 |
+
{
|
| 644 |
+
**request.model_dump(),
|
| 645 |
+
**responseLog,
|
| 646 |
+
"completionId": completionId,
|
| 647 |
+
"machineLabel": os.environ.get("MACHINE_LABEL"),
|
| 648 |
+
}
|
| 649 |
+
)
|
| 650 |
|
| 651 |
del buffer
|
| 652 |
|
utils.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import re
|
| 2 |
from typing import List, Optional, Union
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
from pydantic_settings import BaseSettings
|
|
@@ -68,3 +68,24 @@ def format_bytes(size):
|
|
| 68 |
size /= power
|
| 69 |
n += 1
|
| 70 |
return f"{size:.4f}{power_labels[n]+'B'}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re, os, threading, queue, requests
|
| 2 |
from typing import List, Optional, Union
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
from pydantic_settings import BaseSettings
|
|
|
|
| 68 |
size /= power
|
| 69 |
n += 1
|
| 70 |
return f"{size:.4f}{power_labels[n]+'B'}"
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
LOGGER_QUEUE = queue.Queue()
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def logger():
|
| 77 |
+
while True:
|
| 78 |
+
item = LOGGER_QUEUE.get()
|
| 79 |
+
requests.post(
|
| 80 |
+
os.environ.get("LOG_PORT"),
|
| 81 |
+
headers={"Content-Type": "application/json"},
|
| 82 |
+
json=item,
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
if os.environ.get("LOG_PORT"):
|
| 87 |
+
threading.Thread(target=logger).start()
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def log(item):
|
| 91 |
+
LOGGER_QUEUE.put_nowait(item)
|
uv.lock
CHANGED
|
@@ -1040,9 +1040,6 @@ cpu = [
|
|
| 1040 |
{ name = "torch", version = "2.6.0", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "(sys_platform == 'darwin' and extra == 'extra-13-rwkv-hf-space-cpu') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu113') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu124') or (extra == 'extra-13-rwkv-hf-space-cu113' and extra == 'extra-13-rwkv-hf-space-cu124')" },
|
| 1041 |
{ name = "torch", version = "2.6.0+cpu", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "(sys_platform != 'darwin' and extra == 'extra-13-rwkv-hf-space-cpu') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu113') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu124') or (extra == 'extra-13-rwkv-hf-space-cu113' and extra == 'extra-13-rwkv-hf-space-cu124')" },
|
| 1042 |
]
|
| 1043 |
-
cu113 = [
|
| 1044 |
-
{ name = "torch", version = "2.0.1", source = { registry = "https://download.pytorch.org/whl/cu113" } },
|
| 1045 |
-
]
|
| 1046 |
cu124 = [
|
| 1047 |
{ name = "torch", version = "2.6.0+cu124", source = { registry = "https://download.pytorch.org/whl/cu124" } },
|
| 1048 |
]
|
|
@@ -1063,11 +1060,10 @@ requires-dist = [
|
|
| 1063 |
{ name = "setuptools", specifier = ">=75.8.2" },
|
| 1064 |
{ name = "snowflake-id", specifier = ">=1.0.2" },
|
| 1065 |
{ name = "torch", marker = "extra == 'cpu'", specifier = ">=2.6.0", index = "https://download.pytorch.org/whl/cpu", conflict = { package = "rwkv-hf-space", extra = "cpu" } },
|
| 1066 |
-
{ name = "torch", marker = "extra == 'cu113'", index = "https://download.pytorch.org/whl/cu113", conflict = { package = "rwkv-hf-space", extra = "cu113" } },
|
| 1067 |
{ name = "torch", marker = "extra == 'cu124'", specifier = ">=2.6.0", index = "https://download.pytorch.org/whl/cu124", conflict = { package = "rwkv-hf-space", extra = "cu124" } },
|
| 1068 |
{ name = "transformers" },
|
| 1069 |
]
|
| 1070 |
-
provides-extras = ["cpu", "cu124"
|
| 1071 |
|
| 1072 |
[[package]]
|
| 1073 |
name = "safetensors"
|
|
@@ -1176,22 +1172,6 @@ wheels = [
|
|
| 1176 |
{ url = "https://files.pythonhosted.org/packages/e6/b6/072a8e053ae600dcc2ac0da81a23548e3b523301a442a6ca900e92ac35be/tokenizers-0.21.1-cp39-abi3-win_amd64.whl", hash = "sha256:0f0dcbcc9f6e13e675a66d7a5f2f225a736745ce484c1a4e07476a89ccdad382", size = 2435481 },
|
| 1177 |
]
|
| 1178 |
|
| 1179 |
-
[[package]]
|
| 1180 |
-
name = "torch"
|
| 1181 |
-
version = "2.0.1"
|
| 1182 |
-
source = { registry = "https://download.pytorch.org/whl/cu113" }
|
| 1183 |
-
dependencies = [
|
| 1184 |
-
{ name = "filelock" },
|
| 1185 |
-
{ name = "jinja2" },
|
| 1186 |
-
{ name = "networkx" },
|
| 1187 |
-
{ name = "sympy" },
|
| 1188 |
-
{ name = "typing-extensions" },
|
| 1189 |
-
]
|
| 1190 |
-
wheels = [
|
| 1191 |
-
{ url = "https://download.pytorch.org/whl/torch-2.0.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:359bfaad94d1cda02ab775dc1cc386d585712329bb47b8741607ef6ef4950747" },
|
| 1192 |
-
{ url = "https://download.pytorch.org/whl/torch-2.0.1-cp311-cp311-manylinux2014_aarch64.whl", hash = "sha256:b6019b1de4978e96daa21d6a3ebb41e88a0b474898fe251fd96189587408873e" },
|
| 1193 |
-
]
|
| 1194 |
-
|
| 1195 |
[[package]]
|
| 1196 |
name = "torch"
|
| 1197 |
version = "2.6.0"
|
|
|
|
| 1040 |
{ name = "torch", version = "2.6.0", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "(sys_platform == 'darwin' and extra == 'extra-13-rwkv-hf-space-cpu') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu113') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu124') or (extra == 'extra-13-rwkv-hf-space-cu113' and extra == 'extra-13-rwkv-hf-space-cu124')" },
|
| 1041 |
{ name = "torch", version = "2.6.0+cpu", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "(sys_platform != 'darwin' and extra == 'extra-13-rwkv-hf-space-cpu') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu113') or (extra == 'extra-13-rwkv-hf-space-cpu' and extra == 'extra-13-rwkv-hf-space-cu124') or (extra == 'extra-13-rwkv-hf-space-cu113' and extra == 'extra-13-rwkv-hf-space-cu124')" },
|
| 1042 |
]
|
|
|
|
|
|
|
|
|
|
| 1043 |
cu124 = [
|
| 1044 |
{ name = "torch", version = "2.6.0+cu124", source = { registry = "https://download.pytorch.org/whl/cu124" } },
|
| 1045 |
]
|
|
|
|
| 1060 |
{ name = "setuptools", specifier = ">=75.8.2" },
|
| 1061 |
{ name = "snowflake-id", specifier = ">=1.0.2" },
|
| 1062 |
{ name = "torch", marker = "extra == 'cpu'", specifier = ">=2.6.0", index = "https://download.pytorch.org/whl/cpu", conflict = { package = "rwkv-hf-space", extra = "cpu" } },
|
|
|
|
| 1063 |
{ name = "torch", marker = "extra == 'cu124'", specifier = ">=2.6.0", index = "https://download.pytorch.org/whl/cu124", conflict = { package = "rwkv-hf-space", extra = "cu124" } },
|
| 1064 |
{ name = "transformers" },
|
| 1065 |
]
|
| 1066 |
+
provides-extras = ["cpu", "cu124"]
|
| 1067 |
|
| 1068 |
[[package]]
|
| 1069 |
name = "safetensors"
|
|
|
|
| 1172 |
{ url = "https://files.pythonhosted.org/packages/e6/b6/072a8e053ae600dcc2ac0da81a23548e3b523301a442a6ca900e92ac35be/tokenizers-0.21.1-cp39-abi3-win_amd64.whl", hash = "sha256:0f0dcbcc9f6e13e675a66d7a5f2f225a736745ce484c1a4e07476a89ccdad382", size = 2435481 },
|
| 1173 |
]
|
| 1174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1175 |
[[package]]
|
| 1176 |
name = "torch"
|
| 1177 |
version = "2.6.0"
|