Graham Paasch commited on
Commit
bf1169f
·
1 Parent(s): cb3e0e6

Allow per-run Anthropic/OpenAI key entry in UI

Browse files
Files changed (1) hide show
  1. app.py +32 -2
app.py CHANGED
@@ -436,6 +436,17 @@ def build_ui():
436
  ],
437
  value="Design new (greenfield)"
438
  )
 
 
 
 
 
 
 
 
 
 
 
439
  gns3_project_input = gr.Dropdown(
440
  label="GNS3 project (brownfield)",
441
  choices=project_choices or ["overgrowth"],
@@ -470,11 +481,21 @@ def build_ui():
470
  setup_output = gr.Markdown(label="Deployment Guide")
471
 
472
  # Pipeline handler
473
- def run_pipeline(user_input, mode_choice, gns3_project, sot_path, simulation_only_flag, read_only_flag):
474
  """Execute the full automation pipeline"""
475
  from agent.pipeline_engine import OvergrowthPipeline
476
  from agent.llm_client import LLMClient
477
 
 
 
 
 
 
 
 
 
 
 
478
  pipeline = OvergrowthPipeline()
479
 
480
  try:
@@ -765,7 +786,16 @@ def build_ui():
765
  # Event Handlers
766
  run_pipeline_btn.click(
767
  fn=run_pipeline,
768
- inputs=[pipeline_input, mode_choice, gns3_project_input, sot_path_input, simulation_only, read_only_validation],
 
 
 
 
 
 
 
 
 
769
  outputs=[pipeline_status, sot_output, bom_output, setup_output, api_stats, api_activity],
770
  )
771
 
 
436
  ],
437
  value="Design new (greenfield)"
438
  )
439
+ gr.Markdown("**Optional: provide an API key to override defaults for this run**")
440
+ anthropic_key_box = gr.Textbox(
441
+ label="Anthropic API Key (optional)",
442
+ placeholder="sk-ant-...",
443
+ type="password",
444
+ )
445
+ openai_key_box = gr.Textbox(
446
+ label="OpenAI API Key (optional)",
447
+ placeholder="sk-...",
448
+ type="password",
449
+ )
450
  gns3_project_input = gr.Dropdown(
451
  label="GNS3 project (brownfield)",
452
  choices=project_choices or ["overgrowth"],
 
481
  setup_output = gr.Markdown(label="Deployment Guide")
482
 
483
  # Pipeline handler
484
+ def run_pipeline(user_input, mode_choice, gns3_project, sot_path, simulation_only_flag, read_only_flag, anthropic_key, openai_key):
485
  """Execute the full automation pipeline"""
486
  from agent.pipeline_engine import OvergrowthPipeline
487
  from agent.llm_client import LLMClient
488
 
489
+ # Apply per-run API keys (not persisted)
490
+ if anthropic_key:
491
+ os.environ["ANTHROPIC_API_KEY"] = anthropic_key.strip()
492
+ os.environ["ANTHROPIC_MCP_1ST_BDAY"] = anthropic_key.strip()
493
+ os.environ["OG_LLM_PROVIDER"] = "anthropic"
494
+ elif openai_key:
495
+ os.environ["OPENAI_API_KEY"] = openai_key.strip()
496
+ os.environ["OPENAI_MCP_1ST_BDAY"] = openai_key.strip()
497
+ os.environ["OG_LLM_PROVIDER"] = "openai"
498
+
499
  pipeline = OvergrowthPipeline()
500
 
501
  try:
 
786
  # Event Handlers
787
  run_pipeline_btn.click(
788
  fn=run_pipeline,
789
+ inputs=[
790
+ pipeline_input,
791
+ mode_choice,
792
+ gns3_project_input,
793
+ sot_path_input,
794
+ simulation_only,
795
+ read_only_validation,
796
+ anthropic_key_box,
797
+ openai_key_box,
798
+ ],
799
  outputs=[pipeline_status, sot_output, bom_output, setup_output, api_stats, api_activity],
800
  )
801