wuhp commited on
Commit
3c6a3bf
·
verified ·
1 Parent(s): ad264a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -10,7 +10,7 @@ from huggingface_hub import (
10
  )
11
  from huggingface_hub.utils import build_hf_headers, get_session, hf_raise_for_status
12
  from google import genai
13
- # Import Content and Part types for structured multi-turn/multi-role inputs
14
  from google.genai.types import Content, Part
15
  from google.genai.types import Tool, GenerateContentConfig, GoogleSearch
16
 
@@ -193,10 +193,9 @@ def run_agent(client, model_name, system_prompt_template, user_input_state, conf
193
  model_to_use = model_name
194
 
195
  try:
196
- # *** FIX: Use Content objects with Part objects inside the parts list ***
197
  messages = [
198
- Content(role="system", parts=[Part(text=system_prompt)]), # System instruction as a Part
199
- Content(role="user", parts=[Part(text=user_message_content)]) # User state as a Part
200
  ]
201
 
202
  response = client.models.generate_content(
@@ -442,7 +441,7 @@ def orchestrate_development(client, project_state, config, oauth_token_token):
442
  elif current_task.startswith('CODING'):
443
  # Ensure minimum files exist before asking CodeGen to code
444
  # This happens once at the start of the first coding task or if syntax errors occurred
445
- if project_state['attempt_count'] == 0 or 'Syntax Errors Found' in project_state.get('feedback', ''):
446
  # Add initial stub files if they don't exist or need regeneration due to syntax issues
447
  if project_state['main_app_file'] not in project_state['files'] or project_state.get('needs_initial_stubs', False): # Check flag if set
448
  print("Adding initial stubs for main app file...")
 
10
  )
11
  from huggingface_hub.utils import build_hf_headers, get_session, hf_raise_for_status
12
  from google import genai
13
+ # Import Content and Part types for structured input
14
  from google.genai.types import Content, Part
15
  from google.genai.types import Tool, GenerateContentConfig, GoogleSearch
16
 
 
193
  model_to_use = model_name
194
 
195
  try:
196
+ # *** FIX: Use a single Content object with role="user" and combined text in a Part ***
197
  messages = [
198
+ Content(role="user", parts=[Part(text=system_prompt + "\n\n" + user_message_content)])
 
199
  ]
200
 
201
  response = client.models.generate_content(
 
441
  elif current_task.startswith('CODING'):
442
  # Ensure minimum files exist before asking CodeGen to code
443
  # This happens once at the start of the first coding task or if syntax errors occurred
444
+ if project_state['attempt_count'] == 0 and project_state['current_task'] == 'CODING - Initial Implementation':
445
  # Add initial stub files if they don't exist or need regeneration due to syntax issues
446
  if project_state['main_app_file'] not in project_state['files'] or project_state.get('needs_initial_stubs', False): # Check flag if set
447
  print("Adding initial stubs for main app file...")