Skip to content

Commit c333c47

Browse files
Merge pull request #14 from EnragedAntelope/feature/stats-output
Add inference stats to troubleshooting output (tokens/sec, input/outp…
2 parents 9185ba7 + a2ee013 commit c333c47

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

LMStudio.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
from typing import Optional, Tuple, List
88
import os
9+
import time
910
from tempfile import NamedTemporaryFile
1011
import numpy as np
1112
from PIL import Image
@@ -596,13 +597,25 @@ def generate(
596597
troubleshooting_lines.append(f"[INFO] Sampling: top_k={top_k}, top_p={top_p}")
597598
troubleshooting_lines.append("[INFO] Generating...")
598599

600+
start_time = time.time()
599601
# Generate response
600602
response = model.respond(chat, config=gen_config)
601603
response_text = str(response)
602604

603605
troubleshooting_lines.append("[INFO] Generation complete")
604606
troubleshooting_lines.append(f"[INFO] Raw response length: {len(response_text)} chars")
605607

608+
# Extract inference statistics
609+
tokens_per_sec = getattr(response.stats, 'tokens_per_second', 0.0)
610+
input_tokens = getattr(response.stats, 'prompt_tokens_count', 0)
611+
output_tokens = getattr(response.stats, 'predicted_tokens_count', 0)
612+
elapsed = time.time() - start_time
613+
614+
troubleshooting_lines.append(f"[INFO] Tokens per second: {tokens_per_sec:.2f}")
615+
troubleshooting_lines.append(f"[INFO] Input tokens: {input_tokens}")
616+
troubleshooting_lines.append(f"[INFO] Output tokens: {output_tokens}")
617+
troubleshooting_lines.append(f"[INFO] Total time: {elapsed:.2f}s")
618+
606619
# Extract reasoning based on mode
607620
final_response = response_text
608621
reasoning = ""

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Exclude models from the dropdown by adding patterns to `lms_config/user_config.j
7575
|--------|-------------|
7676
| response | Generated text (reasoning removed if extracted) |
7777
| reasoning | Extracted thinking content |
78-
| troubleshooting | Status messages and debug hints |
78+
| troubleshooting | Status messages, debug hints, and inference stats (tokens/sec, input/output tokens, total time) |
7979

8080
## License
8181

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "EA_LMStudio"
33
description = "A custom node for LM Studio integration into ComfyUI."
4-
version = "1.3.2"
4+
version = "1.3.3"
55
license = {file = "LICENSE"}
66

77
[project.urls]

0 commit comments

Comments
 (0)