File size: 3,243 Bytes
3bbba47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import asyncio
import os
import random

from seeact.agent import SeeActAgent

# Setup your API Key here, or pass through environment
os.environ["OPENAI_API_KEY"] = "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"
# os.environ["GEMINI_API_KEY"] = "Your API KEY Here"


async def run_agent():
    agent = SeeActAgent(model="gpt-4o")
    await agent.start()
    while not agent.complete_flag:
        prediction_dict = await agent.predict()
        await agent.execute(prediction_dict)
    await agent.stop()

if __name__ == "__main__":
    asyncio.run(run_agent())
#
# async def run_agent():
#
#     import json
#
#     # Define the input file path
#     input_file = "tasks.json"
#
#     # Load the data from the input file
#     with open(input_file, 'r', encoding='utf-8') as infile:
#         data = json.load(infile)
#
#     # Iterate through each data point and print the required fields
#
#     data=[i for i in data]
#     random.shuffle(data)
#     for item in data:
#
#
#         website = item.get("website", "N/A")
#         task_id = item.get("task_id", "N/A")
#         confirmed_task = item.get("confirmed_task", "N/A")
#
#         agent = SeeActAgent(model="gpt-4o",default_task=confirmed_task,default_website=website,save_task_id=task_id)
#         await agent.start()
#         count = 0
#         try:
#             while not agent.complete_flag and count < 20:
#                 prediction_dict = await agent.predict()
#                 await agent.execute(prediction_dict)
#                 count += 1
#         except Exception as e:
#             print(e)
#         try:
#             await agent.stop()
#         except Exception as e:
#             print(e)
#
#
#
#
# if __name__ == "__main__":
#     asyncio.run(run_agent())







# import asyncio
# import os
# from seeact.agent import SeeActAgent
#
# # Setup your API Key here, or pass through environment
# os.environ["OPENAI_API_KEY"] = "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"
# # os.environ["GEMINI_API_KEY"] = "Your API KEY Here"
#
# async def process_task(item):
#     website = item.get("website", "N/A")
#     task_id = item.get("task_id", "N/A")
#     confirmed_task = item.get("confirmed_task", "N/A")
#
#     agent = SeeActAgent(model="gpt-4o", default_task=confirmed_task, default_website=website, save_task_id=task_id,save_file_dir="mind2web-online90")
#     await agent.start()
#     count = 0
#     while not agent.complete_flag and count < 20:
#         prediction_dict = await agent.predict()
#         await agent.execute(prediction_dict)
#         count += 1
#     await agent.stop()
#
# async def run_agent():
#     import json
#
#     # Define the input file path
#     input_file = "tasks.json"
#
#     # Load the data from the input file
#     with open(input_file, 'r', encoding='utf-8') as infile:
#         data = json.load(infile)
#
#     # Use a semaphore to limit the number of concurrent tasks
#     semaphore = asyncio.Semaphore(1)
#
#     async def sem_task(item):
#         async with semaphore:
#             await process_task(item)
#
#     # Schedule all the tasks
#     tasks = [sem_task(item) for item in data]
#     await asyncio.gather(*tasks)
#
# if __name__ == "__main__":
#     asyncio.run(run_agent())