AbuAlone09 commited on
Commit
3b331d9
·
verified ·
1 Parent(s): b822f0f

Update backend_docs_manager.py

Browse files
Files changed (1) hide show
  1. backend_docs_manager.py +10 -137
backend_docs_manager.py CHANGED
@@ -188,150 +188,23 @@ def should_update_comfyui_docs() -> bool:
188
 
189
  def get_gradio_docs_content() -> str:
190
  """Get the current Gradio documentation content, updating if necessary"""
191
- global _gradio_docs_content, _gradio_docs_last_fetched
192
-
193
- # Check if we need to update
194
- if (_gradio_docs_content is None or
195
- _gradio_docs_last_fetched is None or
196
- should_update_gradio_docs()):
197
-
198
- print("📚 Loading Gradio 6 documentation...")
199
-
200
- # Try to fetch latest content
201
- latest_content = fetch_gradio_docs()
202
-
203
- if latest_content:
204
- # Filter out problematic instructions that cause early termination
205
- filtered_content = filter_problematic_instructions(latest_content)
206
- _gradio_docs_content = filtered_content
207
- _gradio_docs_last_fetched = datetime.now()
208
- save_gradio_docs_cache(filtered_content)
209
- print(f"✅ Gradio 6 documentation loaded successfully ({len(filtered_content)} chars)")
210
- else:
211
- # Fallback to cached content
212
- cached_content = load_cached_gradio_docs()
213
- if cached_content:
214
- _gradio_docs_content = cached_content
215
- _gradio_docs_last_fetched = datetime.now()
216
- print(f"⚠️ Using cached Gradio documentation (network fetch failed) ({len(cached_content)} chars)")
217
- else:
218
- # Fallback to minimal content
219
- _gradio_docs_content = """
220
- # Gradio API Reference (Offline Fallback)
221
-
222
- This is a minimal fallback when documentation cannot be fetched.
223
- Please check your internet connection for the latest API reference.
224
-
225
- Basic Gradio components: Button, Textbox, Slider, Image, Audio, Video, File, etc.
226
- Use gr.Blocks() for custom layouts and gr.Interface() for simple apps.
227
-
228
- For the latest documentation, visit: https://www.gradio.app/llms.txt
229
- """
230
- print("❌ Using minimal fallback documentation")
231
-
232
- return _gradio_docs_content or ""
233
 
234
  def get_transformersjs_docs_content() -> str:
235
  """Get the current transformers.js documentation content, updating if necessary"""
236
- global _transformersjs_docs_content, _transformersjs_docs_last_fetched
237
-
238
- # Check if we need to update
239
- if (_transformersjs_docs_content is None or
240
- _transformersjs_docs_last_fetched is None or
241
- should_update_transformersjs_docs()):
242
-
243
- print("📚 Loading transformers.js documentation...")
244
-
245
- # Try to fetch latest content
246
- latest_content = fetch_transformersjs_docs()
247
-
248
- if latest_content:
249
- # Filter out problematic instructions that cause early termination
250
- filtered_content = filter_problematic_instructions(latest_content)
251
- _transformersjs_docs_content = filtered_content
252
- _transformersjs_docs_last_fetched = datetime.now()
253
- save_transformersjs_docs_cache(filtered_content)
254
- print(f"✅ transformers.js documentation loaded successfully ({len(filtered_content)} chars)")
255
- else:
256
- # Fallback to cached content
257
- cached_content = load_cached_transformersjs_docs()
258
- if cached_content:
259
- _transformersjs_docs_content = cached_content
260
- _transformersjs_docs_last_fetched = datetime.now()
261
- print(f"⚠️ Using cached transformers.js documentation (network fetch failed) ({len(cached_content)} chars)")
262
- else:
263
- # Fallback to minimal content
264
- _transformersjs_docs_content = """
265
- # Transformers.js API Reference (Offline Fallback)
266
-
267
- This is a minimal fallback when documentation cannot be fetched.
268
- Please check your internet connection for the latest API reference.
269
-
270
- Transformers.js allows you to run 🤗 Transformers models directly in the browser using ONNX Runtime.
271
-
272
- Key features:
273
- - pipeline() API for common tasks (sentiment-analysis, text-generation, etc.)
274
- - Support for custom models via model ID or path
275
- - WebGPU support for GPU acceleration
276
- - Quantization support (fp32, fp16, q8, q4)
277
-
278
- Basic usage:
279
- ```javascript
280
- import { pipeline } from '@huggingface/transformers';
281
- const pipe = await pipeline('sentiment-analysis');
282
- const out = await pipe('I love transformers!');
283
- ```
284
 
285
- For the latest documentation, visit: https://huggingface.co/docs/transformers.js
286
- """
287
- print("❌ Using minimal fallback transformers.js documentation")
288
-
289
- return _transformersjs_docs_content or ""
290
 
