jcmiao commited on
Commit
4f82d26
Β·
verified Β·
1 Parent(s): 51f80a0

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +4 -21
  2. test.py +2 -1
app.py CHANGED
@@ -38,12 +38,6 @@ Please be patient β€” takes about 20–30 minutes to process.
38
  placeholder="https://github.com/google-deepmind/alphagenome"
39
  )
40
 
41
- key_in = gr.Textbox(
42
- label="πŸ”‘ Claude API Key",
43
- placeholder="sk-ant-...",
44
- type="password"
45
- )
46
-
47
  repo_key_in = gr.Textbox(
48
  label="πŸ” API Key (optional, for repositories requiring authentication)",
49
  placeholder="Enter API key for private repositories",
@@ -67,10 +61,6 @@ Please be patient β€” takes about 20–30 minutes to process.
67
  <div style="font-weight: bold; margin-bottom: 2px;">GitHub URL:</div>
68
  <code style="display: block; background: white; padding: 6px 8px; border-radius: 4px; border: 1px solid #ddd; word-break: break-all;">https://github.com/google-deepmind/alphagenome</code>
69
  </div>
70
- <div style="margin-bottom: 8px;">
71
- <div style="font-weight: bold; margin-bottom: 2px;">Claude API Key:</div>
72
- <code style="display: block; background: white; padding: 6px 8px; border-radius: 4px; border: 1px solid #ddd; word-break: break-all;">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</code>
73
- </div>
74
  <div>
75
  <div style="font-weight: bold; margin-bottom: 2px;">Repo API Key:</div>
76
  <code style="display: block; background: white; padding: 6px 8px; border-radius: 4px; border: 1px solid #ddd; word-break: break-all;">AIzaSyDZ-IxStzMSUElDGWS7U9v6BIDr_0WMoO8</code>
@@ -103,13 +93,12 @@ Please be patient β€” takes about 20–30 minutes to process.
103
  def fill_example():
104
  return (
105
  "https://github.com/google-deepmind/alphagenome",
106
- "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",
107
  "AIzaSyDZ-IxStzMSUElDGWS7U9v6BIDr_0WMoO8",
108
  ""
109
  )
110
 
111
  # Button click handler
112
- def run_pipeline(github_url, repo_api_key, claude_api_key, tutorials_filter):
113
  """
114
  Run the Paper2Agent pipeline with the provided inputs.
115
  """
@@ -124,17 +113,12 @@ Please be patient β€” takes about 20–30 minutes to process.
124
  ui_logs.append("❌ Error: GitHub Repo URL is required")
125
  return "\n".join(ui_logs), None, ""
126
 
127
- if not claude_api_key or not claude_api_key.strip():
128
- ui_logs.append("❌ Error: Claude API Key is required")
129
- return "\n".join(ui_logs), None, ""
130
-
131
  # Create Results folder
132
  results_path = ROOT / "Results"
133
  results_path.mkdir(parents=True, exist_ok=True)
134
 
135
  ui_logs.append(f"πŸš€ Starting Paper2Agent pipeline...")
136
  ui_logs.append(f"πŸ“˜ GitHub Repo: {github_url}")
137
- ui_logs.append(f"πŸ”‘ Claude API Key: {'*' * (len(claude_api_key) - 4)}{claude_api_key[-4:]}")
138
 
139
  if tutorials_filter:
140
  ui_logs.append(f"πŸ“š Tutorial Filter: {tutorials_filter}")
@@ -143,9 +127,8 @@ Please be patient β€” takes about 20–30 minutes to process.
143
  ui_logs.append("\n" + "="*70)
144
  yield "\n".join(ui_logs), None, ""
145
 
146
- # Set environment variable for Claude API key (for SDK initialization)
147
  env = os.environ.copy()
148
- env['ANTHROPIC_API_KEY'] = claude_api_key
149
  env['PYTHONUNBUFFERED'] = '1'
150
 
151
  # Build command with unbuffered Python
@@ -233,13 +216,13 @@ Please be patient β€” takes about 20–30 minutes to process.
233
  example_btn.click(
234
  fn=fill_example,
235
  inputs=[],
236
- outputs=[github_in, key_in, repo_key_in, tutorials_in]
237
  )
238
 
239
  # Connect run button
240
  run_btn.click(
241
  fn=run_pipeline,
242
- inputs=[github_in, repo_key_in, key_in, tutorials_in],
243
  outputs=[logs_out, zip_out, overleaf_out]
244
  )
245
 
 
38
  placeholder="https://github.com/google-deepmind/alphagenome"
39
  )
