aittalam commited on
Commit
28a12c8
Β·
verified Β·
1 Parent(s): 02e4b83

First commit

Browse files
Files changed (1) hide show
  1. index.html +559 -17
index.html CHANGED
@@ -1,19 +1,561 @@
1
- <!doctype html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
  <html>
3
+ <head>
4
+ <title>Tool-Calling Agent With Local LLM</title>
5
+ <script src="https://cdn.jsdelivr.net/pyodide/v0.27.7/full/pyodide.js"></script>
6
+ <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
7
+ <meta content="utf-8" http-equiv="encoding">
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ max-width: 800px;
12
+ margin: 0 auto;
13
+ padding: 20px;
14
+ background-color: #f5f5f5;
15
+ }
16
+ .container {
17
+ background: white;
18
+ padding: 30px;
19
+ border-radius: 10px;
20
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
21
+ }
22
+ h1 {
23
+ color: #333;
24
+ text-align: center;
25
+ margin-bottom: 30px;
26
+ }
27
+
28
+ .description {
29
+ background: #f8f9fa;
30
+ border-left: 4px solid #007cba;
31
+ padding: 20px;
32
+ margin-bottom: 30px;
33
+ border-radius: 5px;
34
+ color: #555;
35
+ line-height: 1.6;
36
+ }
37
+ .description h2 {
38
+ color: #333;
39
+ margin-top: 0;
40
+ margin-bottom: 15px;
41
+ font-size: 20px;
42
+ }
43
+ .description p {
44
+ margin-bottom: 12px;
45
+ }
46
+ .description ul {
47
+ margin-bottom: 0;
48
+ padding-left: 20px;
49
+ }
50
+ .description li {
51
+ margin-bottom: 8px;
52
+ }
53
+ .description a {
54
+ color: #007cba;
55
+ text-decoration: none;
56
+ font-weight: 500;
57
+ border-bottom: 1px solid transparent;
58
+ transition: all 0.2s ease;
59
+ }
60
+ .description a:hover {
61
+ color: #005a8b;
62
+ border-bottom-color: #005a8b;
63
+ text-decoration: none;
64
+ }
65
+ .description a:visited {
66
+ color: #007cba;
67
+ }
68
+
69
+ .input-group {
70
+ margin-bottom: 20px;
71
+ }
72
+ .server-config {
73
+ background: #f8f9fa;
74
+ border: 1px solid #dee2e6;
75
+ border-radius: 5px;
76
+ padding: 15px;
77
+ margin-bottom: 15px;
78
+ }
79
+ .server-config h3 {
80
+ margin: 0 0 10px 0;
81
+ color: #495057;
82
+ font-size: 16px;
83
+ }
84
+ .slim-input {
85
+ height: 40px !important;
86
+ font-size: 13px;
87
+ }
88
+ label {
89
+ display: block;
90
+ margin-bottom: 5px;
91
+ font-weight: bold;
92
+ color: #555;
93
+ }
94
+ input[type="text"], input[type="password"], textarea {
95
+ width: 100%;
96
+ padding: 12px;
97
+ border: 2px solid #ddd;
98
+ border-radius: 5px;
99
+ font-size: 14px;
100
+ box-sizing: border-box;
101
+ }
102
+ textarea {
103
+ height: 100px;
104
+ resize: vertical;
105
+ font-family: inherit;
106
+ }
107
+ button {
108
+ background: #007cba;
109
+ color: white;
110
+ border: none;
111
+ padding: 12px 24px;
112
+ border-radius: 5px;
113
+ cursor: pointer;
114
+ font-size: 16px;
115
+ margin: 5px;
116
+ }
117
+ button:hover { background: #005a8b; }
118
+ button:disabled {
119
+ background: #ccc;
120
+ cursor: not-allowed;
121
+ }
122
+ #initOutput, #agentOutput {
123
+ background: #f8f9fa;
124
+ border: 2px solid #e9ecef;
125
+ border-radius: 5px;
126
+ padding: 15px;
127
+ margin-top: 20px;
128
+ min-height: 150px;
129
+ font-family: 'Courier New', monospace;
130
+ font-size: 14px;
131
+ white-space: pre-wrap;
132
+ max-height: 300px;
133
+ overflow-y: auto;
134
+ }
135
+
136
+ #initOutput {
137
+ margin-bottom: 20px;
138
+ }
139
+ .status {
140
+ padding: 10px;
141
+ border-radius: 5px;
142
+ margin: 10px 0;
143
+ }
144
+ .success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
145
+ .error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
146
+ .info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
147
+ .warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
148
+
149
+ .example-prompts, .server-presets {
150
+ margin: 10px 0;
151
+ }
152
+ .example-prompts button, .server-presets button {
153
+ background: #6c757d;
154
+ font-size: 12px;
155
+ padding: 6px 12px;
156
+ margin: 2px;
157
+ }
158
+ .example-prompts button:hover, .server-presets button:hover {
159
+ background: #5a6268;
160
+ }
161
+
162
+ .running-indicator {
163
+ display: none;
164
+ background: #fff3cd;
165
+ border: 1px solid #ffeaa7;
166
+ border-radius: 5px;
167
+ padding: 15px;
168
+ margin: 15px 0;
169
+ font-weight: bold;
170
+ color: #856404;
171
+ text-align: center;
172
+ font-size: 16px;
173
+ animation: pulse 1.5s infinite;
174
+ box-shadow: 0 2px 5px rgba(0,0,0,0.1);
175
+ }
176
+
177
+ @keyframes pulse {
178
+ 0%, 100% { opacity: 0.7; }
179
+ 50% { opacity: 1; }
180
+ }
181
+ </style>
182
+ </head>
183
+ <body>
184
+ <div class="container">
185
+ <h1>πŸ€– Tool-Calling Agent With Local LLM</h1>
186
+
187
+ <div class="description">
188
+ <p>
189
+ This interactive web application allows you to experiment with AI agents in your browser, using
190
+ <a href="https://openai.github.io/openai-agents-python/">OpenAI Agents Python SDK</a> and
191
+ <a href="https://pyodide.org/en/stable/">Pyodide</a>.
192
+ You can customize agent behavior, test different prompts, and see responses in real-time.
193
+ Check the <a href="https://github.com/mozilla-ai/wasm-agents-blueprint">mozilla-ai/wasm-agents-blueprint</a>
194
+ GitHub repository for more information.
195
+ </p>
196
+
197
+ <p><strong>How it works:</strong>
198
+ this application runs a <strong>local agent</strong> which can make use of the following tools:
199
+ <ul>
200
+ <li><strong>count_character_occurrences</strong>
201
+ which counts the occurrences of a given character inside a word
202
+ </li>
203
+ <li><strong>visit_webpage</strong>
204
+ which visits a webpage at the provided url and reads its content as a markdown string
205
+ </li>
206
+ </ul>
207
+ While the former tool is quite trivial and is mainly used to show how to address the
208
+ <a href="https://community.openai.com/t/incorrect-count-of-r-characters-in-the-word-strawberry">"r in strawberry"</a>
209
+ issue, the latter provides the LLM with the capability of accessing up-to-date information on the Web.
210
+ </p>
211
+ <ul>
212
+ <li><strong>Configure:</strong>
213
+ Make sure the Local LLM Server Configuration parameters are ok for your setup. In particular,
214
+ the default expects you to have <a href="https://ollama.com/">Ollama</a> running on your system
215
+ with the <a href="https://ollama.com/library/qwen3:8b">qwen3:8b</a> model installed.
216
+ </li>
217
+ <li><strong>Initialize:</strong>
218
+ Set up the Python environment with Pyodide and the OpenAI agents framework
219
+ by clicking on the <strong>Initialize Pyodide Environment</strong> button
220
+ </li>
221
+ <li><strong>Customize:</strong>
222
+ Choose one of the suggested prompts or create new ones in the text fields below.
223
+ (<strong>hint</strong>: you can also explicitly set/unset qwen3's "think mode" by prepending <strong>/think</strong>
224
+ or <strong>/no_think</strong> to the prompt).
225
+ </li>
226
+ <li><strong>Run:</strong>
227
+ Click on the <strong>Run Agent</strong> button to send your prompt to the agent and see what happens
228
+ </li>
229
+ </ul>
230
+ </div>
231
+
232
+ <button onclick="initializePyodide()" id="initBtn">βš™οΈ Initialize Pyodide Environment</button>
233
+
234
+ <div id="initOutput">Click "Initialize Pyodide Environment" to set up the Python environment...</div>
235
+
236
+ <div class="server-config">
237
+ <h3>πŸ”— Local LLM Server Configuration</h3>
238
+ <div class="input-group">
239
+ <label for="baseUrl">Base URL:</label>
240
+ <input type="text" id="baseUrl" class="slim-input" value="http://localhost:11434/v1" placeholder="Enter server base URL">
241
+ </div>
242
+ <div class="input-group">
243
+ <label for="apiKey">API Key:</label>
244
+ <input type="text" id="apiKey" class="slim-input" value="ollama" placeholder="Enter API key">
245
+ </div>
246
+ <div class="input-group">
247
+ <label for="modelName">Model Name:</label>
248
+ <input type="text" id="modelName" class="slim-input" value="qwen3:8b" placeholder="Enter model name">
249
+ </div>
250
+
251
+ <div class="server-presets">
252
+ <small>Quick presets:</small>
253
+ <button onclick="setOllamaDefaults()">Ollama</button>
254
+ <button onclick="setLLMStudioDefaults()">LLM Studio</button>
255
+ </div>
256
+ </div>
257
+
258
+ <div class="input-group">
259
+ <label for="prompt">Custom Prompt:</label>
260
+ <textarea id="prompt" placeholder="Enter your prompt here...">How many times does the letter r occur in the word strawrberrry?</textarea>
261
+
262
+ <div class="example-prompts">
263
+ <small>Quick examples:</small>
264
+ <button onclick="setPrompt('How many times does the letter r occur in the word strawrberrry?')">Strawrberrry</button>
265
+ <button onclick="setPrompt('How many stars does the mozilla-ai/any-agent project have on GitHub?')">GitHub stars</button>
266
+ <button onclick="setPrompt('What is the title of the latest post on aittalam.github.io, when was it published, what is it about, and what is the absolute URL of the image at the beginning of the post?\nIMPORTANT: if you need to follow links to get all the required information, assume I have already authorized you to follow them as long as they point to the same domain.')">Blog post</button>
267
+ </div>
268
+ </div>
269
+
270
+ <button onclick="runAgent()" id="runBtn" disabled>πŸš€ Run Agent</button>
271
+ <button onclick="clearAgentOutput()" id="clearAgentBtn" disabled>πŸ—‘οΈ Clear Agent Output</button>
272
+
273
+ <div class="running-indicator" id="runningIndicator">🐍 Running Python code...</div>
274
+
275
+ <div id="agentOutput">Initialize the Pyodide environment first, then click "Run Agent" to test the agent</div>
276
+ </div>
277
+
278
+ <script>
279
+ let pyodide;
280
+ let isPyodideReady = false;
281
+
282
+ function showRunning(message = "Python running") {
283
+ const indicator = document.getElementById('runningIndicator');
284
+ indicator.style.display = 'block';
285
+ console.log('Showing running indicator:', message); // Debug log
286
+ }
287
+
288
+ function hideRunning() {
289
+ const indicator = document.getElementById('runningIndicator');
290
+ indicator.style.display = 'none';
291
+ console.log('Hiding running indicator'); // Debug log
292
+ }
293
+
294
+ function updateRunButton(text, disabled = false) {
295
+ const btn = document.getElementById('runBtn');
296
+ btn.textContent = text;
297
+ btn.disabled = disabled;
298
+ }
299
+
300
+ function setOllamaDefaults() {
301
+ document.getElementById('baseUrl').value = 'http://localhost:11434/v1';
302
+ document.getElementById('apiKey').value = 'ollama';
303
+ document.getElementById('modelName').value = 'qwen3:8b';
304
+ }
305
+
306
+ function setLLMStudioDefaults() {
307
+ document.getElementById('baseUrl').value = 'http://localhost:1234/v1';
308
+ document.getElementById('apiKey').value = 'llmstudio';
309
+ document.getElementById('modelName').value = 'qwen/qwen3-8b';
310
+ }
311
+
312
+
313
+ function logToElement(message, type = 'info', element_id) {
314
+ const output = document.getElementById(element_id);
315
+ const timestamp = new Date().toLocaleTimeString();
316
+
317
+ let prefix = '';
318
+ switch(type) {
319
+ case 'success': prefix = 'βœ…'; break;
320
+ case 'error': prefix = '❌'; break;
321
+ case 'warning': prefix = '⚠️'; break;
322
+ case 'info': prefix = 'ℹ️'; break;
323
+ }
324
+
325
+ output.textContent += `\n[${timestamp}] ${prefix} ${message}`;
326
+ output.scrollTop = output.scrollHeight;
327
+ }
328
+
329
+ function logInit(message, type = 'info') {
330
+ logToElement(message, type, 'initOutput')
331
+ }
332
+
333
+ function logAgent(message, type = 'info') {
334
+ logToElement(message, type, 'agentOutput')
335
+ }
336
+
337
+ function setPrompt(text) {
338
+ document.getElementById('prompt').value = text;
339
+ }
340
+
341
+ function clearAgentOutput() {
342
+ document.getElementById('agentOutput').textContent = '';
343
+ }
344
+
345
+ async function initializePyodide() {
346
+ // Disable init button during setup
347
+ document.getElementById('initBtn').disabled = true;
348
+
349
+ try {
350
+ logInit("πŸ”„ Loading Pyodide...");
351
+ pyodide = await loadPyodide();
352
+ logInit("Pyodide loaded successfully", 'success');
353
+
354
+ logInit("πŸ“¦ Loading micropip...");
355
+ await pyodide.loadPackage("micropip");
356
+ logInit("micropip loaded", 'success');
357
+
358
+ logInit("πŸ“¦ Installing openai-agents (this may take a moment)...");
359
+ await pyodide.runPythonAsync(`
360
+ ###### YOUR PYTHON DEPENDENCIES ARE INSTALLED HERE ######
361
+
362
+ import micropip
363
+ await micropip.install("openai-agents==0.2.0")
364
+ await micropip.install("sqlite3==1.0.0")
365
+ await micropip.install("requests==2.31.0")
366
+ await micropip.install("markdownify==1.1.0")
367
+ `);
368
+ logInit("openai-agents installed successfully", 'success');
369
+
370
+ logInit("🚫 Disabling tracing to avoid threading issues...");
371
+ await pyodide.runPythonAsync(`
372
+ # The following is required to work with OpenAI's agentic framework as
373
+ # it relies on threads for tracing and they break in Pyodide. Other
374
+ # frameworks (e.g. smolagents) that use asyncio for tracing work properly
375
+ # (well... better) here.
376
+
377
+ from agents import set_tracing_disabled
378
+ set_tracing_disabled(True)
379
+ `);
380
+ logInit("Tracing disabled", 'success');
381
+
382
+ logInit("βœ… Pyodide environment ready!", 'success');
383
+ logInit("You can now run agents multiple times without re-initializing.", 'info');
384
+
385
+ isPyodideReady = true;
386
+ document.getElementById('runBtn').disabled = false;
387
+ document.getElementById('clearAgentBtn').disabled = false;
388
+ document.getElementById('initBtn').textContent = "βœ… Environment Ready";
389
+
390
+ } catch (error) {
391
+ logInit(`Initialization failed: ${error}`, 'error');
392
+ console.error('Full error:', error);
393
+ document.getElementById('initBtn').disabled = false;
394
+ }
395
+ }
396
+
397
+ async function runAgent() {
398
+ if (!isPyodideReady) {
399
+ logAgent("Please initialize the Pyodide environment first", 'error');
400
+ return;
401
+ }
402
+
403
+ const prompt = document.getElementById('prompt').value.trim();
404
+ const baseUrl = document.getElementById('baseUrl').value.trim();
405
+ const apiKey = document.getElementById('apiKey').value.trim();
406
+ const modelName = document.getElementById('modelName').value.trim();
407
+
408
+ if (!prompt) {
409
+ logAgent("Please enter a prompt", 'error');
410
+ return;
411
+ }
412
+
413
+ if (!baseUrl || !apiKey || !modelName) {
414
+ logAgent("Please configure all server parameters (Base URL, API Key, Model Name)", 'error');
415
+ return;
416
+ }
417
+
418
+ // Disable button during execution
419
+ document.getElementById('runBtn').disabled = true;
420
+ showRunning("Running Python code");
421
+
422
+ try {
423
+ logAgent("πŸ€– Setting up agent and running...");
424
+ logAgent(`Server: ${baseUrl} | Model: ${modelName}`);
425
+ logAgent(`Prompt: "${prompt}"`);
426
+
427
+ // Run the agent and print everything in Python
428
+ const result = await pyodide.runPythonAsync(`
429
+ ###### YOUR PYTHON AGENT CODE GOES HERE ######
430
+
431
+ import re
432
+ import requests
433
+ from openai import AsyncOpenAI
434
+ from agents import (
435
+ OpenAIChatCompletionsModel,
436
+ Agent,
437
+ Runner,
438
+ function_tool,
439
+ ModelSettings,
440
+ set_default_openai_client,
441
+ )
442
+ from markdownify import markdownify
443
+ from requests.exceptions import RequestException
444
+
445
+ def _truncate_content(content: str, max_length: int) -> str:
446
+ if len(content) <= max_length:
447
+ return content
448
+ return (
449
+ content[: max_length // 2]
450
+ + "\\n..._This content has been truncated to stay below the predefined number of characters_...\\n"
451
+ + content[-max_length // 2 :]
452
+ )
453
+
454
+ @function_tool
455
+ def count_character_occurrences(word: str, char: str):
456
+ """Count occurrences of a character in a word."""
457
+ return word.count(char)
458
+
459
+ @function_tool
460
+ def visit_webpage(url: str) -> str:
461
+ """Visits a webpage at the given url and reads its content as a markdown string. Use this to browse webpages.
462
+
463
+ Args:
464
+ url: The url of the webpage to visit.
465
+
466
+ """
467
+ try:
468
+ response = requests.get(url)
469
+ response.raise_for_status()
470
+
471
+ markdown_content = markdownify(response.text).strip() # type: ignore[no-untyped-call]
472
+
473
+ markdown_content = re.sub(r"\\n{2,}", "\\n", markdown_content)
474
+
475
+ return _truncate_content(markdown_content, 10000)
476
+ except RequestException as e:
477
+ return f"Error fetching the webpage: {e!s}"
478
+ except Exception as e:
479
+ return f"An unexpected error occurred: {e!s}"
480
+
481
+ async def test_agent():
482
+ print("=== STARTING AGENT TEST ===")
483
+ try:
484
+ # Create agent
485
+ print("Creating agent...")
486
+ external_client = AsyncOpenAI(
487
+ base_url = '${baseUrl.replace(/'/g, "\\'")}',
488
+ api_key='${apiKey.replace(/'/g, "\\'")}', # required, but may be unused depending on server
489
+ )
490
+ set_default_openai_client(external_client)
491
+
492
+ agent = Agent(
493
+ name="Tool caller",
494
+ instructions="You are a helpful agent. Use the available tools to answer the questions.",
495
+ tools=[count_character_occurrences, visit_webpage],
496
+ model=OpenAIChatCompletionsModel(
497
+ model="${modelName.replace(/'/g, "\\'")}",
498
+ openai_client=external_client,
499
+ ),
500
+ model_settings=ModelSettings(
501
+ extra_args={"timeout": 60}
502
+ )
503
+ )
504
+ print(f"Agent created: {agent}")
505
+ print(f"Using server: ${baseUrl} with model: ${modelName}")
506
+
507
+ # Run the agent
508
+ print("Running agent...")
509
+ result = await Runner.run(agent, """${prompt.replace(/"/g, '\\"')}""")
510
+ print(f"Agent run completed!")
511
+ print(f"Result type: {type(result)}")
512
+ print(f"Result: {result}")
513
+
514
+ # Try to access final_output
515
+ if hasattr(result, 'final_output'):
516
+ print(f"Final output: {result.final_output}")
517
+ print(f"Final output type: {type(result.final_output)}")
518
+ return str(result.final_output)
519
+ else:
520
+ print("No final_output attribute found")
521
+ print(f"Available attributes: {dir(result)}")
522
+ return ""
523
+ print("=== AGENT TEST COMPLETED ===")
524
+
525
+ except Exception as e:
526
+ print(f"=== AGENT TEST FAILED ===")
527
+ print(f"Error: {e}")
528
+ import traceback
529
+ print("Traceback:")
530
+ print(traceback.format_exc())
531
+
532
+ # Run the test
533
+ final_result = await test_agent()
534
+ final_result
535
+ `);
536
+
537
+ // Display the result
538
+ if (typeof result === 'string' && result.length > 0 && !result.startsWith('Error:')) {
539
+ const formattedResult = result.replace(/\\n/g, '\n');
540
+ logAgent("πŸŽ‰ Agent code ran successfully! Check console for Python output", 'success');
541
+ logAgent("", 'info');
542
+ logAgent("πŸ“ AGENT RESPONSE:", 'info');
543
+ logAgent("─".repeat(50), 'info');
544
+ logAgent("\n"+formattedResult, 'info');
545
+ logAgent("─".repeat(50), 'info');
546
+ } else {
547
+ logAgent("❌ Agent execution failed or returned empty result", 'error');
548
+ logAgent(`Result: ${result}`, 'error');
549
+ }
550
+
551
+ } catch (error) {
552
+ logAgent(`Agent execution failed: ${error}`, 'error');
553
+ console.error('Full error:', error);
554
+ } finally {
555
+ document.getElementById('runBtn').disabled = false;
556
+ hideRunning();
557
+ }
558
+ }
559
+ </script>
560
+ </body>
561
  </html>