291
  def get_comfyui_docs_content() -> str:
292
  """Get the current ComfyUI documentation content, updating if necessary"""
293
- global _comfyui_docs_content, _comfyui_docs_last_fetched
294
-
295
- # Check if we need to update
296
- if (_comfyui_docs_content is None or
297
- _comfyui_docs_last_fetched is None or
298
- should_update_comfyui_docs()):
299
-
300
- print("📚 Loading ComfyUI documentation...")
301
-
302
- # Try to fetch latest content
303
- latest_content = fetch_comfyui_docs()
304
-
305
- if latest_content:
306
- # Filter out problematic instructions that cause early termination
307
- filtered_content = filter_problematic_instructions(latest_content)
308
- _comfyui_docs_content = filtered_content
309
- _comfyui_docs_last_fetched = datetime.now()
310
- save_comfyui_docs_cache(filtered_content)
311
- print(f"✅ ComfyUI documentation loaded successfully ({len(filtered_content)} chars)")
312
- else:
313
- # Fallback to cached content
314
- cached_content = load_cached_comfyui_docs()
315
- if cached_content:
316
- _comfyui_docs_content = cached_content
317
- _comfyui_docs_last_fetched = datetime.now()
318
- print(f"⚠️ Using cached ComfyUI documentation (network fetch failed) ({len(cached_content)} chars)")
319
- else:
320
- # Fallback to minimal content
321
- _comfyui_docs_content = """
322
- # ComfyUI API Reference (Offline Fallback)
323
-
324
- This is a minimal fallback when documentation cannot be fetched.
325
- Please check your internet connection for the latest API reference.
326
-
327
- Basic ComfyUI workflow structure: nodes, connections, inputs, outputs.
328
- Use CheckpointLoaderSimple, CLIPTextEncode, KSampler for basic workflows.
329
-
330
- For the latest documentation, visit: https://docs.comfy.org/llms.txt
331
- """
332
- print("❌ Using minimal fallback ComfyUI documentation")
333
-
334
- return _comfyui_docs_content or ""
335
 
336
  def build_gradio_system_prompt() -> str:
337
  """Build the complete Gradio system prompt with full documentation"""
 
188
 
189
  def get_gradio_docs_content() -> str:
190
  """Get the current Gradio documentation content, updating if necessary"""
191
+ # XÓA HOẶC SỬA TOÀN BỘ RUỘT HÀM THÀNH 2 DÒNG DƯỚI ĐÂY:
192
+ print("⚡ Bypassed Gradio Docs")
193
+ return "Minimal Gradio 6 Documentation for testing."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
  def get_transformersjs_docs_content() -> str:
196
  """Get the current transformers.js documentation content, updating if necessary"""
197
+ # XÓA HOẶC SỬA TOÀN BỘ RUỘT HÀM THÀNH 2 DÒNG DƯỚI ĐÂY:
198
+ print("⚡ Bypassed Transformers.js Docs")
199
+ return "Minimal TransformersJS Documentation for testing."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
 
 
 
 
 
201
 
202
  def get_comfyui_docs_content() -> str:
203
  """Get the current ComfyUI documentation content, updating if necessary"""
204
+ # XÓA HOẶC SỬA TOÀN BỘ RUỘT HÀM THÀNH 2 DÒNG DƯỚI ĐÂY:
205
+ print("⚡ Bypassed ComfyUI Docs")
206
+ return "Minimal ComfyUI Documentation for testing."
207
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
  def build_gradio_system_prompt() -> str:
210
  """Build the complete Gradio system prompt with full documentation"""