40
 
 
 
 
 
 
 
41
  repo_key_in = gr.Textbox(
42
  label="πŸ” API Key (optional, for repositories requiring authentication)",
43
  placeholder="Enter API key for private repositories",
 
61
  <div style="font-weight: bold; margin-bottom: 2px;">GitHub URL:</div>
62
  <code style="display: block; background: white; padding: 6px 8px; border-radius: 4px; border: 1px solid #ddd; word-break: break-all;">https://github.com/google-deepmind/alphagenome</code>
63
  </div>
 
 
 
 
64
  <div>
65
  <div style="font-weight: bold; margin-bottom: 2px;">Repo API Key:</div>
66
  <code style="display: block; background: white; padding: 6px 8px; border-radius: 4px; border: 1px solid #ddd; word-break: break-all;">AIzaSyDZ-IxStzMSUElDGWS7U9v6BIDr_0WMoO8</code>
 
93
  def fill_example():
94
  return (
95
  "https://github.com/google-deepmind/alphagenome",
 
96
  "AIzaSyDZ-IxStzMSUElDGWS7U9v6BIDr_0WMoO8",
97
  ""
98
  )
99
 
100
  # Button click handler
101
+ def run_pipeline(github_url, repo_api_key, tutorials_filter):
102
  """
103
  Run the Paper2Agent pipeline with the provided inputs.
104
  """
 
113
  ui_logs.append("❌ Error: GitHub Repo URL is required")
114
  return "\n".join(ui_logs), None, ""
115
 
 
 
 
 
116
  # Create Results folder
117
  results_path = ROOT / "Results"
118
  results_path.mkdir(parents=True, exist_ok=True)
119
 
120
  ui_logs.append(f"πŸš€ Starting Paper2Agent pipeline...")
121
  ui_logs.append(f"πŸ“˜ GitHub Repo: {github_url}")
 
122
 
123
  if tutorials_filter:
124
  ui_logs.append(f"πŸ“š Tutorial Filter: {tutorials_filter}")
 
127
  ui_logs.append("\n" + "="*70)
128
  yield "\n".join(ui_logs), None, ""
129
 
130
+ # Set environment for subprocess
131
  env = os.environ.copy()
 
132
  env['PYTHONUNBUFFERED'] = '1'
133
 
134
  # Build command with unbuffered Python
 
216
  example_btn.click(
217
  fn=fill_example,
218
  inputs=[],
219
+ outputs=[github_in, repo_key_in, tutorials_in]
220
  )
221
 
222
  # Connect run button
223
  run_btn.click(
224
  fn=run_pipeline,
225
+ inputs=[github_in, repo_key_in, tutorials_in],
226
  outputs=[logs_out, zip_out, overleaf_out]
227
  )
228
 
test.py CHANGED
@@ -18,7 +18,8 @@ from pathlib import Path
18
  from utils import copy_project_resources, clone_github_repo, prepare_folder_structure
19
  from prompts.tasks import step1_environment_setup_and_tutorial_discovery, step2_tutorial_execution, step3_tool_extraction_and_testing, step4_mcp_integration
20
 
21
- # ANTHROPIC_API_KEY should be set via environment variable by the caller (app.py)
 
22
 
23
  async def fully_automatic(tasks: list, task_descriptions: list = None, log_file_path: str = None):
24
  options = ClaudeAgentOptions(
 
18
  from utils import copy_project_resources, clone_github_repo, prepare_folder_structure
19
  from prompts.tasks import step1_environment_setup_and_tutorial_discovery, step2_tutorial_execution, step3_tool_extraction_and_testing, step4_mcp_integration
20
 
21
+ # Read API key from environment variable
22
+ api_key_anthropic = os.environ["ANTHROPIC_API_KEY"]
23
 
24
  async def fully_automatic(tasks: list, task_descriptions: list = None, log_file_path: str = None):
25
  options = ClaudeAgentOptions(