Spaces:
Running
Running
Upload 14 files
Browse files- api_base.py +113 -8
- api_keys.json +4 -1
- bs_reasoning.py +1 -7
- configs.py +94 -7
- static/.DS_Store +0 -0
- tot_reasoning.py +1 -7
api_base.py
CHANGED
@@ -1,9 +1,3 @@
|
|
1 |
-
"""
|
2 |
-
Base API module for handling different API providers.
|
3 |
-
This module provides a unified interface for interacting with various API providers
|
4 |
-
like Anthropic, OpenAI, Google Gemini and Together AI.
|
5 |
-
"""
|
6 |
-
|
7 |
from abc import ABC, abstractmethod
|
8 |
import logging
|
9 |
import requests
|
@@ -226,13 +220,112 @@ class TogetherAPI(BaseAPI):
|
|
226 |
except Exception as e:
|
227 |
self._handle_error(e, "request or response processing")
|
228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
class APIFactory:
|
230 |
"""Factory class for creating API instances"""
|
231 |
|
232 |
_providers = {
|
233 |
"anthropic": {
|
234 |
"class": AnthropicAPI,
|
235 |
-
"default_model": "claude-3-
|
236 |
},
|
237 |
"openai": {
|
238 |
"class": OpenAIAPI,
|
@@ -244,7 +337,19 @@ class APIFactory:
|
|
244 |
},
|
245 |
"together": {
|
246 |
"class": TogetherAPI,
|
247 |
-
"default_model": "meta-llama/Meta-Llama-3.1-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
}
|
249 |
}
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from abc import ABC, abstractmethod
|
2 |
import logging
|
3 |
import requests
|
|
|
220 |
except Exception as e:
|
221 |
self._handle_error(e, "request or response processing")
|
222 |
|
223 |
+
class DeepSeekAPI(BaseAPI):
|
224 |
+
"""Class to handle interactions with the DeepSeek API"""
|
225 |
+
|
226 |
+
def __init__(self, api_key: str, model: str = "deepseek-chat"):
|
227 |
+
super().__init__(api_key, model)
|
228 |
+
self.provider_name = "DeepSeek"
|
229 |
+
try:
|
230 |
+
self.client = OpenAI(api_key=api_key, base_url="https://api.deepseek.com")
|
231 |
+
except Exception as e:
|
232 |
+
self._handle_error(e, "initialization")
|
233 |
+
|
234 |
+
def generate_response(self, prompt: str, max_tokens: int = 1024,
|
235 |
+
prompt_format: Optional[str] = None) -> str:
|
236 |
+
"""Generate a response using the DeepSeek API"""
|
237 |
+
try:
|
238 |
+
formatted_prompt = self._format_prompt(prompt, prompt_format)
|
239 |
+
|
240 |
+
logger.info(f"Sending request to DeepSeek API with model {self.model}")
|
241 |
+
response = self.client.chat.completions.create(
|
242 |
+
model=self.model,
|
243 |
+
messages=[
|
244 |
+
{"role": "user", "content": formatted_prompt}
|
245 |
+
],
|
246 |
+
max_tokens=max_tokens
|
247 |
+
)
|
248 |
+
|
249 |
+
return response.choices[0].message.content
|
250 |
+
|
251 |
+
except Exception as e:
|
252 |
+
self._handle_error(e, "request or response processing")
|
253 |
+
|
254 |
+
class QwenAPI(BaseAPI):
|
255 |
+
"""Class to handle interactions with the Qwen API"""
|
256 |
+
|
257 |
+
def __init__(self, api_key: str, model: str = "qwen-plus"):
|
258 |
+
super().__init__(api_key, model)
|
259 |
+
self.provider_name = "Qwen"
|
260 |
+
try:
|
261 |
+
self.client = OpenAI(
|
262 |
+
api_key=api_key,
|
263 |
+
base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
264 |
+
)
|
265 |
+
except Exception as e:
|
266 |
+
self._handle_error(e, "initialization")
|
267 |
+
|
268 |
+
def generate_response(self, prompt: str, max_tokens: int = 1024,
|
269 |
+
prompt_format: Optional[str] = None) -> str:
|
270 |
+
"""Generate a response using the Qwen API"""
|
271 |
+
try:
|
272 |
+
formatted_prompt = self._format_prompt(prompt, prompt_format)
|
273 |
+
|
274 |
+
logger.info(f"Sending request to Qwen API with model {self.model}")
|
275 |
+
response = self.client.chat.completions.create(
|
276 |
+
model=self.model,
|
277 |
+
messages=[
|
278 |
+
{"role": "user", "content": formatted_prompt}
|
279 |
+
],
|
280 |
+
max_tokens=max_tokens
|
281 |
+
)
|
282 |
+
|
283 |
+
return response.choices[0].message.content
|
284 |
+
|
285 |
+
except Exception as e:
|
286 |
+
self._handle_error(e, "request or response processing")
|
287 |
+
|
288 |
+
class GrokAPI(BaseAPI):
|
289 |
+
"""Class to handle interactions with the Grok API"""
|
290 |
+
|
291 |
+
def __init__(self, api_key: str, model: str = "grok-2-latest"):
|
292 |
+
super().__init__(api_key, model)
|
293 |
+
self.provider_name = "Grok"
|
294 |
+
try:
|
295 |
+
self.client = OpenAI(
|
296 |
+
api_key=api_key,
|
297 |
+
base_url="https://api.x.ai/v1"
|
298 |
+
)
|
299 |
+
except Exception as e:
|
300 |
+
self._handle_error(e, "initialization")
|
301 |
+
|
302 |
+
def generate_response(self, prompt: str, max_tokens: int = 1024,
|
303 |
+
prompt_format: Optional[str] = None) -> str:
|
304 |
+
"""Generate a response using the Grok API"""
|
305 |
+
try:
|
306 |
+
formatted_prompt = self._format_prompt(prompt, prompt_format)
|
307 |
+
|
308 |
+
logger.info(f"Sending request to Grok API with model {self.model}")
|
309 |
+
response = self.client.chat.completions.create(
|
310 |
+
model=self.model,
|
311 |
+
messages=[
|
312 |
+
{"role": "user", "content": formatted_prompt}
|
313 |
+
],
|
314 |
+
max_tokens=max_tokens
|
315 |
+
)
|
316 |
+
|
317 |
+
return response.choices[0].message.content
|
318 |
+
|
319 |
+
except Exception as e:
|
320 |
+
self._handle_error(e, "request or response processing")
|
321 |
+
|
322 |
class APIFactory:
|
323 |
"""Factory class for creating API instances"""
|
324 |
|
325 |
_providers = {
|
326 |
"anthropic": {
|
327 |
"class": AnthropicAPI,
|
328 |
+
"default_model": "claude-3-7-sonnet-20250219"
|
329 |
},
|
330 |
"openai": {
|
331 |
"class": OpenAIAPI,
|
|
|
337 |
},
|
338 |
"together": {
|
339 |
"class": TogetherAPI,
|
340 |
+
"default_model": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo"
|
341 |
+
},
|
342 |
+
"deepseek": {
|
343 |
+
"class": DeepSeekAPI,
|
344 |
+
"default_model": "deepseek-chat"
|
345 |
+
},
|
346 |
+
"qwen": {
|
347 |
+
"class": QwenAPI,
|
348 |
+
"default_model": "qwen-plus"
|
349 |
+
},
|
350 |
+
"grok": {
|
351 |
+
"class": GrokAPI,
|
352 |
+
"default_model": "grok-2-latest"
|
353 |
}
|
354 |
}
|
355 |
|
api_keys.json
CHANGED
@@ -2,5 +2,8 @@
|
|
2 |
"anthropic": "",
|
3 |
"openai": "",
|
4 |
"google": "",
|
5 |
-
"together": ""
|
|
|
|
|
|
|
6 |
}
|
|
|
2 |
"anthropic": "",
|
3 |
"openai": "",
|
4 |
"google": "",
|
5 |
+
"together": "",
|
6 |
+
"deepseek": "",
|
7 |
+
"qwen": "",
|
8 |
+
"grok": ""
|
9 |
}
|
bs_reasoning.py
CHANGED
@@ -175,13 +175,7 @@ def wrap_text(text: str, config: VisualizationConfig) -> str:
|
|
175 |
wrapped_lines = textwrap.wrap(text, width=config.max_chars_per_line)
|
176 |
|
177 |
if len(wrapped_lines) > config.max_lines:
|
178 |
-
# Option 1: Simply truncate and add ellipsis to the last line
|
179 |
wrapped_lines = wrapped_lines[:config.max_lines]
|
180 |
wrapped_lines[-1] = wrapped_lines[-1][:config.max_chars_per_line-3] + "..."
|
181 |
-
|
182 |
-
# Option 2 (alternative): Include part of the next line to show continuity
|
183 |
-
# original_next_line = wrapped_lines[config.max_lines] if len(wrapped_lines) > config.max_lines else ""
|
184 |
-
# wrapped_lines = wrapped_lines[:config.max_lines-1]
|
185 |
-
# wrapped_lines.append(original_next_line[:config.max_chars_per_line-3] + "...")
|
186 |
-
|
187 |
return "<br>".join(wrapped_lines)
|
|
|
175 |
wrapped_lines = textwrap.wrap(text, width=config.max_chars_per_line)
|
176 |
|
177 |
if len(wrapped_lines) > config.max_lines:
|
|
|
178 |
wrapped_lines = wrapped_lines[:config.max_lines]
|
179 |
wrapped_lines[-1] = wrapped_lines[-1][:config.max_chars_per_line-3] + "..."
|
180 |
+
|
|
|
|
|
|
|
|
|
|
|
181 |
return "<br>".join(wrapped_lines)
|
configs.py
CHANGED
@@ -29,47 +29,134 @@ class GeneralConfig:
|
|
29 |
"""General configuration parameters that are method-independent"""
|
30 |
available_models: List[str] = field(default_factory=lambda: [
|
31 |
# Anthropic Models
|
|
|
|
|
|
|
32 |
"claude-3-haiku-20240307",
|
33 |
"claude-3-sonnet-20240229",
|
34 |
"claude-3-opus-20240229",
|
35 |
# OpenAI Models
|
36 |
-
"gpt-4-turbo-preview",
|
37 |
"gpt-4",
|
|
|
|
|
|
|
|
|
38 |
"gpt-3.5-turbo",
|
39 |
# Gemini Models
|
40 |
"gemini-2.0-flash",
|
|
|
|
|
|
|
|
|
|
|
41 |
# Together AI Models
|
42 |
-
#"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
|
43 |
"meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
|
|
44 |
"meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
"deepseek-ai/DeepSeek-V3",
|
46 |
"mistralai/Mixtral-8x22B-Instruct-v0.1",
|
47 |
"Qwen/Qwen2.5-72B-Instruct-Turbo",
|
48 |
#"microsoft/WizardLM-2-8x22B",
|
49 |
#"databricks/dbrx-instruct",
|
50 |
#"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
])
|
53 |
model_providers: Dict[str, str] = field(default_factory=lambda: {
|
|
|
|
|
|
|
54 |
"claude-3-haiku-20240307": "anthropic",
|
55 |
"claude-3-sonnet-20240229": "anthropic",
|
56 |
"claude-3-opus-20240229": "anthropic",
|
57 |
-
"gpt-4-turbo-preview": "openai",
|
58 |
"gpt-4": "openai",
|
|
|
|
|
|
|
|
|
59 |
"gpt-3.5-turbo": "openai",
|
60 |
"gemini-2.0-flash": "google",
|
61 |
-
|
|
|
|
|
|
|
|
|
62 |
"meta-llama/Llama-3.3-70B-Instruct-Turbo": "together",
|
|
|
63 |
"meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro": "together",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
"deepseek-ai/DeepSeek-V3": "together",
|
65 |
"mistralai/Mixtral-8x22B-Instruct-v0.1": "together",
|
66 |
"Qwen/Qwen2.5-72B-Instruct-Turbo": "together",
|
67 |
#"microsoft/WizardLM-2-8x22B": "together",
|
68 |
#"databricks/dbrx-instruct": "together",
|
69 |
#"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF": "together",
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
})
|
72 |
-
providers: List[str] = field(default_factory=lambda: ["anthropic", "openai", "google", "together"])
|
73 |
max_tokens: int = 2048
|
74 |
chars_per_line: int = 40
|
75 |
max_lines: int = 8
|
|
|
29 |
"""General configuration parameters that are method-independent"""
|
30 |
available_models: List[str] = field(default_factory=lambda: [
|
31 |
# Anthropic Models
|
32 |
+
"claude-3-7-sonnet-20250219",
|
33 |
+
"claude-3-5-sonnet-20241022",
|
34 |
+
"claude-3-5-haiku-20241022",
|
35 |
"claude-3-haiku-20240307",
|
36 |
"claude-3-sonnet-20240229",
|
37 |
"claude-3-opus-20240229",
|
38 |
# OpenAI Models
|
|
|
39 |
"gpt-4",
|
40 |
+
"gpt-4-turbo",
|
41 |
+
"gpt-4-turbo-preview",
|
42 |
+
"chatgpt-4o-latest",
|
43 |
+
#"gpt-4o-mini",
|
44 |
"gpt-3.5-turbo",
|
45 |
# Gemini Models
|
46 |
"gemini-2.0-flash",
|
47 |
+
"gemini-2.0-flash-lite",
|
48 |
+
"gemini-2.0-pro-exp-02-05",
|
49 |
+
"gemini-1.5-flash",
|
50 |
+
"gemini-1.5-flash-8b",
|
51 |
+
"gemini-1.5-pro",
|
52 |
# Together AI Models
|
|
|
53 |
"meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
54 |
+
#"meta-llama/Llama-3.2-3B-Instruct-Turbo",
|
55 |
"meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro",
|
56 |
+
"meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
|
57 |
+
#"meta-llama/Meta-Llama-3.1-70B-Instruct-Reference",
|
58 |
+
"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
|
59 |
+
"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
|
60 |
+
#"meta-llama/Meta-Llama-3.1-8B-Instruct-Reference",
|
61 |
+
#"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
|
62 |
+
"meta-llama/Llama-3-70b-chat-hf",
|
63 |
+
"meta-llama/Meta-Llama-3-70B-Instruct",
|
64 |
+
"meta-llama/Meta-Llama-3-70B-Instruct-Turbo",
|
65 |
+
"meta-llama/Meta-Llama-3-70B-Instruct-Lite",
|
66 |
+
#"meta-llama/Llama-3-8b-chat-hf",
|
67 |
+
#"meta-llama/Meta-Llama-3-8B-Instruct",
|
68 |
+
#"meta-llama/Meta-Llama-3-8B-Instruct-Turbo",
|
69 |
+
#"meta-llama/Meta-Llama-3-8B-Instruct-Lite",
|
70 |
"deepseek-ai/DeepSeek-V3",
|
71 |
"mistralai/Mixtral-8x22B-Instruct-v0.1",
|
72 |
"Qwen/Qwen2.5-72B-Instruct-Turbo",
|
73 |
#"microsoft/WizardLM-2-8x22B",
|
74 |
#"databricks/dbrx-instruct",
|
75 |
#"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
|
76 |
+
# DeepSeek Models
|
77 |
+
"deepseek-chat",
|
78 |
+
# Qwen Models
|
79 |
+
"qwen-max",
|
80 |
+
"qwen-max-latest",
|
81 |
+
"qwen-max-2025-01-25",
|
82 |
+
"qwen-plus",
|
83 |
+
"qwen-plus-latest",
|
84 |
+
"qwen-plus-2025-01-25",
|
85 |
+
"qwen-turbo",
|
86 |
+
"qwen-turbo-latest",
|
87 |
+
"qwen-turbo-2024-11-01",
|
88 |
+
#"qwen2.5-14b-instruct-1m",
|
89 |
+
#"qwen2.5-7b-instruct-1m",
|
90 |
+
"qwen2.5-72b-instruct",
|
91 |
+
"qwen2.5-32b-instruct",
|
92 |
+
#"qwen2.5-14b-instruct",
|
93 |
+
#"qwen2.5-7b-instruct",
|
94 |
+
# Grok Models
|
95 |
+
"grok-2",
|
96 |
+
"grok-2-latest",
|
97 |
])
|
98 |
model_providers: Dict[str, str] = field(default_factory=lambda: {
|
99 |
+
"claude-3-7-sonnet-20250219": "anthropic",
|
100 |
+
"claude-3-5-sonnet-20241022": "anthropic",
|
101 |
+
"claude-3-5-haiku-20241022": "anthropic",
|
102 |
"claude-3-haiku-20240307": "anthropic",
|
103 |
"claude-3-sonnet-20240229": "anthropic",
|
104 |
"claude-3-opus-20240229": "anthropic",
|
|
|
105 |
"gpt-4": "openai",
|
106 |
+
"gpt-4-turbo": "openai",
|
107 |
+
"gpt-4-turbo-preview": "openai",
|
108 |
+
"chatgpt-4o-latest": "openai",
|
109 |
+
#"gpt-4o-mini": "openai",
|
110 |
"gpt-3.5-turbo": "openai",
|
111 |
"gemini-2.0-flash": "google",
|
112 |
+
"gemini-2.0-flash-lite": "google",
|
113 |
+
"gemini-2.0-pro-exp-02-05": "google",
|
114 |
+
"gemini-1.5-flash": "google",
|
115 |
+
"gemini-1.5-flash-8b": "google",
|
116 |
+
"gemini-1.5-pro": "google",
|
117 |
"meta-llama/Llama-3.3-70B-Instruct-Turbo": "together",
|
118 |
+
#"meta-llama/Llama-3.2-3B-Instruct-Turbo": "together",
|
119 |
"meta-llama/Meta-Llama-3.1-405B-Instruct-Lite-Pro": "together",
|
120 |
+
"meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo": "together",
|
121 |
+
#"meta-llama/Meta-Llama-3.1-70B-Instruct-Reference": "together",
|
122 |
+
"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo": "together",
|
123 |
+
"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF": "together",
|
124 |
+
#"meta-llama/Meta-Llama-3.1-8B-Instruct-Reference": "together",
|
125 |
+
#"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo": "together",
|
126 |
+
"meta-llama/Llama-3-70b-chat-hf": "together",
|
127 |
+
"meta-llama/Meta-Llama-3-70B-Instruct": "together",
|
128 |
+
"meta-llama/Meta-Llama-3-70B-Instruct-Turbo": "together",
|
129 |
+
"meta-llama/Meta-Llama-3-70B-Instruct-Lite": "together",
|
130 |
+
#"meta-llama/Llama-3-8b-chat-hf": "together",
|
131 |
+
#"meta-llama/Meta-Llama-3-8B-Instruct": "together",
|
132 |
+
#"meta-llama/Meta-Llama-3-8B-Instruct-Turbo": "together",
|
133 |
+
#"meta-llama/Meta-Llama-3-8B-Instruct-Lite": "together",
|
134 |
"deepseek-ai/DeepSeek-V3": "together",
|
135 |
"mistralai/Mixtral-8x22B-Instruct-v0.1": "together",
|
136 |
"Qwen/Qwen2.5-72B-Instruct-Turbo": "together",
|
137 |
#"microsoft/WizardLM-2-8x22B": "together",
|
138 |
#"databricks/dbrx-instruct": "together",
|
139 |
#"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF": "together",
|
140 |
+
"deepseek-chat": "deepseek",
|
141 |
+
"qwen-max": "qwen",
|
142 |
+
"qwen-max-latest": "qwen",
|
143 |
+
"qwen-max-2025-01-25": "qwen",
|
144 |
+
"qwen-plus": "qwen",
|
145 |
+
"qwen-plus-latest": "qwen",
|
146 |
+
"qwen-plus-2025-01-25": "qwen",
|
147 |
+
"qwen-turbo": "qwen",
|
148 |
+
"qwen-turbo-latest": "qwen",
|
149 |
+
"qwen-turbo-2024-11-01": "qwen",
|
150 |
+
#"qwen2.5-14b-instruct-1m": "qwen",
|
151 |
+
#"qwen2.5-7b-instruct-1m": "qwen",
|
152 |
+
"qwen2.5-72b-instruct": "qwen",
|
153 |
+
"qwen2.5-32b-instruct": "qwen",
|
154 |
+
#"qwen2.5-14b-instruct": "qwen",
|
155 |
+
#"qwen2.5-7b-instruct": "qwen",
|
156 |
+
"grok-2": "grok",
|
157 |
+
"grok-2-latest": "grok",
|
158 |
})
|
159 |
+
providers: List[str] = field(default_factory=lambda: ["anthropic", "openai", "google", "together", "deepseek", "qwen", "grok"])
|
160 |
max_tokens: int = 2048
|
161 |
chars_per_line: int = 40
|
162 |
max_lines: int = 8
|
static/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
tot_reasoning.py
CHANGED
@@ -125,13 +125,7 @@ def wrap_text(text: str, config: VisualizationConfig) -> str:
|
|
125 |
wrapped_lines = textwrap.wrap(text, width=config.max_chars_per_line)
|
126 |
|
127 |
if len(wrapped_lines) > config.max_lines:
|
128 |
-
# Option 1: Simply truncate and add ellipsis to the last line
|
129 |
wrapped_lines = wrapped_lines[:config.max_lines]
|
130 |
wrapped_lines[-1] = wrapped_lines[-1][:config.max_chars_per_line-3] + "..."
|
131 |
-
|
132 |
-
# Option 2 (alternative): Include part of the next line to show continuity
|
133 |
-
# original_next_line = wrapped_lines[config.max_lines] if len(wrapped_lines) > config.max_lines else ""
|
134 |
-
# wrapped_lines = wrapped_lines[:config.max_lines-1]
|
135 |
-
# wrapped_lines.append(original_next_line[:config.max_chars_per_line-3] + "...")
|
136 |
-
|
137 |
return "<br>".join(wrapped_lines)
|
|
|
125 |
wrapped_lines = textwrap.wrap(text, width=config.max_chars_per_line)
|
126 |
|
127 |
if len(wrapped_lines) > config.max_lines:
|
|
|
128 |
wrapped_lines = wrapped_lines[:config.max_lines]
|
129 |
wrapped_lines[-1] = wrapped_lines[-1][:config.max_chars_per_line-3] + "..."
|
130 |
+
|
|
|
|
|
|
|
|
|
|
|
131 |
return "<br>".join(wrapped_lines)
|