shukdevdatta123 commited on
Commit
5d2c0e5
Β·
verified Β·
1 Parent(s): 6a936d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -36
app.py CHANGED
@@ -93,11 +93,8 @@ class ReasoningOrchestra:
93
  return {"error": "API key not set"}
94
 
95
  prompt = f"""You are the Deep Thinker in a collaborative reasoning system. Your role is to provide thorough, methodical analysis with extensive step-by-step reasoning.
96
-
97
  Problem: {problem}
98
-
99
  {f"Additional Context: {context}" if context else ""}
100
-
101
  Please provide a comprehensive analysis with deep reasoning. Think through all implications, consider multiple angles, and provide detailed step-by-step logic. Be thorough and methodical in your approach."""
102
 
103
  try:
@@ -130,18 +127,14 @@ Please provide a comprehensive analysis with deep reasoning. Think through all i
130
  return {"error": "API key not set"}
131
 
132
  prompt = f"""You are the Quick Strategist in a collaborative reasoning system. Your role is to provide fast, efficient strategic analysis with clear action plans.
133
-
134
  Problem: {problem}
135
-
136
  {f"Additional Context: {context}" if context else ""}
137
-
138
  Please provide a strategic analysis with:
139
  1. Key insights and patterns
140
  2. Practical solutions
141
  3. Implementation priorities
142
  4. Risk assessment
143
  5. Clear next steps
144
-
145
  Be decisive and solution-focused. Provide concrete, actionable recommendations."""
146
 
147
  try:
@@ -173,11 +166,8 @@ Be decisive and solution-focused. Provide concrete, actionable recommendations."
173
  return {"error": "API key not set"}
174
 
175
  prompt = f"""You are the Detail Detective in a collaborative reasoning system. Your role is to provide meticulous investigation and comprehensive fact-checking.
176
-
177
  Problem: {problem}
178
-
179
  {f"Additional Context: {context}" if context else ""}
180
-
181
  Please conduct a thorough investigation including:
182
  1. Detailed analysis of all aspects
183
  2. Potential edge cases and considerations
@@ -185,7 +175,6 @@ Please conduct a thorough investigation including:
185
  4. Historical context or precedents
186
  5. Comprehensive pros and cons
187
  6. Hidden connections or implications
188
-
189
  Be extremely thorough and leave no stone unturned. Provide detailed evidence and reasoning for your conclusions."""
190
 
191
  try:
@@ -242,18 +231,13 @@ Be extremely thorough and leave no stone unturned. Provide detailed evidence and
242
  detective_reasoning = extract_reasoning(detective_result, "Detail Detective")
243
 
244
  synthesis_prompt = f"""You are the Orchestra Conductor using Llama 3.3 70B Versatile model. You have received analytical perspectives from three different AI reasoning specialists on the same problem. Your job is to synthesize these into a comprehensive, unified solution.
245
-
246
  ORIGINAL PROBLEM: {original_problem}
247
-
248
  DEEP THINKER ANALYSIS (🎭 DeepSeek R1):
249
  {deep_reasoning}
250
-
251
  STRATEGIC ANALYSIS (πŸš€ Qwen3 32B):
252
  {strategic_reasoning}
253
-
254
  DETECTIVE INVESTIGATION (πŸ” QwQ 32B):
255
  {detective_reasoning}
256
-
257
  As the Orchestra Conductor, please create a unified synthesis that:
258
  1. Combines the best insights from all available analyses
259
  2. Addresses any gaps where models didn't provide input
@@ -261,9 +245,7 @@ As the Orchestra Conductor, please create a unified synthesis that:
261
  4. Provides a comprehensive final recommendation
262
  5. Highlights where the different reasoning styles complement each other
263
  6. Gives a clear, actionable conclusion
264
-
265
  If some models didn't provide analysis, work with what's available and note any limitations.
266
-
267
  Format your response as a well-structured final solution that leverages all available reasoning approaches. Use clear sections and bullet points where appropriate for maximum clarity."""
268
 
269
  try:
@@ -430,28 +412,25 @@ def run_full_orchestra(problem: str, context: str = "") -> Tuple[str, str, str,
430
 
431
  return deep_output, strategic_output, detective_output, synthesis_output
432
 
433
- # Custom CSS for better styling with consistent font sizes
434
  custom_css = """
435
  .gradio-container {
436
- max-width: 1400px !important;
437
  margin: 0 auto !important;
438
  font-size: 16px !important;
439
  }
440
-
441
  .api-key-section {
442
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
443
  padding: 20px;
444
  border-radius: 10px;
445
  margin-bottom: 20px;
446
  }
447
-
448
  .model-section {
449
  border: 2px solid #e1e5e9;
450
  border-radius: 10px;
451
  padding: 15px;
452
  margin: 10px 0;
453
  }
454
-
455
  .orchestra-header {
456
  text-align: center;
457
  background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
@@ -460,7 +439,6 @@ custom_css = """
460
  margin-bottom: 20px;
461
  font-size: 16px;
462
  }
