Chris commited on
Commit
65443cb
·
1 Parent(s): 85c44e6

Final 5.4.3

Browse files
src/__pycache__/app.cpython-310.pyc CHANGED
Binary files a/src/__pycache__/app.cpython-310.pyc and b/src/__pycache__/app.cpython-310.pyc differ
 
src/app.py CHANGED
@@ -239,6 +239,25 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
239
  username = f"{profile.username}"
240
  oauth_token = getattr(profile, 'oauth_token', None) or getattr(profile, 'token', None)
241
  logger.info(f"User logged in: {username}, Token available: {oauth_token is not None}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  else:
243
  logger.info("User not logged in.")
244
  return "Please Login to Hugging Face with the button.", None
@@ -247,17 +266,17 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
247
  questions_url = f"{api_url}/questions"
248
  submit_url = f"{api_url}/submit"
249
 
250
- # 1. Instantiate GAIA Agent with OAuth token
251
  try:
252
  if oauth_token:
253
- logger.info("Creating GAIA Agent with OAuth token")
254
  agent = GAIAAgentApp.create_with_oauth_token(oauth_token)
255
  else:
256
- logger.warning("No OAuth token found, falling back to environment variables")
257
- agent = GAIAAgentApp()
258
 
259
  if not agent.initialized:
260
- return "Error: GAIA Agent failed to initialize - likely authentication issue", None
261
  except Exception as e:
262
  logger.error(f"Error instantiating agent: {e}")
263
  return f"Error initializing GAIA Agent: {e}", None
@@ -418,7 +437,7 @@ def create_interface():
418
  border-radius: 6px !important;
419
  }
420
 
421
- /* Buttons - Professional neutral theme */
422
  .gradio-container button,
423
  .gradio-container .gr-button,
424
  .gradio-container .gr-button-primary,
@@ -427,53 +446,65 @@ def create_interface():
427
  .gradio-container .gr-button *,
428
  .gradio-container .gr-button-primary *,
429
  .gradio-container .gr-button-secondary * {
430
- color: white !important;
431
  font-weight: 500 !important;
432
  text-shadow: none !important;
433
  border-radius: 6px !important;
 
 
434
  }
435
 
436
  .gradio-container .gr-button-primary,
437
  .gradio-container button[variant="primary"] {
438
- background: #8b7355 !important;
439
- color: white !important;
440
- border: none !important;
441
  padding: 8px 16px !important;
442
  border-radius: 6px !important;
443
  }
444
 
445
  .gradio-container .gr-button-secondary,
446
  .gradio-container button[variant="secondary"] {
447
- background: #a08b73 !important;
448
- color: white !important;
449
- border: none !important;
450
  padding: 8px 16px !important;
451
  border-radius: 6px !important;
452
  }
453
 
454
  .gradio-container button:not([variant]) {
455
- background: #6b5d4f !important;
456
- color: white !important;
457
- border: none !important;
458
  padding: 8px 16px !important;
459
  border-radius: 6px !important;
460
  }
461
 
462
- /* Button hover states */
463
  .gradio-container button:hover,
464
  .gradio-container .gr-button:hover,
465
  .gradio-container .gr-button-primary:hover {
466
- background: #756749 !important;
467
- color: white !important;
 
468
  transform: translateY(-1px) !important;
469
- box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
470
  }
471
 
472
  .gradio-container .gr-button-secondary:hover {
473
- background: #8f7c65 !important;
474
- color: white !important;
 
475
  transform: translateY(-1px) !important;
476
- box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
 
 
 
 
 
 
 
 
477
  }
478
 
479
  /* Markdown content */
@@ -593,11 +624,44 @@ def create_interface():
593
  border-radius: 8px !important;
594
  }
595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  /* Loading states */
597
  .gradio-container .loading {
598
  background-color: #f5f3f0 !important;
599
  color: #6b5d4f !important;
600
  }
 
 
 
 
 
 
 
 
 
601
  """
602
 
603
  with gr.Blocks(css=css, title="GAIA Agent System", theme=gr.themes.Soft()) as interface:
@@ -628,6 +692,10 @@ def create_interface():
628
  3. View your official score and detailed results
629
 
630
  ⚠️ **Note**: This may take several minutes to process all questions.
 
 
 
 
631
  """)
632
 
633
  gr.LoginButton()
 
239
  username = f"{profile.username}"
240
  oauth_token = getattr(profile, 'oauth_token', None) or getattr(profile, 'token', None)
