Skip to content

Commit 7928397

Browse files
🐛 fixed lint issues again
1 parent e30bec3 commit 7928397

4 files changed

Lines changed: 12 additions & 18 deletions

File tree

slm_server/app.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252
STREAM_RESPONSE_MEDIA_TYPE = "text/event-stream"
5353
# Schema for streaming responses.
5454
STREAM_RESPONSE_SCHEMA = {
55-
"schema": {
56-
"$ref": "#/components/schemas/ChatCompletionChunkResponse"
57-
}
55+
"schema": {"$ref": "#/components/schemas/ChatCompletionChunkResponse"}
5856
}
5957

6058

slm_server/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@ def get_settings() -> Settings:
126126
get_settings._instance = Settings()
127127
return get_settings._instance
128128

129+
129130
def get_model_id(settings: Annotated[Settings, Depends(get_settings)]) -> str:
130131
return settings.chat_model_id

slm_server/utils/ids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import string
77

8-
_LENGTH=12
8+
_LENGTH = 12
99
_ALPHABET = string.ascii_letters + string.digits
1010
_BASE = len(_ALPHABET)
1111

slm_server/utils/postprocess.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
from slm_server.utils.ids import gen_id
1818

1919
_THINK_RE = re.compile(r"<think>(.*?)</think>", re.DOTALL)
20-
_TOOL_CALL_RE = re.compile(
21-
r"<tool_call>\s*(\{.*?\})\s*</tool_call>", re.DOTALL
22-
)
20+
_TOOL_CALL_RE = re.compile(r"<tool_call>\s*(\{.*?\})\s*</tool_call>", re.DOTALL)
2321

2422

2523
def extract_reasoning(content: str) -> tuple[str | None, str]:
@@ -151,9 +149,7 @@ def __init__(self, *, model_id: str | None = None) -> None:
151149

152150
# -- public API ----------------------------------------------------------
153151

154-
def process_chunk(
155-
self, chunk: dict[str, Any]
156-
) -> list[dict[str, Any]]:
152+
def process_chunk(self, chunk: dict[str, Any]) -> list[dict[str, Any]]:
157153
"""Process one streaming chunk, returning zero or more output chunks."""
158154
self._last_chunk_template = chunk
159155

@@ -178,8 +174,11 @@ def process_chunk(
178174
"tool_calls" if self._had_tool_calls else orig_finish
179175
)
180176
else:
181-
result.append(self._rewrite_finish(chunk) if self._had_tool_calls
182-
else self._stamp(copy.deepcopy(chunk)))
177+
result.append(
178+
self._rewrite_finish(chunk)
179+
if self._had_tool_calls
180+
else self._stamp(copy.deepcopy(chunk))
181+
)
183182

184183
return result
185184

@@ -193,9 +192,7 @@ def flush(self) -> list[dict[str, Any]]:
193192

194193
# -- internals -----------------------------------------------------------
195194

196-
def _consume_text(
197-
self, text: str, chunk: dict[str, Any]
198-
) -> list[dict[str, Any]]:
195+
def _consume_text(self, text: str, chunk: dict[str, Any]) -> list[dict[str, Any]]:
199196
"""Feed *text* through the tag-detection state machine.
200197
201198
Batches consecutive characters for the same state into single chunks
@@ -273,9 +270,7 @@ def _emit_batch(self, text: str) -> list[dict[str, Any]]:
273270
self._tool_call_buf += text
274271
return []
275272

276-
def _finish_tool_call(
277-
self, chunk: dict[str, Any]
278-
) -> list[dict[str, Any]]:
273+
def _finish_tool_call(self, chunk: dict[str, Any]) -> list[dict[str, Any]]:
279274
"""Parse the accumulated JSON and emit a ``tool_calls`` delta."""
280275
raw = self._tool_call_buf.strip()
281276
self._tool_call_buf = ""

0 commit comments

Comments
 (0)