codereader 0.7.0__tar.gz → 0.7.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codereader
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: Local code readability grader using LLMs
5
5
  License: GPLv3
6
6
  License-File: LICENSE
@@ -159,6 +159,8 @@ models:
159
159
  type: ollama
160
160
  model: qwen2.5-coder
161
161
  weight: 1.0
162
+ runner_config:
163
+ no_think: true # to disable deep thinking to shorten
162
164
 
163
165
  settings:
164
166
  log_path: readability_log.txt
@@ -135,6 +135,8 @@ models:
135
135
  type: ollama
136
136
  model: qwen2.5-coder
137
137
  weight: 1.0
138
+ runner_config:
139
+ no_think: true # to disable deep thinking to shorten
138
140
 
139
141
  settings:
140
142
  log_path: readability_log.txt
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codereader"
3
- version = "0.7.0"
3
+ version = "0.7.2"
4
4
  description = "Local code readability grader using LLMs"
5
5
  authors = [
6
6
  {name = "Jason Liu",email = "Liujason2003@gmail.com"}
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import asyncio
4
4
  import json
5
5
  import re
6
+ import os
6
7
 
7
8
  from dataclasses import dataclass
8
9
  from typing import Any, Dict, List, Optional, Protocol
@@ -89,13 +90,15 @@ async def run_subprocess(
89
90
  loop = asyncio.get_running_loop()
90
91
  start = loop.time()
91
92
 
93
+ clean_env = {**os.environ, "TERM": "dumb", "NO_COLOR": "1", **(env or {})}
94
+
92
95
  try:
93
96
  proc = await asyncio.create_subprocess_exec(
94
97
  *cmd,
95
98
  stdin=asyncio.subprocess.PIPE if stdin_text is not None else None,
96
99
  stdout=asyncio.subprocess.PIPE,
97
100
  stderr=asyncio.subprocess.PIPE,
98
- env=env,
101
+ env=clean_env,
99
102
  )
100
103
  except FileNotFoundError as e:
101
104
  dur = loop.time() - start
@@ -184,6 +187,16 @@ def _try_parse_from(text: str, start: int) -> Optional[Dict[str, Any]]:
184
187
  return None
185
188
 
186
189
 
190
+ def clean_output(text: str):
191
+ text = re.sub(r"\x1b\[[0-9;]*[A-Za-z]", "", text)
192
+
193
+ text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL)
194
+
195
+ text = re.sub(r"Thinking\.\.\..*?\.\.\.done thinking\.", "", text, flags=re.DOTALL)
196
+
197
+ return text
198
+
199
+
187
200
  def extract_json_object(text: str) -> Optional[Dict[str, Any]]:
188
201
  """
189
202
  Robustly extract the first valid JSON object from model output.
@@ -199,7 +212,7 @@ def extract_json_object(text: str) -> Optional[Dict[str, Any]]:
199
212
  - Nested objects: {"subscores": {"a": 1}}
200
213
  """
201
214
 
202
- text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL)
215
+ text = clean_output(text)
203
216
 
204
217
  fenced = re.search(r"```(?:json)?\s*(\{.*?\})\s*```", text, re.DOTALL)
205
218
  if fenced:
File without changes