botrun-flow-lang 5.12.263__py3-none-any.whl → 5.12.264__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. botrun_flow_lang/api/auth_api.py +39 -39
  2. botrun_flow_lang/api/auth_utils.py +183 -183
  3. botrun_flow_lang/api/botrun_back_api.py +65 -65
  4. botrun_flow_lang/api/flow_api.py +3 -3
  5. botrun_flow_lang/api/hatch_api.py +508 -508
  6. botrun_flow_lang/api/langgraph_api.py +811 -811
  7. botrun_flow_lang/api/line_bot_api.py +1484 -1484
  8. botrun_flow_lang/api/model_api.py +300 -300
  9. botrun_flow_lang/api/rate_limit_api.py +32 -32
  10. botrun_flow_lang/api/routes.py +79 -79
  11. botrun_flow_lang/api/search_api.py +53 -53
  12. botrun_flow_lang/api/storage_api.py +395 -395
  13. botrun_flow_lang/api/subsidy_api.py +290 -290
  14. botrun_flow_lang/api/subsidy_api_system_prompt.txt +109 -109
  15. botrun_flow_lang/api/user_setting_api.py +70 -70
  16. botrun_flow_lang/api/version_api.py +31 -31
  17. botrun_flow_lang/api/youtube_api.py +26 -26
  18. botrun_flow_lang/constants.py +13 -13
  19. botrun_flow_lang/langgraph_agents/agents/agent_runner.py +178 -178
  20. botrun_flow_lang/langgraph_agents/agents/agent_tools/step_planner.py +77 -77
  21. botrun_flow_lang/langgraph_agents/agents/checkpointer/firestore_checkpointer.py +666 -666
  22. botrun_flow_lang/langgraph_agents/agents/gov_researcher/GOV_RESEARCHER_PRD.md +192 -192
  23. botrun_flow_lang/langgraph_agents/agents/gov_researcher/gemini_subsidy_graph.py +460 -460
  24. botrun_flow_lang/langgraph_agents/agents/gov_researcher/gov_researcher_2_graph.py +1002 -1002
  25. botrun_flow_lang/langgraph_agents/agents/gov_researcher/gov_researcher_graph.py +822 -822
  26. botrun_flow_lang/langgraph_agents/agents/langgraph_react_agent.py +723 -723
  27. botrun_flow_lang/langgraph_agents/agents/search_agent_graph.py +864 -864
  28. botrun_flow_lang/langgraph_agents/agents/tools/__init__.py +4 -4
  29. botrun_flow_lang/langgraph_agents/agents/tools/gemini_code_execution.py +376 -376
  30. botrun_flow_lang/langgraph_agents/agents/util/gemini_grounding.py +66 -66
  31. botrun_flow_lang/langgraph_agents/agents/util/html_util.py +316 -316
  32. botrun_flow_lang/langgraph_agents/agents/util/img_util.py +294 -294
  33. botrun_flow_lang/langgraph_agents/agents/util/local_files.py +419 -419
  34. botrun_flow_lang/langgraph_agents/agents/util/mermaid_util.py +86 -86
  35. botrun_flow_lang/langgraph_agents/agents/util/model_utils.py +143 -143
  36. botrun_flow_lang/langgraph_agents/agents/util/pdf_analyzer.py +486 -486
  37. botrun_flow_lang/langgraph_agents/agents/util/pdf_cache.py +250 -250
  38. botrun_flow_lang/langgraph_agents/agents/util/pdf_processor.py +204 -204
  39. botrun_flow_lang/langgraph_agents/agents/util/perplexity_search.py +464 -464
  40. botrun_flow_lang/langgraph_agents/agents/util/plotly_util.py +59 -59
  41. botrun_flow_lang/langgraph_agents/agents/util/tavily_search.py +199 -199
  42. botrun_flow_lang/langgraph_agents/agents/util/youtube_util.py +90 -90
  43. botrun_flow_lang/langgraph_agents/cache/langgraph_botrun_cache.py +197 -197
  44. botrun_flow_lang/llm_agent/llm_agent.py +19 -19
  45. botrun_flow_lang/llm_agent/llm_agent_util.py +83 -83
  46. botrun_flow_lang/log/.gitignore +2 -2
  47. botrun_flow_lang/main.py +61 -61
  48. botrun_flow_lang/main_fast.py +51 -51
  49. botrun_flow_lang/mcp_server/__init__.py +10 -10
  50. botrun_flow_lang/mcp_server/default_mcp.py +744 -744
  51. botrun_flow_lang/models/nodes/utils.py +205 -205
  52. botrun_flow_lang/models/token_usage.py +34 -34
  53. botrun_flow_lang/requirements.txt +21 -21
  54. botrun_flow_lang/services/base/firestore_base.py +30 -30
  55. botrun_flow_lang/services/hatch/hatch_factory.py +11 -11
  56. botrun_flow_lang/services/hatch/hatch_fs_store.py +419 -419
  57. botrun_flow_lang/services/storage/storage_cs_store.py +206 -206
  58. botrun_flow_lang/services/storage/storage_factory.py +12 -12
  59. botrun_flow_lang/services/storage/storage_store.py +65 -65
  60. botrun_flow_lang/services/user_setting/user_setting_factory.py +9 -9
  61. botrun_flow_lang/services/user_setting/user_setting_fs_store.py +66 -66
  62. botrun_flow_lang/static/docs/tools/index.html +926 -926
  63. botrun_flow_lang/tests/api_functional_tests.py +1525 -1525
  64. botrun_flow_lang/tests/api_stress_test.py +357 -357
  65. botrun_flow_lang/tests/shared_hatch_tests.py +333 -333
  66. botrun_flow_lang/tests/test_botrun_app.py +46 -46
  67. botrun_flow_lang/tests/test_html_util.py +31 -31
  68. botrun_flow_lang/tests/test_img_analyzer.py +190 -190
  69. botrun_flow_lang/tests/test_img_util.py +39 -39
  70. botrun_flow_lang/tests/test_local_files.py +114 -114
  71. botrun_flow_lang/tests/test_mermaid_util.py +103 -103
  72. botrun_flow_lang/tests/test_pdf_analyzer.py +104 -104
  73. botrun_flow_lang/tests/test_plotly_util.py +151 -151
  74. botrun_flow_lang/tests/test_run_workflow_engine.py +65 -65
  75. botrun_flow_lang/tools/generate_docs.py +133 -133
  76. botrun_flow_lang/tools/templates/tools.html +153 -153
  77. botrun_flow_lang/utils/__init__.py +7 -7
  78. botrun_flow_lang/utils/botrun_logger.py +344 -344
  79. botrun_flow_lang/utils/clients/rate_limit_client.py +209 -209
  80. botrun_flow_lang/utils/clients/token_verify_client.py +153 -153
  81. botrun_flow_lang/utils/google_drive_utils.py +654 -654
  82. botrun_flow_lang/utils/langchain_utils.py +324 -324
  83. botrun_flow_lang/utils/yaml_utils.py +9 -9
  84. {botrun_flow_lang-5.12.263.dist-info → botrun_flow_lang-5.12.264.dist-info}/METADATA +1 -1
  85. botrun_flow_lang-5.12.264.dist-info/RECORD +102 -0
  86. botrun_flow_lang-5.12.263.dist-info/RECORD +0 -102
  87. {botrun_flow_lang-5.12.263.dist-info → botrun_flow_lang-5.12.264.dist-info}/WHEEL +0 -0
