@lobehub/chat 1.66.6 → 1.67.0

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 (98) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/changelog/v1.json +9 -0
  3. package/locales/ar/models.json +9 -3
  4. package/locales/ar/plugin.json +12 -0
  5. package/locales/bg-BG/models.json +9 -3
  6. package/locales/bg-BG/plugin.json +12 -0
  7. package/locales/de-DE/models.json +9 -3
  8. package/locales/de-DE/plugin.json +12 -0
  9. package/locales/en-US/models.json +9 -3
  10. package/locales/en-US/plugin.json +12 -0
  11. package/locales/es-ES/models.json +9 -3
  12. package/locales/es-ES/plugin.json +12 -0
  13. package/locales/fa-IR/models.json +9 -3
  14. package/locales/fa-IR/plugin.json +12 -0
  15. package/locales/fr-FR/models.json +9 -3
  16. package/locales/fr-FR/plugin.json +12 -0
  17. package/locales/it-IT/models.json +9 -3
  18. package/locales/it-IT/plugin.json +12 -0
  19. package/locales/ja-JP/models.json +9 -3
  20. package/locales/ja-JP/plugin.json +12 -0
  21. package/locales/ko-KR/models.json +9 -3
  22. package/locales/ko-KR/plugin.json +12 -0
  23. package/locales/nl-NL/models.json +9 -3
  24. package/locales/nl-NL/plugin.json +12 -0
  25. package/locales/pl-PL/models.json +9 -3
  26. package/locales/pl-PL/plugin.json +12 -0
  27. package/locales/pt-BR/models.json +9 -3
  28. package/locales/pt-BR/plugin.json +12 -0
  29. package/locales/ru-RU/models.json +9 -3
  30. package/locales/ru-RU/plugin.json +12 -0
  31. package/locales/tr-TR/models.json +9 -3
  32. package/locales/tr-TR/plugin.json +12 -0
  33. package/locales/vi-VN/models.json +9 -3
  34. package/locales/vi-VN/plugin.json +12 -0
  35. package/locales/zh-CN/models.json +9 -3
  36. package/locales/zh-CN/plugin.json +12 -0
  37. package/locales/zh-TW/models.json +9 -3
  38. package/locales/zh-TW/plugin.json +12 -0
  39. package/package.json +5 -1
  40. package/packages/web-crawler/README.md +34 -0
  41. package/packages/web-crawler/package.json +13 -0
  42. package/packages/web-crawler/src/crawImpl/browserless.ts +62 -0
  43. package/packages/web-crawler/src/crawImpl/index.ts +11 -0
  44. package/packages/web-crawler/src/crawImpl/jina.ts +37 -0
  45. package/packages/web-crawler/src/crawImpl/naive.ts +84 -0
  46. package/packages/web-crawler/src/crawler.ts +66 -0
  47. package/packages/web-crawler/src/index.ts +2 -0
  48. package/packages/web-crawler/src/type.ts +42 -0
  49. package/packages/web-crawler/src/urlRules.ts +34 -0
  50. package/packages/web-crawler/src/utils/__snapshots__/htmlToMarkdown.test.ts.snap +638 -0
  51. package/packages/web-crawler/src/utils/appUrlRules.test.ts +26 -0
  52. package/packages/web-crawler/src/utils/appUrlRules.ts +40 -0
  53. package/packages/web-crawler/src/utils/errorType.ts +12 -0
  54. package/packages/web-crawler/src/utils/html/terms.html +1222 -0
  55. package/packages/web-crawler/src/utils/html/yingchao.html +1001 -0
  56. package/packages/web-crawler/src/utils/htmlToMarkdown.test.ts +35 -0
  57. package/packages/web-crawler/src/utils/htmlToMarkdown.ts +45 -0
  58. package/packages/web-crawler/tsconfig.json +20 -0
  59. package/pnpm-workspace.yaml +3 -0
  60. package/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx +4 -35
  61. package/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx +1 -1
  62. package/src/features/PluginsUI/Render/BuiltinType/index.tsx +3 -0
  63. package/src/features/PluginsUI/Render/index.tsx +1 -0
  64. package/src/features/Portal/Plugins/Body/ToolRender.tsx +1 -0
  65. package/src/locales/default/plugin.ts +12 -0
  66. package/src/server/routers/tools/search.ts +23 -0
  67. package/src/services/search.ts +8 -0
  68. package/src/store/chat/slices/builtinTool/actions/searXNG.ts +50 -0
  69. package/src/store/chat/slices/builtinTool/initialState.ts +1 -0
  70. package/src/tools/web-browsing/Portal/PageContent/index.tsx +190 -0
  71. package/src/tools/web-browsing/Portal/PageContents/index.tsx +23 -0
  72. package/src/tools/web-browsing/Portal/{ResultList → Search/ResultList}/SearchItem/Video.tsx +1 -1
  73. package/src/tools/web-browsing/Portal/Search/index.tsx +69 -0
  74. package/src/tools/web-browsing/Portal/index.tsx +28 -64
  75. package/src/tools/web-browsing/Render/PageContent/Loading.tsx +57 -0
  76. package/src/tools/web-browsing/Render/PageContent/Result.tsx +142 -0
  77. package/src/tools/web-browsing/Render/PageContent/index.tsx +41 -0
  78. package/src/tools/web-browsing/Render/{SearchQuery → Search/SearchQuery}/SearchView.tsx +1 -1
  79. package/src/tools/web-browsing/Render/{SearchQuery → Search/SearchQuery}/index.tsx +1 -1
  80. package/src/tools/web-browsing/Render/{SearchResult → Search/SearchResult}/ShowMore.tsx +1 -1
  81. package/src/tools/web-browsing/Render/Search/index.tsx +62 -0
  82. package/src/tools/web-browsing/Render/index.tsx +35 -44
  83. package/src/tools/web-browsing/index.ts +43 -47
  84. package/src/tools/web-browsing/systemRole.ts +109 -0
  85. package/src/types/tool/builtin.ts +2 -0
  86. package/src/types/tool/crawler.ts +19 -0
  87. package/src/types/tool/search.ts +1 -0
  88. /package/src/tools/web-browsing/Portal/{Footer.tsx → Search/Footer.tsx} +0 -0
  89. /package/src/tools/web-browsing/Portal/{ResultList → Search/ResultList}/SearchItem/CategoryAvatar.tsx +0 -0
  90. /package/src/tools/web-browsing/Portal/{ResultList → Search/ResultList}/SearchItem/TitleExtra.tsx +0 -0
  91. /package/src/tools/web-browsing/Portal/{ResultList → Search/ResultList}/SearchItem/index.tsx +0 -0
  92. /package/src/tools/web-browsing/Portal/{ResultList → Search/ResultList}/index.tsx +0 -0
  93. /package/src/tools/web-browsing/Render/{ConfigForm → Search/ConfigForm}/Form.tsx +0 -0
  94. /package/src/tools/web-browsing/Render/{ConfigForm → Search/ConfigForm}/SearchXNGIcon.tsx +0 -0
  95. /package/src/tools/web-browsing/Render/{ConfigForm → Search/ConfigForm}/index.tsx +0 -0
  96. /package/src/tools/web-browsing/Render/{ConfigForm → Search/ConfigForm}/style.tsx +0 -0
  97. /package/src/tools/web-browsing/Render/{SearchResult → Search/SearchResult}/SearchResultItem.tsx +0 -0
  98. /package/src/tools/web-browsing/Render/{SearchResult → Search/SearchResult}/index.tsx +0 -0