463
-
464
  .status-box {
465
  background-color: #f8f9fa;
466
  border-left: 4px solid #28a745;
@@ -469,9 +447,15 @@ custom_css = """
469
  border-radius: 5px;
470
  font-size: 16px;
471
  }
472
-
473
- /* Custom styling for HTML outputs */
 
 
 
 
474
  .html-content {
 
 
475
  max-height: 600px;
476
  overflow-y: auto;
477
  border: 1px solid #ddd;
@@ -480,32 +464,47 @@ custom_css = """
480
  background-color: #fafafa;
481
  font-size: 16px !important;
482
  }
483
-
484
  /* Ensure all text has consistent font size */
485
  p, li, span, div, textarea, input, select, button {
486
  font-size: 16px !important;
487
  }
488
-
489
  h1 {
490
  font-size: 24px !important;
491
  }
492
-
493
  h2 {
494
  font-size: 22px !important;
495
  }
496
-
497
  h3 {
498
  font-size: 20px !important;
499
  }
500
-
501
  h4 {
502
  font-size: 18px !important;
503
  }
504
-
505
  /* Make sure code blocks are readable */
506
  pre, code {
507
  font-size: 15px !important;
508
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
  """
510
 
511
  # Build the Gradio interface
@@ -551,8 +550,8 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Ocean(), title="Reasoning Orchest
551
  with gr.TabItem("🎯 Single Model Analysis"):
552
  gr.Markdown("### Test individual reasoning models with beautiful HTML output")
553
 
554
- with gr.Row():
555
- with gr.Column(scale=1):
556
  single_problem = gr.Textbox(
557
  label="Problem Statement",
558
  placeholder="Enter the problem you want to analyze...",
@@ -577,7 +576,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Ocean(), title="Reasoning Orchest
577
  )
578
  single_analyze_btn = gr.Button("πŸš€ Analyze with HTML Output", variant="primary", size="lg", elem_id="single_analyze_btn")
579
 
580
- with gr.Column(scale=2):
581
  single_output = gr.HTML(label="Analysis Result", elem_classes=["html-content"], elem_id="single_output")
582
 
583
  single_analyze_btn.click(
@@ -608,7 +607,7 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Ocean(), title="Reasoning Orchest
608
  orchestra_analyze_btn = gr.Button("🎼 Start Orchestra Analysis", variant="primary", size="lg", elem_id="orchestra_analyze_btn")
609
 
610
  # Orchestra Results
611
- with gr.Column():
612
  deep_output = gr.HTML(label="🎭 Deep Thinker Analysis", elem_classes=["html-content"], elem_id="deep_output")
613
  strategic_output = gr.HTML(label="πŸš€ Quick Strategist Analysis", elem_classes=["html-content"], elem_id="strategic_output")
614
  detective_output = gr.HTML(label="πŸ” Detail Detective Analysis", elem_classes=["html-content"], elem_id="detective_output")
 
93
  return {"error": "API key not set"}
94
 
95
  prompt = f"""You are the Deep Thinker in a collaborative reasoning system. Your role is to provide thorough, methodical analysis with extensive step-by-step reasoning.
 
96
  Problem: {problem}
 
97
  {f"Additional Context: {context}" if context else ""}
 
98
  Please provide a comprehensive analysis with deep reasoning. Think through all implications, consider multiple angles, and provide detailed step-by-step logic. Be thorough and methodical in your approach."""
99
 
100
  try:
 
127
  return {"error": "API key not set"}
128
 
129
  prompt = f"""You are the Quick Strategist in a collaborative reasoning system. Your role is to provide fast, efficient strategic analysis with clear action plans.
 
130
  Problem: {problem}
 
131
  {f"Additional Context: {context}" if context else ""}
 
132
  Please provide a strategic analysis with:
133
  1. Key insights and patterns
134
  2. Practical solutions
135
  3. Implementation priorities
136
  4. Risk assessment
137
  5. Clear next steps
 
138
  Be decisive and solution-focused. Provide concrete, actionable recommendations."""
139
 
140
  try:
 
166
  return {"error": "API key not set"}
167
 
168
  prompt = f"""You are the Detail Detective in a collaborative reasoning system. Your role is to provide meticulous investigation and comprehensive fact-checking.
 
169
  Problem: {problem}
 
170
  {f"Additional Context: {context}" if context else ""}
 
171
  Please conduct a thorough investigation including:
172
  1. Detailed analysis of all aspects
173
  2. Potential edge cases and considerations
 
175
  4. Historical context or precedents
176
  5. Comprehensive pros and cons
177
  6. Hidden connections or implications
 
178
  Be extremely thorough and leave no stone unturned. Provide detailed evidence and reasoning for your conclusions."""
179
 
180
  try:
 
231
  detective_reasoning = extract_reasoning(detective_result, "Detail Detective")
232
 
233
  synthesis_prompt = f"""You are the Orchestra Conductor using Llama 3.3 70B Versatile model. You have received analytical perspectives from three different AI reasoning specialists on the same problem. Your job is to synthesize these into a comprehensive, unified solution.
 
234
  ORIGINAL PROBLEM: {original_problem}
 
235
  DEEP THINKER ANALYSIS (🎭 DeepSeek R1):
236
  {deep_reasoning}
 
237
  STRATEGIC ANALYSIS (πŸš€ Qwen3 32B):
238
  {strategic_reasoning}
 
239
  DETECTIVE INVESTIGATION (πŸ” QwQ 32B):
240
  {detective_reasoning}
 
241
  As the Orchestra Conductor, please create a unified synthesis that:
242
  1. Combines the best insights from all available analyses
243
  2. Addresses any gaps where models didn't provide input
 
245
  4. Provides a comprehensive final recommendation
246
  5. Highlights where the different reasoning styles complement each other
247
  6. Gives a clear, actionable conclusion
 
248
  If some models didn't provide analysis, work with what's available and note any limitations.
 
249
  Format your response as a well-structured final solution that leverages all available reasoning approaches. Use clear sections and bullet points where appropriate for maximum clarity."""
250
 
251
  try:
 
412
 
413
  return deep_output, strategic_output, detective_output, synthesis_output
414
 
415
+ # Custom CSS for consistent width and styling
416
  custom_css = """
417
  .gradio-container {
418
+ max-width: 1200px !important;
419
  margin: 0 auto !important;
420
  font-size: 16px !important;
421
  }
 
422
  .api-key-section {
423
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
424
  padding: 20px;
425
  border-radius: 10px;
426
  margin-bottom: 20px;
427
  }
 
428
  .model-section {
429
  border: 2px solid #e1e5e9;
430
  border-radius: 10px;
431
  padding: 15px;
432
  margin: 10px 0;
433
  }
 
434
  .orchestra-header {
435
  text-align: center;
436
  background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
 
439
  margin-bottom: 20px;
440
  font-size: 16px;
441
  }
 
442
  .status-box {
443
  background-color: #f8f9fa;
444
  border-left: 4px solid #28a745;
 
447
  border-radius: 5px;
448
  font-size: 16px;
449
  }
450
+ /* Consistent width for all tabs */
451
+ .tab {
452
+ width: 100% !important;
453
+ max-width: 1200px !important;
454
+ }
455
+ /* Custom styling for HTML outputs with fixed width */
456
  .html-content {
457
+ width: 100% !important;
458
+ max-width: 1200px !important;
459
  max-height: 600px;
460
  overflow-y: auto;
461
  border: 1px solid #ddd;
 
464
  background-color: #fafafa;
465
  font-size: 16px !important;
466
  }
 
467
  /* Ensure all text has consistent font size */
468
  p, li, span, div, textarea, input, select, button {
469
  font-size: 16px !important;
470
  }
 
471
  h1 {
472
  font-size: 24px !important;
473
  }
 
474
  h2 {
475
  font-size: 22px !important;
476
  }
 
477
  h3 {
478
  font-size: 20px !important;
479
  }
 
480
  h4 {
481
  font-size: 18px !important;
482
  }
 
483
  /* Make sure code blocks are readable */
484
  pre, code {
485
  font-size: 15px !important;
486
  }
487
+ /* Single model analysis layout */
488
+ .single-model-container {
489
+ display: flex;
490
+ flex-direction: column;
491
+ gap: 20px;
492
+ width: 100% !important;
493
+ }
494
+ .single-model-inputs {
495
+ width: 100% !important;
496
+ }
497
+ .single-model-output {
498
+ width: 100% !important;
499
+ margin-top: 20px;
500
+ }
501
+ /* Full orchestra layout */
502
+ .orchestra-outputs {
503
+ display: flex;
504
+ flex-direction: column;
505
+ gap: 20px;
506
+ width: 100% !important;
507
+ }
508
  """
509
 
510
  # Build the Gradio interface
 
550
  with gr.TabItem("🎯 Single Model Analysis"):
551
  gr.Markdown("### Test individual reasoning models with beautiful HTML output")
552
 
553
+ with gr.Column(elem_classes=["single-model-container"]):
554
+ with gr.Column(elem_classes=["single-model-inputs"]):
555
  single_problem = gr.Textbox(
556
  label="Problem Statement",
557
  placeholder="Enter the problem you want to analyze...",
 
576
  )
577
  single_analyze_btn = gr.Button("πŸš€ Analyze with HTML Output", variant="primary", size="lg", elem_id="single_analyze_btn")
578
 
579
+ with gr.Column(elem_classes=["single-model-output"]):
580
  single_output = gr.HTML(label="Analysis Result", elem_classes=["html-content"], elem_id="single_output")
581
 
582
  single_analyze_btn.click(
 
607
  orchestra_analyze_btn = gr.Button("🎼 Start Orchestra Analysis", variant="primary", size="lg", elem_id="orchestra_analyze_btn")
608
 
609
  # Orchestra Results
610
+ with gr.Column(elem_classes=["orchestra-outputs"]):
611
  deep_output = gr.HTML(label="🎭 Deep Thinker Analysis", elem_classes=["html-content"], elem_id="deep_output")
612
  strategic_output = gr.HTML(label="πŸš€ Quick Strategist Analysis", elem_classes=["html-content"], elem_id="strategic_output")
613
  detective_output = gr.HTML(label="πŸ” Detail Detective Analysis", elem_classes=["html-content"], elem_id="detective_output")