@@ -1,927 +1,927 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-TW">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>ReAct Agent Tools Documentation</title>
7
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
8
- <link href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism.min.css" rel="stylesheet">
9
- <style>
10
- .tool-section {
11
- margin-bottom: 2rem;
12
- padding: 1rem;
13
- border: 1px solid #dee2e6;
14
- border-radius: 0.25rem;
15
- }
16
- .tool-name {
17
- color: #0d6efd;
18
- margin-bottom: 1rem;
19
- padding-top: 60px; /* 為固定導航欄留出空間 */
20
- margin-top: -60px; /* 抵消 padding-top */
21
- }
22
- .param-table {
23
- margin-top: 1rem;
24
- }
25
- .doc-content {
26
- white-space: pre-wrap;
27
- font-family: monospace;
28
- background-color: #f8f9fa;
29
- padding: 1rem;
30
- border-radius: 0.25rem;
31
- }
32
- #sidebar {
33
- position: fixed;
34
- top: 0;
35
- left: 0;
36
- height: 100vh;
37
- width: 250px;
38
- background-color: #f8f9fa;
39
- padding: 20px;
40
- overflow-y: auto;
41
- border-right: 1px solid #dee2e6;
42
- }
43
- #main-content {
44
- margin-left: 250px;
45
- padding: 20px;
46
- }
47
- .nav-link {
48
- color: #0d6efd;
49
- padding: 5px 0;
50
- }
51
- .nav-link:hover {
52
- background-color: #e9ecef;
53
- }
54
- .nav-link.active {
55
- font-weight: bold;
56
- background-color: #e9ecef;
57
- }
58
- </style>
59
- </head>
60
- <body>
61
- <div id="sidebar">
62
- <h5 class="mb-3">Tools</h5>
63
- <nav class="nav flex-column">
64
-
65
- <a class="nav-link" href="#chat_with_imgs">chat_with_imgs</a>
66
-
67
- <a class="nav-link" href="#chat_with_pdf">chat_with_pdf</a>
68
-
69
- <a class="nav-link" href="#create_html_page">create_html_page</a>
70
-
71
- <a class="nav-link" href="#create_mermaid_diagram">create_mermaid_diagram</a>
72
-
73
- <a class="nav-link" href="#create_plotly_chart">create_plotly_chart</a>
74
-
75
- <a class="nav-link" href="#current_date_time">current_date_time</a>
76
-
77
- <a class="nav-link" href="#generate_image">generate_image</a>
78
-
79
- <a class="nav-link" href="#generate_tmp_public_url">generate_tmp_public_url</a>
80
-
81
- <a class="nav-link" href="#scrape">scrape</a>
82
-
83
- <a class="nav-link" href="#web_search">web_search</a>
84
-
85
- </nav>
86
- </div>
87
-
88
- <div id="main-content">
89
- <h1 class="mb-4">ReAct Agent Tools Documentation</h1>
90
-
91
- <div class="row">
92
- <div class="col-12">
93
-
94
- <div class="tool-section" id="chat_with_imgs">
95
- <h2 class="tool-name">@tool chat_with_imgs</h2>
96
-
97
- <h4>Documentation:</h4>
98
- <div class="doc-content">Use this to analyze and understand multiple images using Claude's vision capabilities.
99
-
100
- If you have local image files, you can use generate_tmp_public_url tool multiple times to get public URLs first:
101
- 1. Call generate_tmp_public_url for each local image file
102
- 2. Collect all returned URLs into a list
103
- 3. Use the list of URLs as the img_urls parameter for this function
104
-
105
- Data Visualization Integration:
106
- When the user's input indicates a need for comparison or data visualization (e.g., "compare the values in these charts",
107
- "extract and plot the data from these images"), this function can return data in a format suitable for Plotly visualization.
108
- The returned data will be a dictionary with a special key "__plotly_data__" containing:
109
- {
110
- "__plotly_data__": {
111
- "data": [...], # Plotly data array
112
- "layout": {...} # Plotly layout object
113
- }
114
- }
115
- You can then pass this data to create_plotly_chart to generate an interactive chart.
116
-
117
- Supported image formats:
118
- - JPEG, PNG, GIF, WebP
119
- - Maximum file size: 5MB per image
120
- - Recommended size: No more than 1568 pixels in either dimension
121
- - Very small images (under 200 pixels) may degrade performance
122
- - Can analyze up to 20 images per request
123
-
124
- Capabilities:
125
- - Analyzing charts, graphs, and diagrams
126
- - Reading and understanding text in images
127
- - Describing visual content and scenes
128
- - Comparing multiple images in a single request
129
- - Answering questions about image details
130
- - Identifying relationships between images
131
- - Extracting data from charts for visualization
132
-
133
- Limitations:
134
- - Cannot identify or name specific people
135
- - May have reduced accuracy with low-quality or very small images
136
- - Limited spatial reasoning abilities
137
- - Cannot verify if images are AI-generated
138
- - Not designed for medical diagnosis or healthcare applications
139
-
140
- Args:
141
- img_urls: List of URLs to the image files (can be generated using generate_tmp_public_url for local files)
142
- user_input: Question or instruction about the image content(s)
143
-
144
- Returns:
145
- str: Claude's analysis of the image(s) based on the query, or Plotly-compatible data structure if visualization is needed</div>
146
-
147
- <h4 class="mt-3">Parameters:</h4>
148
- <table class="table param-table">
149
- <thead>
150
- <tr>
151
- <th>Name</th>
152
- <th>Type</th>
153
- <th>Default</th>
154
- </tr>
155
- </thead>
156
- <tbody>
157
-
158
- <tr>
159
- <td>img_urls</td>
160
- <td><code>list[str]</code></td>
161
- <td>-</td>
162
- </tr>
163
-
164
- <tr>
165
- <td>user_input</td>
166
- <td><code><class 'str'></code></td>
167
- <td>-</td>
168
- </tr>
169
-
170
- </tbody>
171
- </table>
172
-
173
- <h4 class="mt-3">Returns:</h4>
174
- <code>Any</code>
175
- </div>
176
-
177
- <div class="tool-section" id="chat_with_pdf">
178
- <h2 class="tool-name">@tool chat_with_pdf</h2>
179
-
180
- <h4>Documentation:</h4>
181
- <div class="doc-content">Use this to chat with a PDF file.
182
- User can ask about any text, pictures, charts, and tables in PDFs that is provided. Some sample use cases:
183
- - Analyzing financial reports and understanding charts/tables
184
- - Extracting key information from legal documents
185
- - Translation assistance for documents
186
- - Converting document information into structured formats
187
-
188
- Data Visualization Integration:
189
- When the user's input indicates a need for comparison or data visualization (e.g., "compare the quarterly profits",
190
- "show the trend of sales"), this function can return data in a format suitable for Plotly visualization.
191
- The returned data will be a dictionary with a special key "__plotly_data__" containing:
192
- {
193
- "__plotly_data__": {
194
- "data": [...], # Plotly data array
195
- "layout": {...} # Plotly layout object
196
- }
197
- }
198
- You can then pass this data to create_plotly_chart to generate an interactive chart.
199
-
200
- If you have a local PDF file, you can use generate_tmp_public_url tool to get a public URL first:
201
- 1. Call generate_tmp_public_url with your local PDF file path
202
- 2. Use the returned URL as the pdf_url parameter for this function
203
-
204
- Args:
205
- pdf_url: the URL to the PDF file (can be generated using generate_tmp_public_url for local files)
206
- user_input: the user's input
207
-
208
- Returns:
209
- str: Analysis result or Plotly-compatible data structure if visualization is needed</div>
210
-
211
- <h4 class="mt-3">Parameters:</h4>
212
- <table class="table param-table">
213
- <thead>
214
- <tr>
215
- <th>Name</th>
216
- <th>Type</th>
217
- <th>Default</th>
218
- </tr>
219
- </thead>
220
- <tbody>
221
-
222
- <tr>
223
- <td>pdf_url</td>
224
- <td><code><class 'str'></code></td>
225
- <td>-</td>
226
- </tr>
227
-
228
- <tr>
229
- <td>user_input</td>
230
- <td><code><class 'str'></code></td>
231
- <td>-</td>
232
- </tr>
233
-
234
- </tbody>
235
- </table>
236
-
237
- <h4 class="mt-3">Returns:</h4>
238
- <code>Any</code>
239
- </div>
240
-
241
- <div class="tool-section" id="create_html_page">
242
- <h2 class="tool-name">@tool create_html_page</h2>
243
-
244
- <h4>Documentation:</h4>
245
- <div class="doc-content">Create a custom HTML page and return its URL.
246
- This URL should be provided to the user, as they will need to access it to view the HTML content in their web browser.
247
-
248
- 這個工具支援完整的HTML文檔,包括JavaScript和CSS,可以用來創建複雜的互動式頁面。
249
-
250
- 使用 create_html_page 的情境:
251
- - 需要展示自定義的HTML內容
252
- - 需要嵌入複雜的互動式內容
253
- - 需要製作自訂格式的報告或文件
254
- - 需要使用第三方JavaScript庫
255
- - 需要展示表格、圖像和多媒體內容
256
- - 需要創建結構化且易於閱讀的内容呈現
257
- - 需要使用CSS樣式創建美觀的界面
258
- - 需要嵌入特殊的圖表或視覺元素
259
-
260
- Input Options:
261
- You can pass either:
262
- 1. A complete HTML document with doctype, html, head, and body tags
263
- 2. An HTML fragment that will be automatically wrapped in a basic HTML structure
264
-
265
- Supported HTML Features:
266
- - Complete HTML documents with your own structure
267
- - Custom JavaScript for interactive elements
268
- - Custom CSS for styling and layout
269
- - External libraries and frameworks (via CDN)
270
- - Tables, lists, and other structural elements
271
- - Embedded images and multimedia (via URLs)
272
- - Form elements (though they won't submit data)
273
- - Responsive design elements
274
- - Unicode and international text support
275
-
276
- Security Considerations:
277
- - HTML content is sandboxed in the browser
278
- - Cannot access user's device or data
279
- - External resources must be from trusted sources
280
- - No server-side processing capability
281
- - No personal data should be included in the HTML
282
-
283
- Example of complete HTML document:
284
- ```html
285
- <!DOCTYPE html>
286
- <html>
287
- <head>
288
- <meta charset="utf-8">
289
- <title>互動式報告</title>
290
- <style>
291
- body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }
292
- .container { max-width: 800px; margin: 0 auto; }
293
- .chart { height: 300px; margin: 20px 0; border: 1px solid #ddd; }
294
- </style>
295
- <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
296
- </head>
297
- <body>
298
- <div class="container">
299
- <h1>業績分析報告</h1>
300
- <p>本報告提供了公司過去三個月的銷售數據分析。</p>
301
- <div class="chart">
302
- <canvas id="salesChart"></canvas>
303
- </div>
304
- <script>
305
- // JavaScript可以直接在HTML中使用
306
- const ctx = document.getElementById('salesChart').getContext('2d');
307
- new Chart(ctx, {
308
- type: 'bar',
309
- data: {
310
- labels: ['一月', '二月', '三月'],
311
- datasets: [{
312
- label: '銷售額(千元)',
313
- data: [1200, 1900, 1500],
314
- backgroundColor: ['#ff6384', '#36a2eb', '#ffce56']
315
- }]
316
- }
317
- });
318
- </script>
319
- </div>
320
- </body>
321
- </html>
322
- ```
323
-
324
- Example of HTML fragment (will be auto-wrapped):
325
- ```html
326
- <div style="padding: 20px; background-color: #f0f8ff;">
327
- <h1 style="color: #333; font-family: Arial, sans-serif;">客戶報告</h1>
328
- <p>這份報告包含了重要的資訊。</p>
329
- <table border="1" style="border-collapse: collapse; width: 100%;">
330
- <tr>
331
- <th>項目</th>
332
- <th>數量</th>
333
- <th>單價</th>
334
- </tr>
335
- <tr>
336
- <td>產品A</td>
337
- <td>10</td>
338
- <td>$100</td>
339
- </tr>
340
- <tr>
341
- <td>產品B</td>
342
- <td>5</td>
343
- <td>$200</td>
344
- </tr>
345
- </table>
346
- </div>
347
- ```
348
-
349
- Args:
350
- html_content: Complete HTML document or fragment. Can include JavaScript, CSS, and other elements.
351
- title: Optional title for the HTML page. If provided, must be in Traditional Chinese.
352
- For example: "客戶報告" instead of "Client Report"
353
- Note: This is only used if the HTML content doesn't already have a title.
354
-
355
- Returns:
356
- str: URL for the HTML page. This URL should be provided to the user,
357
- as they will need to access it to view the content in their web browser.</div>
358
-
359
- <h4 class="mt-3">Parameters:</h4>
360
- <table class="table param-table">
361
- <thead>
362
- <tr>
363
- <th>Name</th>
364
- <th>Type</th>
365
- <th>Default</th>
366
- </tr>
367
- </thead>
368
- <tbody>
369
-
370
- <tr>
371
- <td>html_content</td>
372
- <td><code><class 'str'></code></td>
373
- <td>-</td>
374
- </tr>
375
-
376
- <tr>
377
- <td>title</td>
378
- <td><code><class 'str'></code></td>
379
- <td><code>None</code></td>
380
- </tr>
381
-
382
- </tbody>
383
- </table>
384
-
385
- <h4 class="mt-3">Returns:</h4>
386
- <code><class 'str'></code>
387
- </div>
388
-
389
- <div class="tool-section" id="create_mermaid_diagram">
390
- <h2 class="tool-name">@tool create_mermaid_diagram</h2>
391
-
392
- <h4>Documentation:</h4>
393
- <div class="doc-content">Create an interactive Mermaid diagram visualization and return its URL.
394
- This URL should be provided to the user,
395
- as they will need to access it to view the interactive diagram in their web browser.
396
-
397
- 使用 create_mermaid_diagram 的情境:
398
- - 提到「流程圖」、「架構圖」、「關係圖」等字眼
399
- - 需要展示系統架構(flowchart)
400
- - 需要說明操作流程(flowchart)
401
- - 需要展示時序互動(sequence diagram)
402
- - 需要展示狀態轉換(state diagram)
403
- - 需要展示類別關係(class diagram)
404
- - 需要展示實體關係(ER diagram)
405
- - 需要展示專案時程(gantt chart)
406
- - 需要展示使用者旅程(journey)
407
- - 需要展示需求關係(requirement diagram)
408
- - 需要展示資源分配(pie chart)
409
-
410
- Supported Diagram Types:
411
- 1. Flowcharts (graph TD/LR):
412
- - System architectures
413
- - Process flows
414
- - Decision trees
415
- - Data flows
416
-
417
- 2. Sequence Diagrams (sequenceDiagram):
418
- - API interactions
419
- - System communications
420
- - User interactions
421
- - Message flows
422
-
423
- 3. Class Diagrams (classDiagram):
424
- - Software architecture
425
- - Object relationships
426
- - System components
427
- - Code structure
428
-
429
- 4. State Diagrams (stateDiagram-v2):
430
- - System states
431
- - Workflow states
432
- - Process states
433
- - State transitions
434
-
435
- 5. Entity Relationship Diagrams (erDiagram):
436
- - Database schemas
437
- - Data relationships
438
- - System entities
439
- - Data models
440
-
441
- 6. User Journey Diagrams (journey):
442
- - User experiences
443
- - Customer flows
444
- - Process steps
445
- - Task sequences
446
-
447
- 7. Gantt Charts (gantt):
448
- - Project timelines
449
- - Task schedules
450
- - Resource allocation
451
- - Milestone tracking
452
-
453
- 8. Pie Charts (pie):
454
- - Data distribution
455
- - Resource allocation
456
- - Market share
457
- - Component breakdown
458
-
459
- 9. Requirement Diagrams (requirementDiagram):
460
- - System requirements
461
- - Dependencies
462
- - Specifications
463
- - Constraints
464
-
465
- Example Mermaid syntax for a simple flowchart:
466
- ```
467
- graph TD
468
- A[開始] --> B{是否有資料?}
469
- B -->|是| C[處理資料]
470
- B -->|否| D[取得資料]
471
- C --> E[結束]
472
- D --> B
473
- ```
474
-
475
- Args:
476
- mermaid_data: String containing the Mermaid diagram definition
477
- title: Optional title for the diagram. If provided, must be in Traditional Chinese.
478
- For example: "系統流程圖" instead of "System Flowchart"
479
-
480
- Returns:
481
- str: URL for the interactive HTML visualization. This URL should be provided to the user,
482
- as they will need to access it to view the interactive diagram in their web browser.</div>
483
-
484
- <h4 class="mt-3">Parameters:</h4>
485
- <table class="table param-table">
486
- <thead>
487
- <tr>
488
- <th>Name</th>
489
- <th>Type</th>
490
- <th>Default</th>
491
- </tr>
492
- </thead>
493
- <tbody>
494
-
495
- <tr>
496
- <td>mermaid_data</td>
497
- <td><code><class 'str'></code></td>
498
- <td>-</td>
499
- </tr>
500
-
501
- <tr>
502
- <td>title</td>
503
- <td><code><class 'str'></code></td>
504
- <td><code>None</code></td>
505
- </tr>
506
-
507
- </tbody>
508
- </table>
509
-
510
- <h4 class="mt-3">Returns:</h4>
511
- <code><class 'str'></code>
512
- </div>
513
-
514
- <div class="tool-section" id="create_plotly_chart">
515
- <h2 class="tool-name">@tool create_plotly_chart</h2>
516
-
517
- <h4>Documentation:</h4>
518
- <div class="doc-content">Create an interactive Plotly visualization and return its URL.
519
- This URL should be provided to the user,
520
- as they will need to access it to view the interactive chart in their web browser.
521
-
522
- 使用 create_plotly_chart 的情境:
523
- - 提到「圖表」、「統計圖」、「視覺化」等字眼
524
- - 需要呈現數據趨勢(折線圖)
525
- - 需要比較數值(長條圖、圓餅圖)
526
- - 需要展示分布情況(散點圖、熱力圖)
527
- - 需要顯示時間序列資料(時間軸圖)
528
- - 需要展示地理資訊(地圖)
529
- - 需要多維度資料分析(3D圖、氣泡圖)
530
- - 需要展示統計分布(箱型圖)
531
- - 需要展示累積趨勢(面積圖)
532
- - 需要互動式資料探索
533
-
534
- Integration with Other Tools:
535
- This function can be used in conjunction with chat_with_imgs and chat_with_pdf when they return data
536
- suitable for visualization. When those tools detect a need for visualization, they will return a JSON string
537
- with a "__plotly_data__" key, which can be directly passed to this function.
538
-
539
- Example workflow:
540
- 1. User asks to analyze and visualize data from images/PDFs
541
- 2. chat_with_imgs or chat_with_pdf returns JSON string with "__plotly_data__" key
542
- 3. Pass that string to this function to get an interactive visualization URL
543
-
544
- Supported Chart Types:
545
- - Line charts: For showing trends and time series data
546
- - Bar charts: For comparing values across categories
547
- - Pie charts: For showing proportions of a whole
548
- - Scatter plots: For showing relationships between variables
549
- - Heat maps: For showing patterns in matrix data
550
- - Box plots: For showing statistical distributions
551
- - Geographic maps: For showing spatial data
552
- - 3D plots: For showing three-dimensional data
553
- - Bubble charts: For showing three variables in 2D
554
- - Area charts: For showing cumulative totals over time
555
-
556
- The figure_data should be a JSON string containing plotly figure specifications with 'data' and 'layout'.
557
- Example:
558
- {
559
- 'data': [{
560
- 'type': 'scatter',
561
- 'x': [1, 2, 3, 4],
562
- 'y': [10, 15, 13, 17]
563
- }],
564
- 'layout': {
565
- 'title': 'My Plot'
566
- }
567
- }
568
-
569
- Args:
570
- figure_data: JSON string containing plotly figure specifications or output from chat_with_imgs/chat_with_pdf.
571
- Will be parsed using json.loads().
572
- title: Optional title for the plot. If provided, must be in Traditional Chinese.
573
- For example: "台灣人口統計圖表" instead of "Taiwan Population Chart"
574
-
575
- Returns:
576
- str: URL for the interactive HTML visualization. This URL should be provided to the user,
577
- as they will need to access it to view the interactive chart in their web browser.</div>
578
-
579
- <h4 class="mt-3">Parameters:</h4>
580
- <table class="table param-table">
581
- <thead>
582
- <tr>
583
- <th>Name</th>
584
- <th>Type</th>
585
- <th>Default</th>
586
- </tr>
587
- </thead>
588
- <tbody>
589
-
590
- <tr>
591
- <td>figure_data</td>
592
- <td><code><class 'str'></code></td>
593
- <td>-</td>
594
- </tr>
595
-
596
- <tr>
597
- <td>title</td>
598
- <td><code><class 'str'></code></td>
599
- <td><code>None</code></td>
600
- </tr>
601
-
602
- </tbody>
603
- </table>
604
-
605
- <h4 class="mt-3">Returns:</h4>
606
- <code><class 'str'></code>
607
- </div>
608
-
609
- <div class="tool-section" id="current_date_time">
610
- <h2 class="tool-name">@tool current_date_time</h2>
611
-
612
- <h4>Documentation:</h4>
613
- <div class="doc-content">Use this to get the current date and time in local timezone.
614
-
615
- Important: You MUST call this current_date_time function when:
616
- 1. User's query contains time-related words such as:
617
- - 今天、現在、目前
618
- - 本週、這週、下週
619
- - 本月、這個月、上個月
620
- - 今年、去年、明年
621
- - 最近、近期
622
- - 未來、將來
623
- - 過去、以前
624
- 2. User asks about current events or latest information
625
- 3. User wants to know time-sensitive information
626
- 4. Queries involving relative time expressions
627
-
628
- Examples of when to use current_date_time:
629
- - "今天的天氣如何?"
630
- - "本月的股市表現"
631
- - "最近有什麼新聞?"
632
- - "去年到現在的經濟成長"
633
- - "未來一週的活動預告"
634
- - "這個月的銷售數據"
635
-
636
- Returns:
637
- str: Current date and time in format "YYYY-MM-DD HH:MM Asia/Taipei"</div>
638
-
639
- <h4 class="mt-3">Parameters:</h4>
640
- <table class="table param-table">
641
- <thead>
642
- <tr>
643
- <th>Name</th>
644
- <th>Type</th>
645
- <th>Default</th>
646
- </tr>
647
- </thead>
648
- <tbody>
649
-
650
- </tbody>
651
- </table>
652
-
653
- <h4 class="mt-3">Returns:</h4>
654
- <code>Any</code>
655
- </div>
656
-
657
- <div class="tool-section" id="generate_image">
658
- <h2 class="tool-name">@tool generate_image</h2>
659
-
660
- <h4>Documentation:</h4>
661
- <div class="doc-content">Use this to generate high-quality images using DALL-E 3.
662
-
663
- Capabilities:
664
- - Creates photorealistic images and art
665
- - Handles complex scenes and compositions
666
- - Maintains consistent styles
667
- - Follows detailed prompts with high accuracy
668
- - Supports various artistic styles and mediums
669
-
670
- Best practices for prompts:
671
- - Be specific about style, mood, lighting, and composition
672
- - Include details about perspective and setting
673
- - Specify artistic medium if desired (e.g., "oil painting", "digital art")
674
- - Mention color schemes or specific colors
675
- - Describe the atmosphere or emotion you want to convey
676
-
677
- Limitations:
678
- - Cannot generate images of public figures or celebrities
679
- - Avoids harmful, violent, or adult content
680
- - May have inconsistencies with hands, faces, or text
681
- - Cannot generate exact copies of existing artworks or brands
682
- - Limited to single image generation per request
683
-
684
- Args:
685
- user_input: Detailed description of the image you want to generate.
686
- Be specific about style, content, and composition.
687
-
688
- Returns:
689
- str: URL to the generated image, or error message if generation fails</div>
690
-
691
- <h4 class="mt-3">Parameters:</h4>
692
- <table class="table param-table">
693
- <thead>
694
- <tr>
695
- <th>Name</th>
696
- <th>Type</th>
697
- <th>Default</th>
698
- </tr>
699
- </thead>
700
- <tbody>
701
-
702
- <tr>
703
- <td>user_input</td>
704
- <td><code><class 'str'></code></td>
705
- <td>-</td>
706
- </tr>
707
-
708
- </tbody>
709
- </table>
710
-
711
- <h4 class="mt-3">Returns:</h4>
712
- <code>Any</code>
713
- </div>
714
-
715
- <div class="tool-section" id="generate_tmp_public_url">
716
- <h2 class="tool-name">@tool generate_tmp_public_url</h2>
717
-
718
- <h4>Documentation:</h4>
719
- <div class="doc-content">使用者會給你一個本地端的檔案路徑,請你使用這個 generate_tmp_public_url tool 生成一個臨時的公開 URL,這個 URL 可以讓使用者下載這個檔案。
720
- 如果使用者給了多個本地端的檔案路徑,請你多次呼叫這個 tool,並將每次呼叫的回傳值收集起來。
721
-
722
- Args:
723
- file_path: The path to the local file you want to make publicly accessible
724
-
725
- Returns:
726
- str: A public URL that can be used to access the file for 7 days
727
-
728
- Raises:
729
- FileNotFoundError: If the specified file does not exist</div>
730
-
731
- <h4 class="mt-3">Parameters:</h4>
732
- <table class="table param-table">
733
- <thead>
734
- <tr>
735
- <th>Name</th>
736
- <th>Type</th>
737
- <th>Default</th>
738
- </tr>
739
- </thead>
740
- <tbody>
741
-
742
- <tr>
743
- <td>file_path</td>
744
- <td><code><class 'str'></code></td>
745
- <td>-</td>
746
- </tr>
747
-
748
- </tbody>
749
- </table>
750
-
751
- <h4 class="mt-3">Returns:</h4>
752
- <code><class 'str'></code>
753
- </div>
754
-
755
- <div class="tool-section" id="scrape">
756
- <h2 class="tool-name">@tool scrape</h2>
757
-
758
- <h4>Documentation:</h4>
759
- <div class="doc-content">Use this to scrape the web.
760
- as it provides better results for video content.
761
-
762
- Args:
763
- url: the url to scrape</div>
764
-
765
- <h4 class="mt-3">Parameters:</h4>
766
- <table class="table param-table">
767
- <thead>
768
- <tr>
769
- <th>Name</th>
770
- <th>Type</th>
771
- <th>Default</th>
772
- </tr>
773
- </thead>
774
- <tbody>
775
-
776
- <tr>
777
- <td>url</td>
778
- <td><code><class 'str'></code></td>
779
- <td>-</td>
780
- </tr>
781
-
782
- </tbody>
783
- </table>
784
-
785
- <h4 class="mt-3">Returns:</h4>
786
- <code>Any</code>
787
- </div>
788
-
789
- <div class="tool-section" id="web_search">
790
- <h2 class="tool-name">@tool web_search</h2>
791
-
792
- <h4>Documentation:</h4>
793
- <div class="doc-content">Use this to search the web when you need up-to-date information or when your knowledge is insufficient.
794
- This tool uses Perplexity to perform web searches and provides detailed answers with citations.
795
-
796
- 除非使用者堅持要做多輪搜尋,不然這個工具能夠一次進行多個條件的搜尋,比如:
797
- 一次進行多條件範例1:
798
- - 可以:
799
- - web_search("搜尋今天的體育、財經、政治新聞", current_date_time)
800
- - 不需要:
801
- - web_search("搜尋今天的體育新聞", current_date_time)
802
- - web_search("搜尋今天的財經新聞", current_date_time)
803
- - web_search("搜尋今天的政台新聞", current_date_time)
804
-
805
- Time/Date Information Requirements:
806
- 1. MUST preserve any specific dates or time periods mentioned in the user's query
807
- 2. Include both the current time and any specific time references from the query
808
-
809
- Examples:
810
- - Basic query:
811
- User asks: "台灣的人口數量"
812
- web_search("台灣的人口數量", "2024-03-20 14:30 Asia/Taipei")
813
- Actual search: "台灣的人口數量"
814
- Returns: {
815
- "content": "根據最新統計,台灣人口約為2300萬...",
816
- "citations": [
817
- {"title": "內政部統計處", "url": "https://www.moi.gov.tw/..."},
818
- {"title": "國家發展委員會", "url": "https://www.ndc.gov.tw/..."}
819
- ]
820
- }
821
-
822
- - Query with specific date:
823
- User asks: "幫我查詢 2025/1/1 的新聞"
824
- web_search("幫我查詢 2025/1/1 的新聞", "2024-03-20 14:30 Asia/Taipei")
825
- Returns: {
826
- "content": "關於2025年1月1日的新聞預測...",
827
- "citations": [
828
- {"title": "經濟日報", "url": "https://money.udn.com/..."},
829
- {"title": "中央社", "url": "https://www.cna.com.tw/..."}
830
- ]
831
- }
832
-
833
- Args:
834
- user_input: The search query or question you want to find information about.
835
- MUST include any specific time periods or dates from the original query.
836
- Examples of time formats to preserve:
837
- - Specific dates: "2025/1/1", "2023-12-31"
838
- - Years: "2023年"
839
- - Quarters/Months: "第一季", "Q1", "一月"
840
- - Time periods: "過去三年", "未來五年"
841
- current_date_time: The current time string MUST be got by current_date_time() tool. You can NOT use the current time from your own knowledge.
842
- Format: "YYYY-MM-DD HH:MM Asia/Taipei"
843
-
844
- Returns:
845
- dict: A dictionary containing:
846
- - content (str): The detailed answer based on web search results
847
- - citations (list): A list of URLs, citation對使用者很重要,務必提供給使用者</div>
848
-
849
- <h4 class="mt-3">Parameters:</h4>
850
- <table class="table param-table">
851
- <thead>
852
- <tr>
853
- <th>Name</th>
854
- <th>Type</th>
855
- <th>Default</th>
856
- </tr>
857
- </thead>
858
- <tbody>
859
-
860
- <tr>
861
- <td>user_input</td>
862
- <td><code><class 'str'></code></td>
863
- <td>-</td>
864
- </tr>
865
-
866
- <tr>
867
- <td>current_date_time</td>
868
- <td><code><class 'str'></code></td>
869
- <td>-</td>
870
- </tr>
871
-
872
- </tbody>
873
- </table>
874
-
875
- <h4 class="mt-3">Returns:</h4>
876
- <code><class 'dict'></code>
877
- </div>
878
-
879
- </div>
880
- </div>
881
- </div>
882
-
883
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
884
- <script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js"></script>
885
- <script>
886
- // 高亮當前選中的導航項
887
- document.addEventListener('DOMContentLoaded', function() {
888
- const navLinks = document.querySelectorAll('.nav-link');
889
-
890
- // 監聽滾動事件
891
- window.addEventListener('scroll', function() {
892
- let currentSection = '';
893
- const sections = document.querySelectorAll('.tool-section');
894
-
895
- sections.forEach(section => {
896
- const sectionTop = section.offsetTop;
897
- const sectionHeight = section.clientHeight;
898
- if (pageYOffset >= sectionTop - 100) {
899
- currentSection = section.getAttribute('id');
900
- }
901
- });
902
-
903
- // 更新導航項的激活狀態
904
- navLinks.forEach(link => {
905
- link.classList.remove('active');
906
- if (link.getAttribute('href').substring(1) === currentSection) {
907
- link.classList.add('active');
908
- }
909
- });
910
- });
911
-
912
- // 平滑滾動
913
- navLinks.forEach(link => {
914
- link.addEventListener('click', function(e) {
915
- e.preventDefault();
916
- const targetId = this.getAttribute('href').substring(1);
917
- const targetElement = document.getElementById(targetId);
918
- window.scrollTo({
919
- top: targetElement.offsetTop - 20,
920
- behavior: 'smooth'
921
- });
922
- });
923
- });
924
- });
925
- </script>
926
- </body>
1
+ <!DOCTYPE html>
2
+ <html lang="zh-TW">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>ReAct Agent Tools Documentation</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
8
+ <link href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism.min.css" rel="stylesheet">
9
+ <style>
10
+ .tool-section {
11
+ margin-bottom: 2rem;
12
+ padding: 1rem;
13
+ border: 1px solid #dee2e6;
14
+ border-radius: 0.25rem;
15
+ }
16
+ .tool-name {
17
+ color: #0d6efd;
18
+ margin-bottom: 1rem;
19
+ padding-top: 60px; /* 為固定導航欄留出空間 */
20
+ margin-top: -60px; /* 抵消 padding-top */
21
+ }
22
+ .param-table {
23
+ margin-top: 1rem;
24
+ }
25
+ .doc-content {
26
+ white-space: pre-wrap;
27
+ font-family: monospace;
28
+ background-color: #f8f9fa;
29
+ padding: 1rem;
30
+ border-radius: 0.25rem;
31
+ }
32
+ #sidebar {
33
+ position: fixed;
34
+ top: 0;
35
+ left: 0;
36
+ height: 100vh;
37
+ width: 250px;
38
+ background-color: #f8f9fa;
39
+ padding: 20px;
40
+ overflow-y: auto;
41
+ border-right: 1px solid #dee2e6;
42
+ }
43
+ #main-content {
44
+ margin-left: 250px;
45
+ padding: 20px;
46
+ }
47
+ .nav-link {
48
+ color: #0d6efd;
49
+ padding: 5px 0;
50
+ }
51
+ .nav-link:hover {
52
+ background-color: #e9ecef;
53
+ }
54
+ .nav-link.active {
55
+ font-weight: bold;
56
+ background-color: #e9ecef;
57
+ }
58
+ </style>
59
+ </head>
60
+ <body>
61
+ <div id="sidebar">
62
+ <h5 class="mb-3">Tools</h5>
63
+ <nav class="nav flex-column">
64
+
65
+ <a class="nav-link" href="#chat_with_imgs">chat_with_imgs</a>
66
+
67
+ <a class="nav-link" href="#chat_with_pdf">chat_with_pdf</a>
68
+
69
+ <a class="nav-link" href="#create_html_page">create_html_page</a>
70
+
71
+ <a class="nav-link" href="#create_mermaid_diagram">create_mermaid_diagram</a>
72
+
73
+ <a class="nav-link" href="#create_plotly_chart">create_plotly_chart</a>
74
+
75
+ <a class="nav-link" href="#current_date_time">current_date_time</a>
76
+
77
+ <a class="nav-link" href="#generate_image">generate_image</a>
78
+
79
+ <a class="nav-link" href="#generate_tmp_public_url">generate_tmp_public_url</a>
80
+
81
+ <a class="nav-link" href="#scrape">scrape</a>
82
+
83
+ <a class="nav-link" href="#web_search">web_search</a>
84
+
85
+ </nav>
86
+ </div>
87
+
88
+ <div id="main-content">
89
+ <h1 class="mb-4">ReAct Agent Tools Documentation</h1>
90
+
91
+ <div class="row">
92
+ <div class="col-12">
93
+
94
+ <div class="tool-section" id="chat_with_imgs">
95
+ <h2 class="tool-name">@tool chat_with_imgs</h2>
96
+
97
+ <h4>Documentation:</h4>
98
+ <div class="doc-content">Use this to analyze and understand multiple images using Claude's vision capabilities.
99
+
100
+ If you have local image files, you can use generate_tmp_public_url tool multiple times to get public URLs first:
101
+ 1. Call generate_tmp_public_url for each local image file
102
+ 2. Collect all returned URLs into a list
103
+ 3. Use the list of URLs as the img_urls parameter for this function
104
+
105
+ Data Visualization Integration:
106
+ When the user's input indicates a need for comparison or data visualization (e.g., "compare the values in these charts",
107
+ "extract and plot the data from these images"), this function can return data in a format suitable for Plotly visualization.
108
+ The returned data will be a dictionary with a special key "__plotly_data__" containing:
109
+ {
110
+ "__plotly_data__": {
111
+ "data": [...], # Plotly data array
112
+ "layout": {...} # Plotly layout object
113
+ }
114
+ }
115
+ You can then pass this data to create_plotly_chart to generate an interactive chart.
116
+
117
+ Supported image formats:
118
+ - JPEG, PNG, GIF, WebP
119
+ - Maximum file size: 5MB per image
120
+ - Recommended size: No more than 1568 pixels in either dimension
121
+ - Very small images (under 200 pixels) may degrade performance
122
+ - Can analyze up to 20 images per request
123
+
124
+ Capabilities:
125
+ - Analyzing charts, graphs, and diagrams
126
+ - Reading and understanding text in images
127
+ - Describing visual content and scenes
128
+ - Comparing multiple images in a single request
129
+ - Answering questions about image details
130
+ - Identifying relationships between images
131
+ - Extracting data from charts for visualization
132
+
133
+ Limitations:
134
+ - Cannot identify or name specific people
135
+ - May have reduced accuracy with low-quality or very small images
136
+ - Limited spatial reasoning abilities
137
+ - Cannot verify if images are AI-generated
138
+ - Not designed for medical diagnosis or healthcare applications
139
+
140
+ Args:
141
+ img_urls: List of URLs to the image files (can be generated using generate_tmp_public_url for local files)
142
+ user_input: Question or instruction about the image content(s)
143
+
144
+ Returns:
145
+ str: Claude's analysis of the image(s) based on the query, or Plotly-compatible data structure if visualization is needed</div>
146
+
147
+ <h4 class="mt-3">Parameters:</h4>
148
+ <table class="table param-table">
149
+ <thead>
150
+ <tr>
151
+ <th>Name</th>
152
+ <th>Type</th>
153
+ <th>Default</th>
154
+ </tr>
155
+ </thead>
156
+ <tbody>
157
+
158
+ <tr>
159
+ <td>img_urls</td>
160
+ <td><code>list[str]</code></td>
161
+ <td>-</td>
162
+ </tr>
163
+
164
+ <tr>
165
+ <td>user_input</td>
166
+ <td><code><class 'str'></code></td>
167
+ <td>-</td>
168
+ </tr>
169
+
170
+ </tbody>
171
+ </table>
172
+
173
+ <h4 class="mt-3">Returns:</h4>
174
+ <code>Any</code>
175
+ </div>
176
+
177
+ <div class="tool-section" id="chat_with_pdf">
178
+ <h2 class="tool-name">@tool chat_with_pdf</h2>
179
+
180
+ <h4>Documentation:</h4>
181
+ <div class="doc-content">Use this to chat with a PDF file.
182
+ User can ask about any text, pictures, charts, and tables in PDFs that is provided. Some sample use cases:
183
+ - Analyzing financial reports and understanding charts/tables
184
+ - Extracting key information from legal documents
185
+ - Translation assistance for documents
186
+ - Converting document information into structured formats
187
+
188
+ Data Visualization Integration:
189
+ When the user's input indicates a need for comparison or data visualization (e.g., "compare the quarterly profits",
190
+ "show the trend of sales"), this function can return data in a format suitable for Plotly visualization.
191
+ The returned data will be a dictionary with a special key "__plotly_data__" containing:
192
+ {
193
+ "__plotly_data__": {
194
+ "data": [...], # Plotly data array
195
+ "layout": {...} # Plotly layout object
196
+ }
197
+ }
198
+ You can then pass this data to create_plotly_chart to generate an interactive chart.
199
+
200
+ If you have a local PDF file, you can use generate_tmp_public_url tool to get a public URL first:
201
+ 1. Call generate_tmp_public_url with your local PDF file path
202
+ 2. Use the returned URL as the pdf_url parameter for this function
203
+
204
+ Args:
205
+ pdf_url: the URL to the PDF file (can be generated using generate_tmp_public_url for local files)
206
+ user_input: the user's input
207
+
208
+ Returns:
209
+ str: Analysis result or Plotly-compatible data structure if visualization is needed</div>
210
+
211
+ <h4 class="mt-3">Parameters:</h4>
212
+ <table class="table param-table">
213
+ <thead>
214
+ <tr>
215
+ <th>Name</th>
216
+ <th>Type</th>
217
+ <th>Default</th>
218
+ </tr>
219
+ </thead>
220
+ <tbody>
221
+
222
+ <tr>
223
+ <td>pdf_url</td>
224
+ <td><code><class 'str'></code></td>
225
+ <td>-</td>
226
+ </tr>
227
+
228
+ <tr>
229
+ <td>user_input</td>
230
+ <td><code><class 'str'></code></td>
231
+ <td>-</td>
232
+ </tr>
233
+
234
+ </tbody>
235
+ </table>
236
+
237
+ <h4 class="mt-3">Returns:</h4>
238
+ <code>Any</code>
239
+ </div>
240
+
241
+ <div class="tool-section" id="create_html_page">
242
+ <h2 class="tool-name">@tool create_html_page</h2>
243
+
244
+ <h4>Documentation:</h4>
245
+ <div class="doc-content">Create a custom HTML page and return its URL.
246
+ This URL should be provided to the user, as they will need to access it to view the HTML content in their web browser.
247
+
248
+ 這個工具支援完整的HTML文檔,包括JavaScript和CSS,可以用來創建複雜的互動式頁面。
249
+
250
+ 使用 create_html_page 的情境:
251
+ - 需要展示自定義的HTML內容
252
+ - 需要嵌入複雜的互動式內容
253
+ - 需要製作自訂格式的報告或文件
254
+ - 需要使用第三方JavaScript庫
255
+ - 需要展示表格、圖像和多媒體內容
256
+ - 需要創建結構化且易於閱讀的内容呈現
257
+ - 需要使用CSS樣式創建美觀的界面
258
+ - 需要嵌入特殊的圖表或視覺元素
259
+
260
+ Input Options:
261
+ You can pass either:
262
+ 1. A complete HTML document with doctype, html, head, and body tags
263
+ 2. An HTML fragment that will be automatically wrapped in a basic HTML structure
264
+
265
+ Supported HTML Features:
266
+ - Complete HTML documents with your own structure
267
+ - Custom JavaScript for interactive elements
268
+ - Custom CSS for styling and layout
269
+ - External libraries and frameworks (via CDN)
270
+ - Tables, lists, and other structural elements
271
+ - Embedded images and multimedia (via URLs)
272
+ - Form elements (though they won't submit data)
273
+ - Responsive design elements
274
+ - Unicode and international text support
275
+
276
+ Security Considerations:
277
+ - HTML content is sandboxed in the browser
278
+ - Cannot access user's device or data
279
+ - External resources must be from trusted sources
280
+ - No server-side processing capability
281
+ - No personal data should be included in the HTML
282
+
283
+ Example of complete HTML document:
284
+ ```html
285
+ <!DOCTYPE html>
286
+ <html>
287
+ <head>
288
+ <meta charset="utf-8">
289
+ <title>互動式報告</title>
290
+ <style>
291
+ body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }
292
+ .container { max-width: 800px; margin: 0 auto; }
293
+ .chart { height: 300px; margin: 20px 0; border: 1px solid #ddd; }
294
+ </style>
295
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
296
+ </head>
297
+ <body>
298
+ <div class="container">
299
+ <h1>業績分析報告</h1>
300
+ <p>本報告提供了公司過去三個月的銷售數據分析。</p>
301
+ <div class="chart">
302
+ <canvas id="salesChart"></canvas>
303
+ </div>
304
+ <script>
305
+ // JavaScript可以直接在HTML中使用
306
+ const ctx = document.getElementById('salesChart').getContext('2d');
307
+ new Chart(ctx, {
308
+ type: 'bar',
309
+ data: {
310
+ labels: ['一月', '二月', '三月'],
311
+ datasets: [{
312
+ label: '銷售額(千元)',
313
+ data: [1200, 1900, 1500],
314
+ backgroundColor: ['#ff6384', '#36a2eb', '#ffce56']
315
+ }]
316
+ }
317
+ });
318
+ </script>
319
+ </div>
320
+ </body>
321
+ </html>
322
+ ```
323
+
324
+ Example of HTML fragment (will be auto-wrapped):
325
+ ```html
326
+ <div style="padding: 20px; background-color: #f0f8ff;">
327
+ <h1 style="color: #333; font-family: Arial, sans-serif;">客戶報告</h1>
328
+ <p>這份報告包含了重要的資訊。</p>
329
+ <table border="1" style="border-collapse: collapse; width: 100%;">
330
+ <tr>
331
+ <th>項目</th>
332
+ <th>數量</th>
333
+ <th>單價</th>
334
+ </tr>
335
+ <tr>
336
+ <td>產品A</td>
337
+ <td>10</td>
338
+ <td>$100</td>
339
+ </tr>
340
+ <tr>
341
+ <td>產品B</td>
342
+ <td>5</td>
343
+ <td>$200</td>
344
+ </tr>
345
+ </table>
346
+ </div>
347
+ ```
348
+
349
+ Args:
350
+ html_content: Complete HTML document or fragment. Can include JavaScript, CSS, and other elements.
351
+ title: Optional title for the HTML page. If provided, must be in Traditional Chinese.
352
+ For example: "客戶報告" instead of "Client Report"
353
+ Note: This is only used if the HTML content doesn't already have a title.
354
+
355
+ Returns:
356
+ str: URL for the HTML page. This URL should be provided to the user,
357
+ as they will need to access it to view the content in their web browser.</div>
358
+
359
+ <h4 class="mt-3">Parameters:</h4>
360
+ <table class="table param-table">
361
+ <thead>
362
+ <tr>
363
+ <th>Name</th>
364
+ <th>Type</th>
365
+ <th>Default</th>
366
+ </tr>
367
+ </thead>
368
+ <tbody>
369
+
370
+ <tr>
371
+ <td>html_content</td>
372
+ <td><code><class 'str'></code></td>
373
+ <td>-</td>
374
+ </tr>
375
+
376
+ <tr>
377
+ <td>title</td>
378
+ <td><code><class 'str'></code></td>
379
+ <td><code>None</code></td>
380
+ </tr>
381
+
382
+ </tbody>
383
+ </table>
384
+
385
+ <h4 class="mt-3">Returns:</h4>
386
+ <code><class 'str'></code>
387
+ </div>
388
+
389
+ <div class="tool-section" id="create_mermaid_diagram">
390
+ <h2 class="tool-name">@tool create_mermaid_diagram</h2>
391
+
392
+ <h4>Documentation:</h4>
393
+ <div class="doc-content">Create an interactive Mermaid diagram visualization and return its URL.
394
+ This URL should be provided to the user,
395
+ as they will need to access it to view the interactive diagram in their web browser.
396
+
397
+ 使用 create_mermaid_diagram 的情境:
398
+ - 提到「流程圖」、「架構圖」、「關係圖」等字眼
399
+ - 需要展示系統架構(flowchart)
400
+ - 需要說明操作流程(flowchart)
401
+ - 需要展示時序互動(sequence diagram)
402
+ - 需要展示狀態轉換(state diagram)
403
+ - 需要展示類別關係(class diagram)
404
+ - 需要展示實體關係(ER diagram)
405
+ - 需要展示專案時程(gantt chart)
406
+ - 需要展示使用者旅程(journey)
407
+ - 需要展示需求關係(requirement diagram)
408
+ - 需要展示資源分配(pie chart)
409
+
410
+ Supported Diagram Types:
411
+ 1. Flowcharts (graph TD/LR):
412
+ - System architectures
413
+ - Process flows
414
+ - Decision trees
415
+ - Data flows
416
+
417
+ 2. Sequence Diagrams (sequenceDiagram):
418
+ - API interactions
419
+ - System communications
420
+ - User interactions
421
+ - Message flows
422
+
423
+ 3. Class Diagrams (classDiagram):
424
+ - Software architecture
425
+ - Object relationships
426
+ - System components
427
+ - Code structure
428
+
429
+ 4. State Diagrams (stateDiagram-v2):
430
+ - System states
431
+ - Workflow states
432
+ - Process states
433
+ - State transitions
434
+
435
+ 5. Entity Relationship Diagrams (erDiagram):
436
+ - Database schemas
437
+ - Data relationships
438
+ - System entities
439
+ - Data models
440
+
441
+ 6. User Journey Diagrams (journey):
442
+ - User experiences
443
+ - Customer flows
444
+ - Process steps
445
+ - Task sequences
446
+
447
+ 7. Gantt Charts (gantt):
448
+ - Project timelines
449
+ - Task schedules
450
+ - Resource allocation
451
+ - Milestone tracking
452
+
453
+ 8. Pie Charts (pie):
454
+ - Data distribution
455
+ - Resource allocation
456
+ - Market share
457
+ - Component breakdown
458
+
459
+ 9. Requirement Diagrams (requirementDiagram):
460
+ - System requirements
461
+ - Dependencies
462
+ - Specifications
463
+ - Constraints
464
+
465
+ Example Mermaid syntax for a simple flowchart:
466
+ ```
467
+ graph TD
468
+ A[開始] --> B{是否有資料?}
469
+ B -->|是| C[處理資料]
470
+ B -->|否| D[取得資料]
471
+ C --> E[結束]
472
+ D --> B
473
+ ```
474
+
475
+ Args:
476
+ mermaid_data: String containing the Mermaid diagram definition
477
+ title: Optional title for the diagram. If provided, must be in Traditional Chinese.
478
+ For example: "系統流程圖" instead of "System Flowchart"
479
+
480
+ Returns:
481
+ str: URL for the interactive HTML visualization. This URL should be provided to the user,
482
+ as they will need to access it to view the interactive diagram in their web browser.</div>
483
+
484
+ <h4 class="mt-3">Parameters:</h4>
485
+ <table class="table param-table">
486
+ <thead>
487
+ <tr>
488
+ <th>Name</th>
489
+ <th>Type</th>
490
+ <th>Default</th>
491
+ </tr>
492
+ </thead>
493
+ <tbody>
494
+
495
+ <tr>
496
+ <td>mermaid_data</td>
497
+ <td><code><class 'str'></code></td>
498
+ <td>-</td>
499
+ </tr>
500
+
501
+ <tr>
502
+ <td>title</td>
503
+ <td><code><class 'str'></code></td>
504
+ <td><code>None</code></td>
505
+ </tr>
506
+
507
+ </tbody>
508
+ </table>
509
+
510
+ <h4 class="mt-3">Returns:</h4>
511
+ <code><class 'str'></code>
512
+ </div>
513
+
514
+ <div class="tool-section" id="create_plotly_chart">
515
+ <h2 class="tool-name">@tool create_plotly_chart</h2>
516
+
517
+ <h4>Documentation:</h4>
518
+ <div class="doc-content">Create an interactive Plotly visualization and return its URL.
519
+ This URL should be provided to the user,
520
+ as they will need to access it to view the interactive chart in their web browser.
521
+
522
+ 使用 create_plotly_chart 的情境:
523
+ - 提到「圖表」、「統計圖」、「視覺化」等字眼
524
+ - 需要呈現數據趨勢(折線圖)
525
+ - 需要比較數值(長條圖、圓餅圖)
526
+ - 需要展示分布情況(散點圖、熱力圖)
527
+ - 需要顯示時間序列資料(時間軸圖)
528
+ - 需要展示地理資訊(地圖)
529
+ - 需要多維度資料分析(3D圖、氣泡圖)
530
+ - 需要展示統計分布(箱型圖)
531
+ - 需要展示累積趨勢(面積圖)
532
+ - 需要互動式資料探索
533
+
534
+ Integration with Other Tools:
535
+ This function can be used in conjunction with chat_with_imgs and chat_with_pdf when they return data
536
+ suitable for visualization. When those tools detect a need for visualization, they will return a JSON string
537
+ with a "__plotly_data__" key, which can be directly passed to this function.
538
+
539
+ Example workflow:
540
+ 1. User asks to analyze and visualize data from images/PDFs
541
+ 2. chat_with_imgs or chat_with_pdf returns JSON string with "__plotly_data__" key
542
+ 3. Pass that string to this function to get an interactive visualization URL
543
+
544
+ Supported Chart Types:
545
+ - Line charts: For showing trends and time series data
546
+ - Bar charts: For comparing values across categories
547
+ - Pie charts: For showing proportions of a whole
548
+ - Scatter plots: For showing relationships between variables
549
+ - Heat maps: For showing patterns in matrix data
550
+ - Box plots: For showing statistical distributions
551
+ - Geographic maps: For showing spatial data
552
+ - 3D plots: For showing three-dimensional data
553
+ - Bubble charts: For showing three variables in 2D
554
+ - Area charts: For showing cumulative totals over time
555
+
556
+ The figure_data should be a JSON string containing plotly figure specifications with 'data' and 'layout'.
557
+ Example:
558
+ {
559
+ 'data': [{
560
+ 'type': 'scatter',
561
+ 'x': [1, 2, 3, 4],
562
+ 'y': [10, 15, 13, 17]
563
+ }],
564
+ 'layout': {
565
+ 'title': 'My Plot'
566
+ }
567
+ }
568
+
569
+ Args:
570
+ figure_data: JSON string containing plotly figure specifications or output from chat_with_imgs/chat_with_pdf.
571
+ Will be parsed using json.loads().
572
+ title: Optional title for the plot. If provided, must be in Traditional Chinese.
573
+ For example: "台灣人口統計圖表" instead of "Taiwan Population Chart"
574
+
575
+ Returns:
576
+ str: URL for the interactive HTML visualization. This URL should be provided to the user,
577
+ as they will need to access it to view the interactive chart in their web browser.</div>
578
+
579
+ <h4 class="mt-3">Parameters:</h4>
580
+ <table class="table param-table">
581
+ <thead>
582
+ <tr>
583
+ <th>Name</th>
584
+ <th>Type</th>
585
+ <th>Default</th>
586
+ </tr>
587
+ </thead>
588
+ <tbody>
589
+
590
+ <tr>
591
+ <td>figure_data</td>
592
+ <td><code><class 'str'></code></td>
593
+ <td>-</td>
594
+ </tr>
595
+
596
+ <tr>
597
+ <td>title</td>
598
+ <td><code><class 'str'></code></td>
599
+ <td><code>None</code></td>
600
+ </tr>
601
+
602
+ </tbody>
603
+ </table>
604
+
605
+ <h4 class="mt-3">Returns:</h4>
606
+ <code><class 'str'></code>
607
+ </div>
608
+
609
+ <div class="tool-section" id="current_date_time">
610
+ <h2 class="tool-name">@tool current_date_time</h2>
611
+
612
+ <h4>Documentation:</h4>
613
+ <div class="doc-content">Use this to get the current date and time in local timezone.
614
+
615
+ Important: You MUST call this current_date_time function when:
616
+ 1. User's query contains time-related words such as:
617
+ - 今天、現在、目前
618
+ - 本週、這週、下週
619
+ - 本月、這個月、上個月
620
+ - 今年、去年、明年
621
+ - 最近、近期
622
+ - 未來、將來
623
+ - 過去、以前
624
+ 2. User asks about current events or latest information
625
+ 3. User wants to know time-sensitive information
626
+ 4. Queries involving relative time expressions
627
+
628
+ Examples of when to use current_date_time:
629
+ - "今天的天氣如何?"
630
+ - "本月的股市表現"
631
+ - "最近有什麼新聞?"
632
+ - "去年到現在的經濟成長"
633
+ - "未來一週的活動預告"
634
+ - "這個月的銷售數據"
635
+
636
+ Returns:
637
+ str: Current date and time in format "YYYY-MM-DD HH:MM Asia/Taipei"</div>
638
+
639
+ <h4 class="mt-3">Parameters:</h4>
640
+ <table class="table param-table">
641
+ <thead>
642
+ <tr>
643
+ <th>Name</th>
644
+ <th>Type</th>
645
+ <th>Default</th>
646
+ </tr>
647
+ </thead>
648
+ <tbody>
649
+
650
+ </tbody>
651
+ </table>
652
+
653
+ <h4 class="mt-3">Returns:</h4>
654
+ <code>Any</code>
655
+ </div>
656
+
657
+ <div class="tool-section" id="generate_image">
658
+ <h2 class="tool-name">@tool generate_image</h2>
659
+
660
+ <h4>Documentation:</h4>
661
+ <div class="doc-content">Use this to generate high-quality images using DALL-E 3.
662
+
663
+ Capabilities:
664
+ - Creates photorealistic images and art
665
+ - Handles complex scenes and compositions
666
+ - Maintains consistent styles
667
+ - Follows detailed prompts with high accuracy
668
+ - Supports various artistic styles and mediums
669
+
670
+ Best practices for prompts:
671
+ - Be specific about style, mood, lighting, and composition
672
+ - Include details about perspective and setting
673
+ - Specify artistic medium if desired (e.g., "oil painting", "digital art")
674
+ - Mention color schemes or specific colors
675
+ - Describe the atmosphere or emotion you want to convey
676
+
677
+ Limitations:
678
+ - Cannot generate images of public figures or celebrities
679
+ - Avoids harmful, violent, or adult content
680
+ - May have inconsistencies with hands, faces, or text
681
+ - Cannot generate exact copies of existing artworks or brands
682
+ - Limited to single image generation per request
683
+
684
+ Args:
685
+ user_input: Detailed description of the image you want to generate.
686
+ Be specific about style, content, and composition.
687
+
688
+ Returns:
689
+ str: URL to the generated image, or error message if generation fails</div>
690
+
691
+ <h4 class="mt-3">Parameters:</h4>
692
+ <table class="table param-table">
693
+ <thead>
694
+ <tr>
695
+ <th>Name</th>
696
+ <th>Type</th>
697
+ <th>Default</th>
698
+ </tr>
699
+ </thead>
700
+ <tbody>
701
+
702
+ <tr>
703
+ <td>user_input</td>
704
+ <td><code><class 'str'></code></td>
705
+ <td>-</td>
706
+ </tr>
707
+
708
+ </tbody>
709
+ </table>
710
+
711
+ <h4 class="mt-3">Returns:</h4>
712
+ <code>Any</code>
713
+ </div>
714
+
715
+ <div class="tool-section" id="generate_tmp_public_url">
716
+ <h2 class="tool-name">@tool generate_tmp_public_url</h2>
717
+
718
+ <h4>Documentation:</h4>
719
+ <div class="doc-content">使用者會給你一個本地端的檔案路徑,請你使用這個 generate_tmp_public_url tool 生成一個臨時的公開 URL,這個 URL 可以讓使用者下載這個檔案。
720
+ 如果使用者給了多個本地端的檔案路徑,請你多次呼叫這個 tool,並將每次呼叫的回傳值收集起來。
721
+
722
+ Args:
723
+ file_path: The path to the local file you want to make publicly accessible
724
+
725
+ Returns:
726
+ str: A public URL that can be used to access the file for 7 days
727
+
728
+ Raises:
729
+ FileNotFoundError: If the specified file does not exist</div>
730
+
731
+ <h4 class="mt-3">Parameters:</h4>
732
+ <table class="table param-table">
733
+ <thead>
734
+ <tr>
735
+ <th>Name</th>
736
+ <th>Type</th>
737
+ <th>Default</th>
738
+ </tr>
739
+ </thead>
740
+ <tbody>
741
+
742
+ <tr>
743
+ <td>file_path</td>
744
+ <td><code><class 'str'></code></td>
745
+ <td>-</td>
746
+ </tr>
747
+
748
+ </tbody>
749
+ </table>
750
+
751
+ <h4 class="mt-3">Returns:</h4>
752
+ <code><class 'str'></code>
753
+ </div>
754
+
755
+ <div class="tool-section" id="scrape">
756
+ <h2 class="tool-name">@tool scrape</h2>
757
+
758
+ <h4>Documentation:</h4>
759
+ <div class="doc-content">Use this to scrape the web.
760
+ as it provides better results for video content.
761
+
762
+ Args:
763
+ url: the url to scrape</div>
764
+
765
+ <h4 class="mt-3">Parameters:</h4>
766
+ <table class="table param-table">
767
+ <thead>
768
+ <tr>
769
+ <th>Name</th>
770
+ <th>Type</th>
771
+ <th>Default</th>
772
+ </tr>
773
+ </thead>
774
+ <tbody>
775
+
776
+ <tr>
777
+ <td>url</td>
778
+ <td><code><class 'str'></code></td>
779
+ <td>-</td>
780
+ </tr>
781
+
782
+ </tbody>
783
+ </table>
784
+
785
+ <h4 class="mt-3">Returns:</h4>
786
+ <code>Any</code>
787
+ </div>
788
+
789
+ <div class="tool-section" id="web_search">
790
+ <h2 class="tool-name">@tool web_search</h2>
791
+
792
+ <h4>Documentation:</h4>
793
+ <div class="doc-content">Use this to search the web when you need up-to-date information or when your knowledge is insufficient.
794
+ This tool uses Perplexity to perform web searches and provides detailed answers with citations.
795
+
796
+ 除非使用者堅持要做多輪搜尋,不然這個工具能夠一次進行多個條件的搜尋,比如:
797
+ 一次進行多條件範例1:
798
+ - 可以:
799
+ - web_search("搜尋今天的體育、財經、政治新聞", current_date_time)
800
+ - 不需要:
801
+ - web_search("搜尋今天的體育新聞", current_date_time)
802
+ - web_search("搜尋今天的財經新聞", current_date_time)
803
+ - web_search("搜尋今天的政台新聞", current_date_time)
804
+
805
+ Time/Date Information Requirements:
806
+ 1. MUST preserve any specific dates or time periods mentioned in the user's query
807
+ 2. Include both the current time and any specific time references from the query
808
+
809
+ Examples:
810
+ - Basic query:
811
+ User asks: "台灣的人口數量"
812
+ web_search("台灣的人口數量", "2024-03-20 14:30 Asia/Taipei")
813
+ Actual search: "台灣的人口數量"
814
+ Returns: {
815
+ "content": "根據最新統計,台灣人口約為2300萬...",
816
+ "citations": [
817
+ {"title": "內政部統計處", "url": "https://www.moi.gov.tw/..."},
818
+ {"title": "國家發展委員會", "url": "https://www.ndc.gov.tw/..."}
819
+ ]
820
+ }
821
+
822
+ - Query with specific date:
823
+ User asks: "幫我查詢 2025/1/1 的新聞"
824
+ web_search("幫我查詢 2025/1/1 的新聞", "2024-03-20 14:30 Asia/Taipei")
825
+ Returns: {
826
+ "content": "關於2025年1月1日的新聞預測...",
827
+ "citations": [
828
+ {"title": "經濟日報", "url": "https://money.udn.com/..."},
829
+ {"title": "中央社", "url": "https://www.cna.com.tw/..."}
830
+ ]
831
+ }
832
+
833
+ Args:
834
+ user_input: The search query or question you want to find information about.
835
+ MUST include any specific time periods or dates from the original query.
836
+ Examples of time formats to preserve:
837
+ - Specific dates: "2025/1/1", "2023-12-31"
838
+ - Years: "2023年"
839
+ - Quarters/Months: "第一季", "Q1", "一月"
840
+ - Time periods: "過去三年", "未來五年"
841
+ current_date_time: The current time string MUST be got by current_date_time() tool. You can NOT use the current time from your own knowledge.
842
+ Format: "YYYY-MM-DD HH:MM Asia/Taipei"
843
+
844
+ Returns:
845
+ dict: A dictionary containing:
846
+ - content (str): The detailed answer based on web search results
847
+ - citations (list): A list of URLs, citation對使用者很重要,務必提供給使用者</div>
848
+
849
+ <h4 class="mt-3">Parameters:</h4>
850
+ <table class="table param-table">
851
+ <thead>
852
+ <tr>
853
+ <th>Name</th>
854
+ <th>Type</th>
855
+ <th>Default</th>
856
+ </tr>
857
+ </thead>
858
+ <tbody>
859
+
860
+ <tr>
861
+ <td>user_input</td>
862
+ <td><code><class 'str'></code></td>
863
+ <td>-</td>
864
+ </tr>
865
+
866
+ <tr>
867
+ <td>current_date_time</td>
868
+ <td><code><class 'str'></code></td>
869
+ <td>-</td>
870
+ </tr>
871
+
872
+ </tbody>
873
+ </table>
874
+
875
+ <h4 class="mt-3">Returns:</h4>
876
+ <code><class 'dict'></code>
877
+ </div>
878
+
879
+ </div>
880
+ </div>
881
+ </div>
882
+
883
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
884
+ <script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js"></script>
885
+ <script>
886
+ // 高亮當前選中的導航項
887
+ document.addEventListener('DOMContentLoaded', function() {
888
+ const navLinks = document.querySelectorAll('.nav-link');
889
+
890
+ // 監聽滾動事件
891
+ window.addEventListener('scroll', function() {
892
+ let currentSection = '';
893
+ const sections = document.querySelectorAll('.tool-section');
894
+
895
+ sections.forEach(section => {
896
+ const sectionTop = section.offsetTop;
897
+ const sectionHeight = section.clientHeight;
898
+ if (pageYOffset >= sectionTop - 100) {
899
+ currentSection = section.getAttribute('id');
900
+ }
901
+ });
902
+
903
+ // 更新導航項的激活狀態
904
+ navLinks.forEach(link => {
905
+ link.classList.remove('active');
906
+ if (link.getAttribute('href').substring(1) === currentSection) {
907
+ link.classList.add('active');
908
+ }
909
+ });
910
+ });
911
+
912
+ // 平滑滾動
913
+ navLinks.forEach(link => {
914
+ link.addEventListener('click', function(e) {
915
+ e.preventDefault();
916
+ const targetId = this.getAttribute('href').substring(1);
917
+ const targetElement = document.getElementById(targetId);
918
+ window.scrollTo({
919
+ top: targetElement.offsetTop - 20,
920
+ behavior: 'smooth'
921
+ });
922
+ });
923
+ });
924
+ });
925
+ </script>
926
+ </body>
927
927
  </html>