LeroyDyer commited on
Commit
f39f4e5
Β·
verified Β·
1 Parent(s): e085a8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +649 -4
app.py CHANGED
@@ -60,10 +60,655 @@ chatbot = gr.ChatInterface(
60
  ],
61
  )
62
 
63
- with gr.Blocks() as demo:
64
- with gr.Sidebar():
65
- gr.LoginButton()
66
- chatbot.render()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
 
69
  if __name__ == "__main__":
 
60
  ],
61
  )
62
 
63
+ with gr.Blocks(
64
+ title="πŸš€ L.C.A.R.S - Local Computer Advanced Reasoning System",
65
+ css=config.custom_css,
66
+ theme='Yntec/HaleyCH_Theme_Orange_Green'
67
+ ) as demo:
68
+ # Header
69
+ # State management
70
+ history_state = gr.State([])
71
+
72
+
73
+ # ============================================
74
+ # HEADER SECTION
75
+ # ============================================
76
+ with gr.Row():
77
+ with gr.Column(scale=1):
78
+ gr.Image(
79
+ value="https://cdn-avatars.huggingface.co/v1/production/uploads/65d883893a52cd9bcd8ab7cf/tRsCJlHNZo1D02kBTmfy9.jpeg",
80
+ elem_id="lcars_logo",
81
+ height=200, show_download_button=False,container=False,
82
+ width=200
83
+ )
84
+ with gr.Column(scale=3):
85
+ gr.HTML(f"""
86
+ <div style='text-align: center; padding: 20px; background: linear-gradient(90deg, {config.COLORS['primary']}, {config.COLORS['accent']});
87
+ color: {config.COLORS['background']}; font-size: 24px; font-weight: bold; margin-bottom: 20px;
88
+ border-radius: 0px 0px 15px 15px;'>
89
+ πŸ–₯️ L.C.A.R.S - Local Computer Advanced Reasoning System
90
+ <br><small style='font-size: 14px;'>USS Enterprise β€’ NCC-1701-D β€’ Starfleet Command</small>
91
+ </div>
92
+ """)
93
+
94
+
95
+ # ============================================
96
+ # MAIN INTERFACE TABS
97
+ # ============================================
98
+ with gr.Tabs():
99
+
100
+ # ============================================
101
+ # L.C.A.R.S MAIN CHAT TAB (Enhanced)
102
+ # ============================================
103
+ with gr.TabItem(label="πŸ€– L.C.A.R.S Chat Intelligence", elem_id="lcars_main_tab"):
104
+
105
+ with gr.Row():
106
+ # LEFT COLUMN - INPUT & CONTROLS
107
+ with gr.Column(scale=2):
108
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>🧠 REASONING PROCESS</div>")
109
+ with gr.Accordion(label="🧠 Current AI Reasoning", open=False):
110
+ thinking_html = gr.HTML(label="AI Thought Process", show_label=True)
111
+
112
+ # Main chat input
113
+ message = gr.Textbox(
114
+ show_copy_button=True,
115
+ lines=6,
116
+ label="πŸ’¬ Ask L.C.A.R.S",
117
+ placeholder="Enter your message to the Local Computer Advanced Reasoning System..."
118
+ )
119
+
120
+ # Control buttons
121
+ with gr.Row():
122
+ submit_btn = gr.Button("πŸš€ Ask L.C.A.R.S", variant="huggingface", size="lg")
123
+ clear_btn = gr.Button("πŸ—‘οΈ Clear", variant="huggingface")
124
+
125
+ # Audio controls
126
+ with gr.Row():
127
+ speak_response = gr.Checkbox(label="πŸ”Š Speak Response", value=False)
128
+ speak_thoughts = gr.Checkbox(label="🧠 Speak Reasoning", value=False)
129
+
130
+ # Quick Actions
131
+ with gr.Accordion(label="⚑ Utilitys Quick Actions", open=False):
132
+ with gr.Row():
133
+ artifact_id_input = gr.Textbox(
134
+ label="Artifact ID",
135
+ placeholder="Artifact ID (0, 1, 2)",
136
+ scale=2
137
+ )
138
+ execute_artifact_btn = gr.Button("▢️ Execute Artifact", variant="huggingface")
139
+
140
+ with gr.Row():
141
+ batch_artifact_ids = gr.Textbox(
142
+ label="Batch Execute IDs",
143
+ placeholder="e.g., 0,1 or 0-5",
144
+ scale=2
145
+ )
146
+ batch_execute_btn = gr.Button("⚑Batch Execute", variant="huggingface")
147
+
148
+ # MIDDLE COLUMN - RESPONSES
149
+ with gr.Column(scale=2):
150
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>SYSTEM RESPONSE</div>")
151
+
152
+ with gr.Accordion(label="πŸ€– Library Computer Advanced Reasoning System", open=True):
153
+ plain_text_output = gr.Markdown(
154
+ container=True,
155
+ show_copy_button=True,
156
+ label="AI Response",
157
+ height=400
158
+ )
159
+
160
+ execution_output = gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>🧠 Execution Results</div>")
161
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>Current Session</div>")
162
+
163
+ # Enhanced Chat History Display
164
+ with gr.Accordion(label="πŸ“œ Session Chat History", open=False):
165
+ chat_history_display = gr.HTML(label="Full Session History", show_label=True)
166
+ # Artifacts Display
167
+ with gr.Accordion(label="πŸ“Š Current Session Artifacts", open=False):
168
+ artifacts_display = gr.HTML(label="Generated Artifacts Timeline", show_label=True)
169
+
170
+ # RIGHT COLUMN - ENHANCED CODE ARTIFACTS
171
+ with gr.Column(scale=2):
172
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>🧱 ENHANCED CODE ARTIFACTS WORKSHOP</div>")
173
+
174
+ with gr.Accordion(label="🧱 Code Artifacts Workshop", open=True):
175
+ # Enhanced Code Editor with save functionality
176
+ code_artifacts = gr.Code(
177
+ language="python",
178
+ label="Generated Code & Artifacts",
179
+ lines=10,
180
+ interactive=True,
181
+ autocomplete=True,
182
+ show_line_numbers=True,
183
+ elem_id="code_editor"
184
+ )
185
+
186
+ # Enhanced Artifact Controls
187
+ with gr.Row():
188
+ artifact_description = gr.Textbox(
189
+ label="Artifact Description",
190
+ placeholder="Brief description of the code...",
191
+ scale=2
192
+ )
193
+ artifact_language = gr.Dropdown(
194
+ choices=["python", "javascript", "html", "css", "bash", "sql", "json"],
195
+ value="python",
196
+ label="Language",
197
+ scale=1
198
+ )
199
+
200
+ with gr.Row():
201
+ ExecuteCodePad_btn = gr.Button("▢️ Execute Code", variant="huggingface")
202
+ CreateArtifact_btn = gr.Button("🧱 Save Artifact", variant="huggingface")
203
+
204
+ with gr.Row():
205
+ LoadArtifact_btn = gr.Button("πŸ“‚ Load Artifact", variant="huggingface")
206
+ Load_artifact_id_input = gr.Textbox(
207
+ label="Artifact ID",
208
+ placeholder="ID to Load",
209
+ scale=1
210
+ )
211
+
212
+
213
+ with gr.TabItem("πŸ› οΈ Task Enabled AI"):
214
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>πŸ› οΈ Function Tools</div>")
215
+ with gr.Row():
216
+ with gr.Column():
217
+ tool_model_name = gr.Textbox(
218
+ label="Tool-Capable Model",
219
+ value="leroydyer/lcars/qwen3-0.6b-q4_k_m.gguf"
220
+ )
221
+ tool_prompt = gr.Textbox(
222
+ label="Tool Request",
223
+ value="What is the result of 123 + 456? Use the add tool.",
224
+ lines=4
225
+ )
226
+ tool_call_btn = gr.Button("πŸ› οΈ Execute Tool Call", variant="huggingface")
227
+
228
+ with gr.Column():
229
+ tool_output = gr.Textbox(label="Tool Execution Results", lines=15)
230
+
231
+ with gr.TabItem("πŸ’» System Tools", elem_id="system_tab"):
232
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>πŸ’» System Tools</div>")
233
+ with gr.Tabs():
234
+
235
+ # Tab 1: Code Fragment Analysis
236
+ with gr.TabItem("πŸ“ Code Fragment"):
237
+ gr.Markdown("### Analyze a Python code snippet")
238
+ with gr.Row():
239
+ with gr.Column(scale=2):
240
+ code_input = gr.Code(
241
+ language="python",
242
+ label="Python Code",
243
+ lines=15
244
+ )
245
+ fragment_name = gr.Textbox(
246
+ label="Fragment Name (optional)",
247
+ placeholder="my_code_snippet",
248
+ value="code_fragment"
249
+ )
250
+ analyze_fragment_btn = gr.Button("πŸ” Analyze Code Fragment", variant="huggingface")
251
+ with gr.Column(scale=3):
252
+ fragment_output = gr.Markdown(label="### πŸ” Analysis Results")
253
+ code_output = gr.Markdown("Results will appear here")
254
+ fragment_download = gr.File(label="πŸ“₯ Download Report")
255
+
256
+ # Tab 2: Single File Analysis
257
+ with gr.TabItem("πŸ“„ Single File"):
258
+ gr.Markdown("### Analyze a single Python file")
259
+
260
+ with gr.Row():
261
+ with gr.Column():
262
+ file_input = gr.File(
263
+ label="Upload Python File",
264
+ file_types=[".py"],
265
+ type="filepath"
266
+ )
267
+ analyze_file_btn = gr.Button("πŸ” Analyze File", variant="huggingface")
268
+
269
+ with gr.Column(scale=2):
270
+ gr.Markdown("### πŸ” Analysis Results")
271
+ single_file_output = gr.Markdown("Results will appear here")
272
+
273
+ file_output = gr.Markdown(label="Analysis Results")
274
+ file_download = gr.File(label="πŸ“₯ Download Report")
275
+
276
+ # Tab 3: Directory Analysis
277
+ with gr.TabItem("πŸ“ Directory"):
278
+ with gr.Row():
279
+ gr.HTML(f"""
280
+ <div style='text-align: center; padding: 20px; background: linear-gradient(90deg, {config.COLORS['primary']}, {config.COLORS['accent']});
281
+ color: {config.COLORS['background']}; font-size: 24px; font-weight: bold; margin-bottom: 20px;
282
+ border-radius: 0px 0px 15px 15px;'>
283
+ πŸ–₯️ Analyze an entire directory/project
284
+
285
+ </div>
286
+ """)
287
+
288
+ with gr.Column():
289
+ gr.HTML(f"""
290
+ <div style='text-align: center; padding: 20px; background: linear-gradient(90deg, {config.COLORS['primary']}, {config.COLORS['accent']});
291
+ color: {config.COLORS['background']}; font-size: 24px; font-weight: bold; margin-bottom: 20px;
292
+ border-radius: 0px 0px 15px 15px;'>
293
+ <br><small style='font-size: 14px;'>ℹ️ Directory Scanning Tips
294
+
295
+ - Default excluded dirs: `__pycache__`, `.git`, `.venv`
296
+ </small></br>
297
+ </div>
298
+ """)
299
+ dir_input = gr.Textbox(
300
+ label="Directory Path",
301
+ placeholder="/path/to/your/project",
302
+ lines=1
303
+ )
304
+ with gr.Row():
305
+ recurse_check = gr.Checkbox(label="Include subdirectories", value=True)
306
+ analyze_dir_btn = gr.Button("πŸ” Analyze Directory", variant="huggingface")
307
+ exclude_dirs_input = gr.Textbox(
308
+ label="Directories to Exclude (comma separated)",
309
+ placeholder="tests, docs, examples",
310
+ lines=1
311
+ )
312
+ with gr.Column():
313
+ gr.Markdown("### πŸ“Š Scan Summary")
314
+ summary_output = gr.Markdown("Scan results will appear here")
315
+ with gr.Column():
316
+ gr.Markdown("### πŸ” Detailed Results")
317
+ detailed_output = gr.Markdown("Detailed errors and fixes will appear here")
318
+ dir_output = gr.Markdown(label="Analysis Results")
319
+ dir_download = gr.File(label="πŸ“₯ Download Report")
320
+
321
+
322
+ with gr.TabItem(label="πŸ“Š Enhanced Session & Artifact Management"):
323
+ with gr.Row():
324
+ # Session Management Column
325
+ with gr.Column():
326
+ gr.HTML(f"<div style='background: {config.COLORS['info']}; color: {config.COLORS['background']}; padding: 8px; font-weight: bold;'>πŸ“œ SESSION MANAGEMENT</div>")
327
+
328
+ session_status = gr.Textbox(label="Session Status", value="Ready", interactive=False)
329
+
330
+ with gr.Row():
331
+ session_name_input = gr.Textbox(
332
+ label="Session Name",
333
+ placeholder="Leave empty for auto-naming (NewSession1, NewSession2...)",
334
+ scale=2
335
+ )
336
+ merge_session_checkbox = gr.Checkbox(
337
+ label="Merge Mode",
338
+ value=False,
339
+ info="Merge with current session instead of replacing"
340
+ )
341
+
342
+ with gr.Row():
343
+ save_session_btn = gr.Button("πŸ’Ύ Save Session", variant="huggingface")
344
+ load_session_btn = gr.Button("πŸ“‚ Load Session", variant="huggingface")
345
+
346
+ session_dropdown = gr.Dropdown(
347
+ label="Available Sessions",
348
+ choices=interface.get_session_choices(),
349
+ interactive=True,
350
+ info="Select session to load"
351
+ )
352
+
353
+ with gr.Row():
354
+ load_all_sessions_btn = gr.Button("πŸ“š Load All Sessions", variant="huggingface")
355
+ refresh_sessions_btn = gr.Button("πŸ”„ Refresh Sessions", variant="huggingface")
356
+
357
+ # Artifact Management Column
358
+ with gr.Column():
359
+ gr.HTML(f"<div style='background: {config.COLORS['success']}; color: {config.COLORS['background']}; padding: 8px; font-weight: bold;'>🧱 ARTIFACT MANAGEMENT</div>")
360
+
361
+ artifact_status = gr.Textbox(label="Artifact Status", value="Ready", interactive=False)
362
+
363
+ with gr.Row():
364
+ artifact_session_input = gr.Textbox(
365
+ label="Artifact Session Name",
366
+ placeholder="Leave empty to load all artifacts",
367
+ scale=2
368
+ )
369
+ merge_artifacts_checkbox = gr.Checkbox(
370
+ label="Merge Artifacts",
371
+ value=True,
372
+ info="Add to current artifacts instead of replacing"
373
+ )
374
+
375
+ with gr.Row():
376
+ load_artifacts_btn = gr.Button("πŸ“‚ Load Artifacts", variant="huggingface")
377
+ #save_artifacts_btn = gr.Button("πŸ’Ύ Save Artifacts", variant="huggingface")
378
+
379
+ artifact_dropdown = gr.Dropdown(
380
+ label="Available Artifact Files",
381
+ choices=interface.get_artifact_choices(),
382
+ interactive=True,
383
+ info="Select artifact file to load"
384
+ )
385
+
386
+ with gr.Row():
387
+ load_all_artifacts_btn = gr.Button("πŸ“š Load All Artifacts", variant="huggingface")
388
+ refresh_artifacts_btn = gr.Button("πŸ”„ Refresh Artifacts", variant="huggingface")
389
+
390
+
391
+ with gr.TabItem(label="πŸ“Š Session & Artifact Browser"):
392
+ with gr.Row():
393
+ session_info = gr.JSON(label="Session Details", value=[], elem_classes=["metadata-display"])
394
+ artifact_info = gr.JSON(label="Artifact Details", value=[], elem_classes=["metadata-display"])
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+ with gr.Tab(label="πŸ“‚ Directory to JSON Extractor", elem_id="directory_extractor_tab"):
405
+
406
+ def ExtractDirectoryToJson(directory_path="dump", extension='.txt', json_file_path="_Data.json"):
407
+ def extract_data_from_files(directory_path, Extension='.md', max_seq_length=2048):
408
+ import os
409
+ import json
410
+ Json_list = []
411
+
412
+ # Check if directory exists
413
+ if not os.path.exists(directory_path):
414
+ return f"Error: Directory '{directory_path}' does not exist."
415
+
416
+ # Check if directory is empty
417
+ if not os.listdir(directory_path):
418
+ return f"Error: Directory '{directory_path}' is empty."
419
+
420
+ # Iterate over each file in the directory
421
+ for file_name in os.listdir(directory_path):
422
+ if file_name.endswith(Extension):
423
+ file_path = os.path.join(directory_path, file_name)
424
+ try:
425
+ with open(file_path, 'r', encoding='utf-8') as file:
426
+ chunk = file.read()
427
+ chunks = [chunk[i:i+max_seq_length] for i in range(0, len(chunk), max_seq_length)]
428
+ for text_seg in chunks:
429
+ Json_list.append({'DocumentTitle': file_name, 'Text': text_seg})
430
+ except Exception as e:
431
+ return f"Error reading file {file_name}: {str(e)}"
432
+ return Json_list
433
+
434
+ def save_to_json(data, json_file):
435
+ import os
436
+ import json
437
+ try:
438
+ with open(json_file, 'w') as f:
439
+ json.dump(data, f, indent=4)
440
+ return True, None
441
+ except Exception as e:
442
+ return False, str(e)
443
+
444
+ # Extract file contents
445
+ _data = extract_data_from_files(directory_path, Extension=extension)
446
+
447
+ # Check if we got an error message instead of data
448
+ if isinstance(_data, str):
449
+ return _data
450
+
451
+ # Save data to JSON file
452
+ success, error = save_to_json(_data, json_file_path)
453
+ if success:
454
+ return f"File extraction completed. JSON file saved to: {json_file_path}"
455
+ else:
456
+ return f"Error saving JSON file: {error}"
457
+
458
+ # Gradio Interface
459
+ def process_directory(directory_path, extension, json_filename):
460
+ # Validate inputs
461
+ if not directory_path:
462
+ return "Please select a directory"
463
+ if not extension:
464
+ return "Please specify a file extension"
465
+ if not json_filename:
466
+ json_filename = "_Data.json"
467
+
468
+ # Ensure extension starts with a dot
469
+ if not extension.startswith('.'):
470
+ extension = '.' + extension
471
+
472
+ # Call the main function
473
+ result = ExtractDirectoryToJson(
474
+ directory_path=directory_path,
475
+ extension=extension,
476
+ json_file_path=json_filename
477
+ )
478
+ return result
479
+
480
+
481
+
482
+ FileTypes=['.txt','.md','.json','.py']
483
+
484
+ gr.Markdown("## Directory to JSON Extractor")
485
+ gr.Markdown("Extract text from files in a directory and save as JSON")
486
+
487
+ with gr.Row():
488
+ directory_input = gr.Textbox(label="Directory Path", placeholder="Path to directory containing files")
489
+ directory_btn = gr.Button("Browse")
490
+
491
+ with gr.Row():
492
+ extension_input = gr.Dropdown(label="File Extension",choices=FileTypes, interactive=True)
493
+ json_output = gr.Textbox(label="Output JSON Filename", value="_Data.json")
494
+
495
+ submitProcessDirectory_btn = gr.Button("Process Directory")
496
+ output_text = gr.JSON(label="Output")
497
+
498
+
499
+
500
+ # Main Crawling Tab
501
+ with gr.Tab("πŸ” Crawl Repository"):
502
+ with gr.Row():
503
+ with gr.Column(scale=1):
504
+ gr.Markdown("## 🎯 Source Configuration")
505
+
506
+ source_type = gr.Dropdown(
507
+ choices=["GitHub", "Local", "Hugging Face"],
508
+ label="Source Type",
509
+ value="GitHub"
510
+ )
511
+
512
+ # GitHub settings
513
+ with gr.Group(visible=True) as github_group:
514
+ repo_url = gr.Textbox(
515
+ label="GitHub Repository URL",
516
+ placeholder="https://github.com/owner/repo",
517
+ value=""
518
+ )
519
+ github_token = gr.Textbox(
520
+ label="GitHub Token (optional)",
521
+ type="password",
522
+ placeholder="ghp_..."
523
+ )
524
+
525
+ # Local settings
526
+ with gr.Group(visible=False) as local_group:
527
+ local_path = gr.Textbox(
528
+ label="Local Directory Path",
529
+ placeholder="/path/to/directory",
530
+ value=""
531
+ )
532
+
533
+ # Hugging Face settings
534
+ with gr.Group(visible=False) as hf_group:
535
+ hf_repo_id = gr.Textbox(
536
+ label="Hugging Face Repository ID",
537
+ placeholder="microsoft/DialoGPT-medium",
538
+ value=""
539
+ )
540
+ hf_repo_type = gr.Dropdown(
541
+ choices=["model", "dataset", "space"],
542
+ label="Repository Type",
543
+ value="model"
544
+ )
545
+ hf_token = gr.Textbox(
546
+ label="Hugging Face Token (optional)",
547
+ type="password",
548
+ placeholder="hf_..."
549
+ )
550
+
551
+ gr.Markdown("## βš™οΈ Crawling Options")
552
+
553
+ max_file_size = gr.Number(
554
+ label="Max File Size (MB)",
555
+ value=1,
556
+ minimum=0.1,
557
+ maximum=100
558
+ )
559
+
560
+ include_patterns = gr.Textbox(
561
+ label="Include Patterns (comma-separated)",
562
+ placeholder="*.py, *.js, *.md",
563
+ value=""
564
+ )
565
+
566
+ exclude_patterns = gr.Textbox(
567
+ label="Exclude Patterns (comma-separated)",
568
+ placeholder="*.pyc, __pycache__/*, .git/*",
569
+ value=""
570
+ )
571
+
572
+ use_relative_paths = gr.Checkbox(
573
+ label="Use Relative Paths",
574
+ value=True
575
+ )
576
+
577
+ crawl_btn = gr.Button("πŸš€ Start Crawling", variant="primary", size="lg")
578
+
579
+ with gr.Column(scale=2):
580
+ gr.Markdown("## πŸ“Š Results")
581
+
582
+ results_summary = gr.Textbox(
583
+ label="Crawling Summary",
584
+ lines=8,
585
+ interactive=False
586
+ )
587
+
588
+ file_list = gr.Dataframe(
589
+ label="Files Found",
590
+ headers=["File Path", "Size (chars)", "Type", "Lines"],
591
+ interactive=False,
592
+ wrap=True
593
+ )
594
+
595
+ # File Browser Tab
596
+ with gr.Tab("πŸ“ File Browser"):
597
+ with gr.Row():
598
+ with gr.Column(scale=1):
599
+ gr.Markdown("## πŸ“‚ File Selection")
600
+
601
+ selected_file = gr.Dropdown(
602
+ label="Select File",
603
+ choices=[],
604
+ interactive=True,
605
+ allow_custom_value=True
606
+ )
607
+
608
+ load_btn = gr.Button("πŸ“– Load File", variant="secondary")
609
+ save_btn = gr.Button("πŸ’Ύ Save Changes", variant="primary")
610
+
611
+ save_status = gr.Textbox(
612
+ label="Status",
613
+ lines=2,
614
+ interactive=False
615
+ )
616
+
617
+ with gr.Column(scale=3):
618
+ gr.Markdown("## ✏️ File Editor")
619
+
620
+ file_content = gr.Textbox(
621
+ label="File Content",
622
+ lines=25,
623
+ interactive=True,
624
+ show_copy_button=True,
625
+ placeholder="Select a file to view its content..."
626
+ )
627
+
628
+ # Export Tab
629
+ with gr.Tab("πŸ“€ Export"):
630
+ with gr.Row():
631
+ with gr.Column():
632
+ gr.Markdown("## πŸ’Ύ Export Options")
633
+
634
+ export_format = gr.Dropdown(
635
+ choices=["JSON", "File List", "Summary Report"],
636
+ label="Export Format",
637
+ value="JSON"
638
+ )
639
+
640
+ export_btn = gr.Button("πŸ“‹ Generate Export", variant="primary")
641
+
642
+ export_output = gr.Textbox(
643
+ label="Export Output",
644
+ lines=20,
645
+ show_copy_button=True,
646
+ interactive=False
647
+ )
648
+ with gr.Tab("🧠 Task Planning"):
649
+
650
+ with gr.Column(scale = 1):
651
+
652
+ with gr.Column():
653
+ with gr.Row():
654
+ sub_task_output = gr.Textbox(lines=4,show_label=True,container=False,label="Sub Tasks")
655
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>Task Strategy and Planning</div>")
656
+ with gr.Accordion("Task Graph", open=False):
657
+ task_graph_img = gr.Image(label="Task Reasoning Graph")
658
+ with gr.Row():
659
+ graph_btn = gr.Button("Visualize Task Graph",variant="huggingface")
660
+ with gr.Row():
661
+ with gr.Column():
662
+ task_input = gr.Textbox(lines = 10,label="Enter Task Description",placeholder = "Write a BPE Tokenizer in VB.NET")
663
+
664
+
665
+ with gr.Column():
666
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>Generated Code</div>")
667
+
668
+ with gr.Accordion("Generated Code", open=False):
669
+
670
+ task_code_output = gr.Code(show_label=True,container=True,label="Task Code Generated",language='python')
671
+
672
+ with gr.Row():
673
+ complexity_btn = gr.Button("Analyze Complexity", variant="huggingface")
674
+ decompose_btn = gr.Button("Decompose Task", variant="huggingface")
675
+ workflow_btn = gr.Button("Generate Workflow", variant="huggingface")
676
+ with gr.Row():
677
+ GeneratePlan_btn = gr.Button("Generate plan", variant="huggingface")
678
+ GenerateTaskCode_btn = gr.Button("Generate code", variant="huggingface")
679
+
680
+ with gr.Row():
681
+
682
+ with gr.Tabs():
683
+
684
+ with gr.Tab("Complexity"):
685
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>Task Complexity</div>")
686
+
687
+ complexity_output = gr.Markdown(show_label=True,max_height=600,container=True,show_copy_button = True,label="Task Complexity")
688
+
689
+ with gr.Tab("Planning"):
690
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>Sub Task Planning</div>")
691
+
692
+ decompose_output = gr.Markdown(show_label=True,container=True,show_copy_button = True,label="Task Analysis")
693
+
694
+ with gr.Tab("WorkFlow"):
695
+ gr.HTML(f"<div style='background: {config.COLORS['primary']}; color: {config.COLORS['background']}; padding: 10px; font-weight: bold;'>Task Work-Flow</div>")
696
+
697
+ workflow_output = gr.Markdown(show_label=True,container=True,label="Task WorkFlow")
698
+
699
+
700
+
701
+
702
+
703
+ # Footer
704
+ gr.HTML(f"""
705
+ <div style='text-align: center; padding: 10px; margin-top: 20px;
706
+ color: {config.COLORS['primary']}; font-size: 12px;
707
+ border-top: 2px solid {config.COLORS['primary']};'>
708
+ πŸš€ L.C.A.R.S - Enhanced Local Computer Advanced Reasoning System v3.0 β€’ Starfleet Command β€’ Computer Core Online
709
+ </div>
710
+ """)
711
+
712
 
713
 
714
  if __name__ == "__main__":