Trisha Tomy commited on
Commit
d078da9
·
1 Parent(s): 229832a

logging in updates

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -29,11 +29,13 @@ async def initialize_runner():
29
  config = RunnerConfig.from_dict({
30
  "environment": {
31
  "name": "webbrowser",
32
- # The homepage is already set to the Account Forecast Settings page.
33
- # The agent will start here, but still needs to handle login if not already logged in.
34
  "homepage": "https://dwd000006jia1mae.lightning.force.com/lightning/setup/AccountForecastSettings/home",
35
  "headless": True, # Keep headless for production environments
36
- "launch_args": ["--no-sandbox", "--disable-setuid-sandbox"]
 
 
 
 
37
  },
38
  "solver": {
39
  "name": "simple",
@@ -74,7 +76,6 @@ def run_async_task(coro):
74
  @app.route('/run_proxy_task', methods=['POST'])
75
  def run_proxy_task_endpoint():
76
  data = request.json
77
- # The 'task' from the user request will now be the dynamic instruction
78
  request_task_instruction = data.get('task')
79
 
80
  if not request_task_instruction:
@@ -83,7 +84,6 @@ def run_proxy_task_endpoint():
83
 
84
  logger.info(f"Received user request task: '{request_task_instruction}'")
85
 
86
- # Retrieve Salesforce credentials from environment variables (Hugging Face Space secrets)
87
  salesforce_username = os.environ.get("SALESFORCE_USERNAME")
88
  salesforce_password = os.environ.get("SALESFORCE_PASSWORD")
89
 
@@ -92,19 +92,20 @@ def run_proxy_task_endpoint():
92
  return jsonify({"error": "Salesforce credentials not configured. Please set SALESFORCE_USERNAME and SALESFORCE_PASSWORD as Space secrets."}), 500
93
 
94
  # Construct the full task for the proxy-lite agent,
95
- # combining login instructions with the dynamic task from the user.
96
- # The agent is expected to handle the login flow if needed.
97
  agent_task = (
98
  f"Log in to Salesforce. The username is '{salesforce_username}' and the password is '{salesforce_password}'. "
99
- f"Once logged in, {request_task_instruction}. "
100
- f"Report the final status of the requested action."
 
 
101
  )
102
 
103
  logger.info(f"Executing agent task: '{agent_task[:200]}...'")
104
 
105
  try:
106
  runner = run_async_task(initialize_runner())
107
- # Pass the constructed agent_task to the runner
108
  result = run_async_task(runner.run(agent_task))
109
 
110
  logger.info(f"Proxy-lite task completed. Output: {result[:200]}...")
 
29
  config = RunnerConfig.from_dict({
30
  "environment": {
31
  "name": "webbrowser",
 
 
32
  "homepage": "https://dwd000006jia1mae.lightning.force.com/lightning/setup/AccountForecastSettings/home",
33
  "headless": True, # Keep headless for production environments
34
+ "launch_args": ["--no-sandbox", "--disable-setuid-sandbox"] ,
35
+ "environment_timeout": 90, # Increased from default 30 seconds
36
+ "screenshot_delay": 3.0, # Increased delay for full page render before screenshot
37
+ "include_html": True, # Include full HTML for richer observations
38
+ "include_poi_text": True, # Keep including points of interest text
39
  },
40
  "solver": {
41
  "name": "simple",
 
76
  @app.route('/run_proxy_task', methods=['POST'])
77
  def run_proxy_task_endpoint():
78
  data = request.json
 
79
  request_task_instruction = data.get('task')
80
 
81
  if not request_task_instruction:
 
84
 
85
  logger.info(f"Received user request task: '{request_task_instruction}'")
86
 
 
87
  salesforce_username = os.environ.get("SALESFORCE_USERNAME")
88
  salesforce_password = os.environ.get("SALESFORCE_PASSWORD")
89
 
 
92
  return jsonify({"error": "Salesforce credentials not configured. Please set SALESFORCE_USERNAME and SALESFORCE_PASSWORD as Space secrets."}), 500
93
 
94
  # Construct the full task for the proxy-lite agent,
95
+ # combining login instructions with the dynamic task from the user,
96
+ # and adding explicit verification steps for login success.
97
  agent_task = (
98
  f"Log in to Salesforce. The username is '{salesforce_username}' and the password is '{salesforce_password}'. "
99
+ f"After attempting to log in, observe the page carefully. "
100
+ f"If the login was successful, the URL should change from the login page, and you should see elements indicating a logged-in state (e.g., a Salesforce navigation menu, a home screen, or a profile icon), rather than a login form or an error message. "
101
+ f"If the login is successful, {request_task_instruction}. "
102
+ f"Report the final status of the requested action and confirmation of successful login."
103
  )
104
 
105
  logger.info(f"Executing agent task: '{agent_task[:200]}...'")
106
 
107
  try:
108
  runner = run_async_task(initialize_runner())
 
109
  result = run_async_task(runner.run(agent_task))
110
 
111
  logger.info(f"Proxy-lite task completed. Output: {result[:200]}...")