-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tinyfish.py
More file actions
29 lines (26 loc) · 1.14 KB
/
Copy pathtest_tinyfish.py
File metadata and controls
29 lines (26 loc) · 1.14 KB
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
import os
import requests
import json
from dotenv import load_dotenv
load_dotenv()
response = requests.post(
"https://agent.tinyfish.ai/v1/automation/run-sse",
headers={
"X-API-Key": os.environ["TINYFISH_API_KEY"],
"Content-Type": "application/json"
},
json={
"url": "https://ecaseline.case.org.sg",
"goal": "Navigate to https://ecaseline.case.org.sg. Find a button or link that says File a Complaint or Lodge a Complaint or Submit Complaint. Click it. Tell me what you see on the next page — specifically: is there a form visible without needing to log in or create an account? What fields are on the form? Return the result as JSON: {\"status\": \"success\", \"login_required\": true or false, \"form_fields_visible\": [\"list of field labels you can see\"]}"
},
stream=True
)
for line in response.iter_lines():
if line:
decoded = line.decode()
if decoded.startswith("data: "):
try:
event = json.loads(decoded[6:])
print(f"EVENT TYPE: {event.get('type')} | DATA: {json.dumps(event)[:300]}")
except:
print(decoded)