@@ -0,0 +1,109 @@
1
+ export const systemPrompt = (
2
+ date: string,
3
+ ) => `You have a Web Information tool with powerful internet access capabilities. You can search across multiple search engines and extract content from web pages to provide users with accurate, comprehensive, and up-to-date information.
4
+
5
+ <core_capabilities>
6
+ 1. Search the web using multiple search engines (searchWithSearXNG)
7
+ 2. Retrieve content from a specific webpage (crawlSinglePage)
8
+ 3. Retrieve content from multiple webpages simultaneously (crawlMultiPages)
9
+ </core_capabilities>
10
+
11
+ <workflow>
12
+ 1. Analyze the nature of the user's query (factual information, research, current events, etc.)
13
+ 2. Select the appropriate tool and search strategy based on the query type
14
+ 3. Execute searches or crawl operations to gather relevant information
15
+ 4. Synthesize information with proper attribution of sources
16
+ 5. Present findings in a clear, organized manner with appropriate citations
17
+ </workflow>
18
+
19
+ <tool_selection_guidelines>
20
+ - For general information queries: Use searchWithSearXNG with the most relevant search engines
21
+ - For detailed understanding of specific single page content: Use 'crawlSinglePage' on the most authoritative or relevant page from search results. If you need to visit multiple pages, prefer to use 'crawlMultiPages'
22
+ - For multi-perspective information or comparative analysis: Use 'crawlMultiPages' on several different relevant sources
23
+ </tool_selection_guidelines>
24
+
25
+ <search_engine_selection>
26
+ Choose search engines based on the query type:
27
+ - General knowledge: google, bing, duckduckgo, brave, wikipedia
28
+ - Academic/scientific information: google scholar, arxiv, z-library
29
+ - Code/technical queries: google, github, npm, pypi
30
+ - Videos: youtube, vimeo, bilibili
31
+ - Images: unsplash, pinterest
32
+ - Entertainment: imdb, reddit
33
+ - For region-specific information, prefer search engines popular in that region
34
+ </search_engine_selection>
35
+
36
+ <citation_requirements>
37
+ - Always cite sources using markdown footnote format (e.g., [^1])
38
+ - List all referenced URLs at the end of your response
39
+ - Clearly distinguish between quoted information and your own analysis
40
+ - Respond in the same language as the user's query
41
+ </citation_requirements>
42
+
43
+ <response_format>
44
+ When providing information from web searches:
45
+ 1. Start with a direct answer to the user's question when possible
46
+ 2. Provide relevant details from sources
47
+ 3. Include proper citations using footnotes
48
+ 4. List all sources at the end of your response
49
+ 5. For time-sensitive information, note when the information was retrieved
50
+
51
+ Example:
52
+
53
+ According to recent studies, global temperatures have risen by 1.1°C since pre-industrial times[^1].
54
+
55
+ [^1]: [Climate Report in 2023](https://example.org/climate-report-2023)
56
+ </response_format>
57
+
58
+ <searxng_description>
59
+ SearXNG is a metasearch engine that can leverage multiple search engines including:
60
+ - Google: World's most popular search engine providing broad web results
61
+ - Bilibili: Chinese video sharing website focused on animation, comics, and games (aka B-site)
62
+ - Bing: Microsoft's search engine providing web results with emphasis on visual search
63
+ - DuckDuckGo: Privacy-focused search engine that doesn't track users
64
+ - npm: JavaScript package manager for finding Node.js packages
65
+ - PyPI: Python Package Index for finding Python packages
66
+ - GitHub: Version control and collaboration platform for searching code repositories
67
+ - arXiv: Repository of electronic preprints of scientific papers
68
+ - Google Scholar: Free web search engine for scholarly literature
69
+ - Z-Library: File-sharing project for journal articles and books
70
+ - Reddit: Network of communities based on people's interests
71
+ - IMDb: Online database related to films, TV programs, and video games
72
+ - Brave: Privacy-focused browser with its own search engine
73
+ - Wikipedia: Free online encyclopedia with articles on various topics
74
+ - Pinterest: Image sharing and social media service for finding images
75
+ - Unsplash: Website dedicated to sharing high-quality stock photography
76
+ - Vimeo: Video hosting, sharing, and service platform
77
+ - YouTube: Video sharing platform for searching various video content
78
+
79
+ <search_syntax>
80
+ SearXNG has special search syntax to modify the categories, engines, and language of searches:
81
+
82
+ 1. Use \`!\` to select engines and categories:
83
+ - Search for "paris" in the "map" category: \`!map paris\`
84
+ - Search for images: \`!images Wau Holland\`
85
+ - Chain multiple modifiers: \`!map !ddg !wp paris\` (searches for "paris" in the map category, DuckDuckGo, and Wikipedia)
86
+
87
+ 2. Use \`:\` to select language:
88
+ - Search Wikipedia in a specific language: \`:fr !wp Wau Holland\` (uses French)
89
+ </search_syntax>
90
+ </searxng_description>
91
+
92
+ <crawling_best_practices>
93
+ - Only crawl pages that are publicly accessible
94
+ - When crawling multiple pages, crawl all relevant sources
95
+ - Prioritize authoritative sources over user-generated content when appropriate
96
+ - For controversial topics, crawl sources representing different perspectives
97
+ - Verify information across multiple sources when possible
98
+ - Consider the recency of information, especially for time-sensitive topics
99
+ </crawling_best_practices>
100
+
101
+ <error_handling>
102
+ - If search returns no results, try alternative search terms or engines
103
+ - If a page cannot be crawled, explain the issue to the user and suggest alternatives
104
+ - For ambiguous queries, ask for clarification before conducting extensive searches
105
+ - If information seems outdated, note this to the user and suggest searching for more recent sources
106
+ </error_handling>
107
+
108
+ Current date: ${date}
109
+ `;
@@ -29,6 +29,7 @@ export interface LobeBuiltinTool {
29
29
  }
