File size: 7,393 Bytes
30980ef
 
 
 
 
 
 
 
e2cfff6
30980ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2cfff6
30980ef
 
 
 
 
098e7fa
7784a35
 
 
30980ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2cfff6
30980ef
 
e2cfff6
30980ef
 
e2cfff6
30980ef
 
e2cfff6
30980ef
 
e2cfff6
30980ef
 
 
 
 
 
 
e2cfff6
30980ef
 
e2cfff6
30980ef
 
e2cfff6
 
 
 
30980ef
 
 
e2cfff6
 
 
 
30980ef
 
e2cfff6
 
30980ef
e2cfff6
30980ef
 
 
 
 
 
 
 
 
 
e2cfff6
30980ef
 
e2cfff6
30980ef
 
 
e2cfff6
30980ef
 
 
e2cfff6
30980ef
 
 
 
 
 
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Browser-Use Server Interface</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: 600;
            color: #555;
        }
        textarea, select, button {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 14px;
            box-sizing: border-box;
        }
        textarea {
            height: 100px;
            resize: vertical;
        }
        button {
            background-color: #007bff;
            color: white;
            border: none;
            cursor: pointer;
            font-weight: 600;
            margin-top: 10px;
        }
        button:hover {
            background-color: #0056b3;
        }
        button:disabled {
            background-color: #ccc;
            cursor: not-allowed;
        }
        .result {
            margin-top: 20px;
            padding: 15px;
            border-radius: 5px;
            white-space: pre-wrap;
            font-family: monospace;
            font-size: 12px;
        }
        .success {
            background-color: #d4edda;
            border: 1px solid #c3e6cb;
            color: #155724;
        }
        .error {
            background-color: #f8d7da;
            border: 1px solid #f5c6cb;
            color: #721c24;
        }
        .loading {
            background-color: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
        }
        .examples {
            margin-top: 30px;
            padding: 20px;
            background-color: #f8f9fa;
            border-radius: 5px;
        }
        .example {
            margin-bottom: 10px;
            padding: 8px;
            background: white;
            border-radius: 3px;
            cursor: pointer;
            border: 1px solid #e9ecef;
        }
        .example:hover {
            background-color: #e9ecef;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🌐 Browser-Use Server Interface</h1>
        
        <form id="taskForm">
            <div class="form-group">
                <label for="task">Task Description:</label>
                <textarea id="task" name="task" placeholder="Describe what you want the browser to do...\nExample: Go to google.com and search for 'Python programming'" required></textarea>
            </div>
            
            <div class="form-group">
                <label for="model">AI Model:</label>
                <select id="model" name="model">
                    <option value="gemini-2.0-flash">gemini-2.0-flash</option>
                    <option value="gemini-2.5-flash">gemini-2.5-flash</option>
                    <option value="gemini-2.0-flash-exp">gemini-2.0-flash-exp</option>
                    <option value="gemini-2.0-flash-lite">gemini-2.0-flash-lite</option>
                    <option value="gpt-4o-mini">GPT-4o Mini (Recommended)</option>
                    <option value="gpt-4o">GPT-4o</option>
                    <option value="gpt-4-turbo">GPT-4 Turbo</option>
                    <option value="claude-3-haiku-20240307">Claude 3 Haiku</option>
                    <option value="claude-3-sonnet-20240229">Claude 3 Sonnet</option>
                </select>
            </div>
            
            <button type="submit" id="submitBtn">Run Task</button>
        </form>
        
        <div id="result" class="result" style="display: none;"></div>
        
        <div class="examples">
            <h3>Example Tasks (Click to use):</h3>
            <div class="example" onclick="setTask('Go to google.com and search for Python programming')">
                πŸ” Search Google for "Python programming"
            </div>
            <div class="example" onclick="setTask('Navigate to github.com and find the trending repositories')">
                πŸ“ˆ Check GitHub trending repositories
            </div>
            <div class="example" onclick="setTask('Go to example.com and get the page title and main heading')">
                πŸ“„ Get page title from example.com
            </div>
            <div class="example" onclick="setTask('Visit news.ycombinator.com and get the top 3 story titles')">
                πŸ“° Get top stories from Hacker News
            </div>
            <div class="example" onclick="setTask('Go to wikipedia.org and search for artificial intelligence')">
                πŸ“š Search Wikipedia for "artificial intelligence"
            </div>
        </div>
    </div>

    <script>
        function setTask(taskText) {
            document.getElementById('task').value = taskText;
        }

        document.getElementById('taskForm').addEventListener('submit', async function(e) {
            e.preventDefault();
            
            const task = document.getElementById('task').value;
            const model = document.getElementById('model').value;
            const submitBtn = document.getElementById('submitBtn');
            const resultDiv = document.getElementById('result');
            
            // Show loading state
            submitBtn.disabled = true;
            submitBtn.textContent = 'Running Task...';
            resultDiv.style.display = 'block';
            resultDiv.className = 'result loading';
            resultDiv.textContent = 'Task is running... This may take a while depending on the complexity.';
            
            try {
                const response = await fetch('/run-task', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        task: task,
                        model: model
                    })
                });
                
                const data = await response.json();
                
                if (data.success) {
                    resultDiv.className = 'result success';
                    resultDiv.textContent = `βœ… Task completed successfully!\n\nResult:\n${data.result}`;
                } else {
                    resultDiv.className = 'result error';
                    resultDiv.textContent = `❌ Task failed:\n\n${data.error}`;
                }
            } catch (error) {
                resultDiv.className = 'result error';
                resultDiv.textContent = `❌ Network error:\n\n${error.message}`;
            } finally {
                submitBtn.disabled = false;
                submitBtn.textContent = 'Run Task';
            }
        });
    </script>
</body>
</html>