241
  logger.info(f"User logged in: {username}, Token available: {oauth_token is not None}")
242
+
243
+ # Check if OAuth token has sufficient scopes
244
+ if oauth_token:
245
+ try:
246
+ import requests
247
+ headers = {"Authorization": f"Bearer {oauth_token}"}
248
+ test_response = requests.get("https://huggingface.co/api/whoami", headers=headers, timeout=5)
249
+
250
+ if test_response.status_code == 401:
251
+ logger.warning("⚠️ OAuth token has insufficient scopes for model inference")
252
+ oauth_token = None # Force fallback to SimpleClient
253
+ elif test_response.status_code == 200:
254
+ logger.info("✅ OAuth token validated successfully")
255
+ else:
256
+ logger.warning(f"⚠️ OAuth token validation returned {test_response.status_code}")
257
+
258
+ except Exception as e:
259
+ logger.warning(f"⚠️ Could not validate OAuth token: {e}")
260
+
261
  else:
262
  logger.info("User not logged in.")
263
  return "Please Login to Hugging Face with the button.", None
 
266
  questions_url = f"{api_url}/questions"
267
  submit_url = f"{api_url}/submit"
268
 
269
+ # 1. Instantiate GAIA Agent with OAuth token or fallback
270
  try:
271
  if oauth_token:
272
+ logger.info("Creating GAIA Agent with validated OAuth token")
273
  agent = GAIAAgentApp.create_with_oauth_token(oauth_token)
274
  else:
275
+ logger.info("Creating GAIA Agent with fallback authentication (limited OAuth scopes detected)")
276
+ agent = GAIAAgentApp() # This will automatically fallback to SimpleClient
277
 
278
  if not agent.initialized:
279
+ return "Error: GAIA Agent failed to initialize - using SimpleClient fallback for limited OAuth", None
280
  except Exception as e:
281
  logger.error(f"Error instantiating agent: {e}")
282
  return f"Error initializing GAIA Agent: {e}", None
 
437
  border-radius: 6px !important;
438
  }
439
 
440
+ /* Buttons - Subtle professional styling */
441
  .gradio-container button,
442
  .gradio-container .gr-button,
443
  .gradio-container .gr-button-primary,
 
446
  .gradio-container .gr-button *,
447
  .gradio-container .gr-button-primary *,
448
  .gradio-container .gr-button-secondary * {
449
+ color: #3c3c3c !important;
450
  font-weight: 500 !important;
451
  text-shadow: none !important;
452
  border-radius: 6px !important;
453
+ border: 1px solid #d4c4b0 !important;
454
+ transition: all 0.2s ease !important;
455
  }
456
 
457
  .gradio-container .gr-button-primary,
458
  .gradio-container button[variant="primary"] {
459
+ background: #f5f3f0 !important;
460
+ color: #3c3c3c !important;
461
+ border: 1px solid #d4c4b0 !important;
462
  padding: 8px 16px !important;
463
  border-radius: 6px !important;
464
  }
465
 
466
  .gradio-container .gr-button-secondary,
467
  .gradio-container button[variant="secondary"] {
468
+ background: #ffffff !important;
469
+ color: #3c3c3c !important;
470
+ border: 1px solid #d4c4b0 !important;
471
  padding: 8px 16px !important;
472
  border-radius: 6px !important;
473
  }
474
 
475
  .gradio-container button:not([variant]) {
476
+ background: #f8f6f3 !important;
477
+ color: #3c3c3c !important;
478
+ border: 1px solid #d4c4b0 !important;
479
  padding: 8px 16px !important;
480
  border-radius: 6px !important;
481
  }
482
 
483
+ /* Button hover states - subtle changes */
484
  .gradio-container button:hover,
485
  .gradio-container .gr-button:hover,
486
  .gradio-container .gr-button-primary:hover {
487
+ background: #ede9e4 !important;
488
+ color: #2c2c2c !important;
489
+ border: 1px solid #c4b49f !important;
490
  transform: translateY(-1px) !important;
491
+ box-shadow: 0 2px 4px rgba(0,0,0,0.08) !important;
492
  }
493
 
494
  .gradio-container .gr-button-secondary:hover {
495
+ background: #f5f3f0 !important;
496
+ color: #2c2c2c !important;
497
+ border: 1px solid #c4b49f !important;
498
  transform: translateY(-1px) !important;
499
+ box-shadow: 0 2px 4px rgba(0,0,0,0.08) !important;
500
+ }
501
+
502
+ /* Login button styling */
503
+ .gradio-container .gr-button:contains("Login"),
504
+ .gradio-container button:contains("Login") {
505
+ background: #e8e3dc !important;
506
+ color: #3c3c3c !important;
507
+ border: 1px solid #d4c4b0 !important;
508
  }