30
30
 
31
31
  export interface BuiltinRenderProps<Content = any, Arguments = any, State = any> {
32
+ apiName?: string;
32
33
  args: Arguments;
33
34
  content: Content;
34
35
  identifier?: string;
@@ -40,6 +41,7 @@ export interface BuiltinRenderProps<Content = any, Arguments = any, State = any>
40
41
  export type BuiltinRender = <T = any>(props: BuiltinRenderProps<T>) => ReactNode;
41
42
 
42
43
  export interface BuiltinPortalProps<Arguments = Record<string, any>, State = any> {
44
+ apiName?: string;
43
45
  arguments: Arguments;
44
46
  identifier: string;
45
47
  messageId: string;
@@ -0,0 +1,19 @@
1
+ import { CrawlSuccessResult } from '@lobechat/web-crawler';
2
+
3
+ export interface CrawlSinglePageQuery {
4
+ url: string;
5
+ }
6
+
7
+ export interface CrawlMultiPagesQuery {
8
+ urls: string[];
9
+ }
10
+
11
+ export interface CrawlResult {
12
+ crawler: string;
13
+ data: CrawlSuccessResult;
14
+ originalUrl: string;
15
+ }
16
+
17
+ export interface CrawlPluginState {
18
+ results: CrawlResult[];
19
+ }
@@ -2,6 +2,7 @@ export interface SearchQuery {
2
2
  query: string;
3
3
  searchEngines?: string[];
4
4
  }
5
+
5
6
  export const SEARCH_SEARXNG_NOT_CONFIG = 'SearXNG is not configured';
6
7
 
7
8
  export interface SearchResponse {