inferencesh 0.2.16__py3-none-any.whl → 0.2.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of inferencesh might be problematic. Click here for more details.
- inferencesh/models/llm.py +13 -2
- {inferencesh-0.2.16.dist-info → inferencesh-0.2.17.dist-info}/METADATA +1 -1
- {inferencesh-0.2.16.dist-info → inferencesh-0.2.17.dist-info}/RECORD +7 -7
- {inferencesh-0.2.16.dist-info → inferencesh-0.2.17.dist-info}/WHEEL +0 -0
- {inferencesh-0.2.16.dist-info → inferencesh-0.2.17.dist-info}/entry_points.txt +0 -0
- {inferencesh-0.2.16.dist-info → inferencesh-0.2.17.dist-info}/licenses/LICENSE +0 -0
- {inferencesh-0.2.16.dist-info → inferencesh-0.2.17.dist-info}/top_level.txt +0 -0
inferencesh/models/llm.py
CHANGED
|
@@ -228,6 +228,7 @@ class ResponseTransformer:
|
|
|
228
228
|
def __init__(self, output_cls: type[LLMOutput] = LLMOutput):
|
|
229
229
|
self.state = ResponseState()
|
|
230
230
|
self.output_cls = output_cls
|
|
231
|
+
self.timing = None # Will be set by stream_generate
|
|
231
232
|
|
|
232
233
|
def clean_text(self, text: str) -> str:
|
|
233
234
|
"""Clean common tokens from the text and apply model-specific cleaning.
|
|
@@ -264,10 +265,17 @@ class ResponseTransformer:
|
|
|
264
265
|
text: Cleaned text to process for reasoning
|
|
265
266
|
"""
|
|
266
267
|
# Default implementation for <think> style reasoning
|
|
267
|
-
if "<think>" in text:
|
|
268
|
+
if "<think>" in text and not self.state.state_changes["reasoning_started"]:
|
|
268
269
|
self.state.state_changes["reasoning_started"] = True
|
|
269
|
-
|
|
270
|
+
if self.timing:
|
|
271
|
+
self.timing.start_reasoning()
|
|
272
|
+
|
|
273
|
+
if "</think>" in text and not self.state.state_changes["reasoning_ended"]:
|
|
270
274
|
self.state.state_changes["reasoning_ended"] = True
|
|
275
|
+
if self.timing:
|
|
276
|
+
# Estimate token count from character count (rough approximation)
|
|
277
|
+
token_count = len(self.state.buffer.split("<think>")[1].split("</think>")[0]) // 4
|
|
278
|
+
self.timing.end_reasoning(token_count)
|
|
271
279
|
|
|
272
280
|
if "<think>" in self.state.buffer:
|
|
273
281
|
parts = self.state.buffer.split("</think>", 1)
|
|
@@ -381,6 +389,9 @@ def stream_generate(
|
|
|
381
389
|
}
|
|
382
390
|
|
|
383
391
|
with timing_context() as timing:
|
|
392
|
+
# Set timing context in transformer
|
|
393
|
+
transformer.timing = timing
|
|
394
|
+
|
|
384
395
|
def generation_thread():
|
|
385
396
|
nonlocal thread_exception, usage_stats
|
|
386
397
|
try:
|
|
@@ -2,13 +2,13 @@ inferencesh/__init__.py,sha256=WdADtOhfa3HDOunoE9HLFCTFlXRykYstBIH1FpyWvj8,613
|
|
|
2
2
|
inferencesh/models/__init__.py,sha256=FDwcdtT6c4hbRitymjmN-hZMlQa8RbKSftkZZyjtUXA,536
|
|
3
3
|
inferencesh/models/base.py,sha256=4gZQRi8J7y9U6PrGD9pRIehd1MJVJAqGakPQDs2AKFM,3251
|
|
4
4
|
inferencesh/models/file.py,sha256=5xnpypcRahM1YcEjj64rv9g2gTimxrZb41YT4r440hU,7393
|
|
5
|
-
inferencesh/models/llm.py,sha256=
|
|
5
|
+
inferencesh/models/llm.py,sha256=ndRFWbnAD1-BQFTTEb2YShGP-gjVd7w80ItT4XFV1_U,18983
|
|
6
6
|
inferencesh/utils/__init__.py,sha256=-xiD6uo2XzcrPAWFb_fUbaimmnW4KFKc-8IvBzaxNd4,148
|
|
7
7
|
inferencesh/utils/download.py,sha256=7n5twvoNYDcFnKJyefImaj2YfzRI7vddQw4usZbj38c,1521
|
|
8
8
|
inferencesh/utils/storage.py,sha256=E4J8emd4eFKdmdDgAqzz3TpaaDd3n0l8gYlMHuY8yIU,519
|
|
9
|
-
inferencesh-0.2.
|
|
10
|
-
inferencesh-0.2.
|
|
11
|
-
inferencesh-0.2.
|
|
12
|
-
inferencesh-0.2.
|
|
13
|
-
inferencesh-0.2.
|
|
14
|
-
inferencesh-0.2.
|
|
9
|
+
inferencesh-0.2.17.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
|
|
10
|
+
inferencesh-0.2.17.dist-info/METADATA,sha256=gOHSF2qhb_XT_tXlHqp5HAVblDDZzOjM9kGcbp99JQ4,2757
|
|
11
|
+
inferencesh-0.2.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
+
inferencesh-0.2.17.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
|
|
13
|
+
inferencesh-0.2.17.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
|
|
14
|
+
inferencesh-0.2.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|