509
 
510
  /* Markdown content */
 
624
  border-radius: 8px !important;
625
  }
626
 
627
+ /* Override any remaining purple/blue elements */
628
+ .gradio-container .gr-textbox,
629
+ .gradio-container .gr-dropdown,
630
+ .gradio-container .gr-number,
631
+ .gradio-container .gr-slider {
632
+ background-color: #ffffff !important;
633
+ border: 1px solid #d4c4b0 !important;
634
+ color: #3c3c3c !important;
635
+ }
636
+
637
+ /* Force override any Gradio default styling */
638
+ .gradio-container * {
639
+ background-color: inherit !important;
640
+ }
641
+
642
+ .gradio-container *[style*="background-color: rgb(239, 68, 68)"],
643
+ .gradio-container *[style*="background-color: rgb(59, 130, 246)"],
644
+ .gradio-container *[style*="background-color: rgb(147, 51, 234)"],
645
+ .gradio-container *[style*="background-color: rgb(16, 185, 129)"] {
646
+ background-color: #f5f3f0 !important;
647
+ color: #3c3c3c !important;
648
+ border: 1px solid #d4c4b0 !important;
649
+ }
650
+
651
  /* Loading states */
652
  .gradio-container .loading {
653
  background-color: #f5f3f0 !important;
654
  color: #6b5d4f !important;
655
  }
656
+
657
+ /* Progress bars */
658
+ .gradio-container .gr-progress {
659
+ background-color: #f5f3f0 !important;
660
+ }
661
+
662
+ .gradio-container .gr-progress-bar {
663
+ background-color: #a08b73 !important;
664
+ }
665
  """
666
 
667
  with gr.Blocks(css=css, title="GAIA Agent System", theme=gr.themes.Soft()) as interface:
 
692
  3. View your official score and detailed results
693
 
694
  ⚠️ **Note**: This may take several minutes to process all questions.
695
+
696
+ 💡 **OAuth Limitations**: If your OAuth token has limited scopes (common with Gradio OAuth),
697
+ the system will automatically use a reliable fallback that still provides accurate answers
698
+ for basic questions but may have reduced performance on complex queries.
699
  """)
700
 
701
  gr.LoginButton()
src/production_deployment_guide.md CHANGED
@@ -137,9 +137,31 @@ LANGCHAIN_PROJECT=gaia-agent # Optional: LangSmith project
137
  # Production OAuth Flow:
138
  1. User clicks "Login with HuggingFace" button
139
  2. OAuth flow provides profile with token
140
- 3. run_and_submit_all(profile) extracts oauth_token
141
- 4. GAIAAgentApp.create_with_oauth_token(oauth_token)
142
- 5. All API calls use user's OAuth token
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  ```
144
 
145
  ### 6. Deployment Process
 
137
  # Production OAuth Flow:
138
  1. User clicks "Login with HuggingFace" button
139
  2. OAuth flow provides profile with token
140
+ 3. System validates OAuth token scopes
141
+ 4. If sufficient scopes: Use OAuth token for model access
142
+ 5. If limited scopes: Gracefully fallback to SimpleClient
143
+ 6. Always provides working responses regardless of token scopes
144
+ ```
145
+
146
+ #### OAuth Scope Limitations ⚠️
147
+
148
+ **Common Issue**: Gradio OAuth tokens often have **limited scopes** by default:
149
+ - ✅ **"read" scope**: Can access user profile, model info
150
+ - ❌ **"inference" scope**: Cannot access model generation APIs
151
+ - ❌ **"write" scope**: Cannot perform model inference
152
+
153
+ **System Behavior**:
154
+ - **High-scope token**: Uses advanced models (Qwen, FLAN-T5) → 30%+ GAIA performance
155
+ - **Limited-scope token**: Uses SimpleClient fallback → 15%+ GAIA performance
156
+ - **No token**: Uses SimpleClient fallback → 15%+ GAIA performance
157
+
158
+ **Detection & Handling**:
159
+ ```python
160
+ # Automatic scope validation
161
+ test_response = requests.get("https://huggingface.co/api/whoami", headers=headers)
162
+ if test_response.status_code == 401:
163
+ # Limited scopes detected - use fallback
164
+ oauth_token = None
165
  ```
166
 
167
  ### 6. Deployment Process