@lobehub/chat 1.90.4 → 1.91.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 1.91.0](https://github.com/lobehub/lobe-chat/compare/v1.90.4...v1.91.0)
6
+
7
+ <sup>Released on **2025-06-03**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: Add more provider support for search & crawl.
12
+
13
+ #### 💄 Styles
14
+
15
+ - **misc**: Update modelscope models.
16
+
17
+ <br/>
18
+
19
+ <details>
20
+ <summary><kbd>Improvements and Fixes</kbd></summary>
21
+
22
+ #### What's improved
23
+
24
+ - **misc**: Add more provider support for search & crawl, closes [#8033](https://github.com/lobehub/lobe-chat/issues/8033) ([23fade3](https://github.com/lobehub/lobe-chat/commit/23fade3))
25
+
26
+ #### Styles
27
+
28
+ - **misc**: Update modelscope models, closes [#8057](https://github.com/lobehub/lobe-chat/issues/8057) ([3e02c25](https://github.com/lobehub/lobe-chat/commit/3e02c25))
29
+
30
+ </details>
31
+
32
+ <div align="right">
33
+
34
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
35
+
36
+ </div>
37
+
5
38
  ### [Version 1.90.4](https://github.com/lobehub/lobe-chat/compare/v1.90.3...v1.90.4)
6
39
 
7
40
  <sup>Released on **2025-06-02**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "features": [
5
+ "Add more provider support for search & crawl."
6
+ ],
7
+ "improvements": [
8
+ "Update modelscope models."
9
+ ]
10
+ },
11
+ "date": "2025-06-03",
12
+ "version": "1.91.0"
13
+ },
2
14
  {
3
15
  "children": {
4
16
  "improvements": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.90.4",
3
+ "version": "1.91.0",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -0,0 +1,93 @@
1
+ import { CrawlImpl, CrawlSuccessResult } from '../type';
2
+ import { NetworkConnectionError, PageNotFoundError, TimeoutError } from '../utils/errorType';
3
+ import { DEFAULT_TIMEOUT, withTimeout } from '../utils/withTimeout';
4
+
5
+ interface ExaResults {
6
+ author?: string;
7
+ favicon?: string;
8
+ id?: string;
9
+ image?: string;
10
+ publishedDate?: string;
11
+ summary?: string;
12
+ text: string;
13
+ title: string;
14
+ url: string;
15
+ }
16
+
17
+ interface ExaResponse {
18
+ requestId?: string;
19
+ results: ExaResults[];
20
+ }
21
+
22
+ export const exa: CrawlImpl = async (url) => {
23
+ // Get API key from environment variable
24
+ const apiKey = process.env.EXA_API_KEY;
25
+
26
+ let res: Response;
27
+
28
+ try {
29
+ res = await withTimeout(
30
+ fetch('https://api.exa.ai/contents', {
31
+ body: JSON.stringify({
32
+ livecrawl: 'fallback', // always, fallback
33
+ text: true,
34
+ urls: [url],
35
+ }),
36
+ headers: {
37
+ 'Content-Type': 'application/json',
38
+ 'x-api-key': !apiKey ? '' : apiKey,
39
+ },
40
+ method: 'POST',
41
+ }),
42
+ DEFAULT_TIMEOUT,
43
+ );
44
+ } catch (e) {
45
+ const error = e as Error;
46
+ if (error.message === 'fetch failed') {
47
+ throw new NetworkConnectionError();
48
+ }
49
+
50
+ if (error instanceof TimeoutError) {
51
+ throw error;
52
+ }
53
+
54
+ throw e;
55
+ }
56
+
57
+ if (!res.ok) {
58
+ if (res.status === 404) {
59
+ throw new PageNotFoundError(res.statusText);
60
+ }
61
+
62
+ throw new Error(`Exa request failed with status ${res.status}: ${res.statusText}`);
63
+ }
64
+
65
+ try {
66
+ const data = (await res.json()) as ExaResponse;
67
+
68
+ if (!data.results || data.results.length === 0) {
69
+ console.warn( 'Exa API returned no results for URL:', url )
70
+ return
71
+ }
72
+
73
+ const firstResult = data.results[0];
74
+
75
+ // Check if content is empty or too short
76
+ if (!firstResult.text || firstResult.text.length < 100) {
77
+ return;
78
+ }
79
+
80
+ return {
81
+ content: firstResult.text,
82
+ contentType: 'text',
83
+ length: firstResult.text.length,
84
+ siteName: new URL(url).hostname,
85
+ title: firstResult.title,
86
+ url: firstResult.url || url,
87
+ } satisfies CrawlSuccessResult;
88
+ } catch (error) {
89
+ console.error(error);
90
+ }
91
+
92
+ return;
93
+ };
@@ -0,0 +1,97 @@
1
+ import { CrawlImpl, CrawlSuccessResult } from '../type';
2
+ import { NetworkConnectionError, PageNotFoundError, TimeoutError } from '../utils/errorType';
3
+ import { DEFAULT_TIMEOUT, withTimeout } from '../utils/withTimeout';
4
+
5
+ interface FirecrawlMetadata {
6
+ description: string;
7
+ keywords: string;
8
+ language: string;
9
+ ogDescription?: string;
10
+ ogImage?: string;
11
+ ogLocaleAlternate?: string[];
12
+ ogSiteName?: string;
13
+ ogTitle?: string;
14
+ ogUrl?: string;
15
+ robots: string;
16
+ statusCode: number;
17
+ sourceURL: string;
18
+ title: string;
19
+ }
20
+
21
+ interface FirecrawlResults {
22
+ html?: string;
23
+ markdown?: string;
24
+ metadata: FirecrawlMetadata;
25
+ }
26
+
27
+ interface FirecrawlResponse {
28
+ success: boolean;
29
+ data: FirecrawlResults;
30
+ }
31
+
32
+ export const firecrawl: CrawlImpl = async (url) => {
33
+ // Get API key from environment variable
34
+ const apiKey = process.env.FIRECRAWL_API_KEY;
35
+ const baseUrl = process.env.FIRECRAWL_URL || 'https://api.firecrawl.dev/v1';
36
+
37
+ let res: Response;
38
+
39
+ try {
40
+ res = await withTimeout(
41
+ fetch(`${baseUrl}/scrape`, {
42
+ body: JSON.stringify({
43
+ formats: ["markdown"], // ["markdown", "html"]
44
+ url,
45
+ }),
46
+ headers: {
47
+ 'Authorization': !apiKey ? '' : `Bearer ${apiKey}`,
48
+ 'Content-Type': 'application/json',
49
+ },
50
+ method: 'POST',
51
+ }),
52
+ DEFAULT_TIMEOUT,
53
+ );
54
+ } catch (e) {
55
+ const error = e as Error;
56
+ if (error.message === 'fetch failed') {
57
+ throw new NetworkConnectionError();
58
+ }
59
+
60
+ if (error instanceof TimeoutError) {
61
+ throw error;
62
+ }
63
+
64
+ throw e;
65
+ }
66
+
67
+ if (!res.ok) {
68
+ if (res.status === 404) {
69
+ throw new PageNotFoundError(res.statusText);
70
+ }
71
+
72
+ throw new Error(`Firecrawl request failed with status ${res.status}: ${res.statusText}`);
73
+ }
74
+
75
+ try {
76
+ const data = (await res.json()) as FirecrawlResponse;
77
+
78
+ // Check if content is empty or too short
79
+ if (!data.data.markdown || data.data.markdown.length < 100) {
80
+ return;
81
+ }
82
+
83
+ return {
84
+ content: data.data.markdown,
85
+ contentType: 'text',
86
+ description: data.data.metadata.description,
87
+ length: data.data.markdown.length,
88
+ siteName: new URL(url).hostname,
89
+ title: data.data.metadata.title,
90
+ url: url,
91
+ } satisfies CrawlSuccessResult;
92
+ } catch (error) {
93
+ console.error(error);
94
+ }
95
+
96
+ return;
97
+ };
@@ -1,13 +1,19 @@
1
1
  import { browserless } from './browserless';
2
+ import { exa } from './exa';
3
+ import { firecrawl } from './firecrawl';
2
4
  import { jina } from './jina';
3
5
  import { naive } from './naive';
4
6
  import { search1api } from './search1api';
7
+ import { tavily } from './tavily';
5
8
 
6
9
  export const crawlImpls = {
7
10
  browserless,
11
+ exa,
12
+ firecrawl,
8
13
  jina,
9
14
  naive,
10
15
  search1api,
16
+ tavily,
11
17
  };
12
18
 
13
19
  export type CrawlImplType = keyof typeof crawlImpls;
@@ -0,0 +1,94 @@
1
+ import { CrawlImpl, CrawlSuccessResult } from '../type';
2
+ import { NetworkConnectionError, PageNotFoundError, TimeoutError } from '../utils/errorType';
3
+ import { DEFAULT_TIMEOUT, withTimeout } from '../utils/withTimeout';
4
+
5
+ interface TavilyResults {
6
+ images?: string[];
7
+ raw_content: string;
8
+ url: string;
9
+ }
10
+
11
+ interface TavilyFailedResults {
12
+ error?: string;
13
+ url: string;
14
+ }
15
+
16
+ interface TavilyResponse {
17
+ base_url: string;
18
+ failed_results?: TavilyFailedResults[];
19
+ response_time: number;
20
+ results: TavilyResults[];
21
+ }
22
+
23
+ export const tavily: CrawlImpl = async (url) => {
24
+ // Get API key from environment variable
25
+ const apiKey = process.env.TAVILY_API_KEY;
26
+
27
+ let res: Response;
28
+
29
+ try {
30
+ res = await withTimeout(
31
+ fetch('https://api.tavily.com/extract', {
32
+ body: JSON.stringify({
33
+ extract_depth: process.env.TAVILY_EXTRACT_DEPTH || 'basic', // basic or advanced
34
+ include_images: false,
35
+ urls: url,
36
+ }),
37
+ headers: {
38
+ 'Authorization': !apiKey ? '' : `Bearer ${apiKey}`,
39
+ 'Content-Type': 'application/json',
40
+ },
41
+ method: 'POST',
42
+ }),
43
+ DEFAULT_TIMEOUT,
44
+ );
45
+ } catch (e) {
46
+ const error = e as Error;
47
+ if (error.message === 'fetch failed') {
48
+ throw new NetworkConnectionError();
49
+ }
50
+
51
+ if (error instanceof TimeoutError) {
52
+ throw error;
53
+ }
54
+
55
+ throw e;
56
+ }
57
+
58
+ if (!res.ok) {
59
+ if (res.status === 404) {
60
+ throw new PageNotFoundError(res.statusText);
61
+ }
62
+
63
+ throw new Error(`Tavily request failed with status ${res.status}: ${res.statusText}`);
64
+ }
65
+
66
+ try {
67
+ const data = (await res.json()) as TavilyResponse;
68
+
69
+ if (!data.results || data.results.length === 0) {
70
+ console.warn( 'Tavily API returned no results for URL:', url )
71
+ return
72
+ }
73
+
74
+ const firstResult = data.results[0];
75
+
76
+ // Check if content is empty or too short
77
+ if (!firstResult.raw_content || firstResult.raw_content.length < 100) {
78
+ return;
79
+ }
80
+
81
+ return {
82
+ content: firstResult.raw_content,
83
+ contentType: 'text',
84
+ length: firstResult.raw_content.length,
85
+ siteName: new URL(url).hostname,
86
+ title: new URL(url).hostname,
87
+ url: firstResult.url || url,
88
+ } satisfies CrawlSuccessResult;
89
+ } catch (error) {
90
+ console.error(error);
91
+ }
92
+
93
+ return;
94
+ };
@@ -6,10 +6,10 @@ const modelscopeChatModels: AIChatModelCard[] = [
6
6
  functionCall: true,
7
7
  },
8
8
  contextWindowTokens: 131_072,
9
- description: 'DeepSeek-V3是DeepSeek第三代模型,在多项基准测试中表现优异。',
10
- displayName: 'DeepSeek-V3-0324',
9
+ description: 'DeepSeek R1 通过利用增加的计算资源和在后训练过程中引入算法优化机制,显著提高了其推理和推断能力的深度。该模型在各种基准评估中表现出色,包括数学、编程和一般逻辑方面。其整体性能现已接近领先模型,如 O3 和 Gemini 2.5 Pro。',
10
+ displayName: 'DeepSeek-R1-0528',
11
11
  enabled: true,
12
- id: 'deepseek-ai/DeepSeek-V3-0324',
12
+ id: 'deepseek-ai/DeepSeek-R1-0528',
13
13
  type: 'chat',
14
14
  },
15
15
  {
@@ -5,11 +5,11 @@ const ModelScope: ModelProviderCard = {
5
5
  chatModels: [
6
6
  {
7
7
  contextWindowTokens: 131_072,
8
- description: 'DeepSeek-V3是DeepSeek第三代模型,在多项基准测试中表现优异。',
9
- displayName: 'DeepSeek-V3-0324',
8
+ description: 'DeepSeek R1 通过利用增加的计算资源和在后训练过程中引入算法优化机制,显著提高了其推理和推断能力的深度。该模型在各种基准评估中表现出色,包括数学、编程和一般逻辑方面。其整体性能现已接近领先模型,如 O3 和 Gemini 2.5 Pro。',
9
+ displayName: 'DeepSeek-R1-0528',
10
10
  enabled: true,
11
11
  functionCall: true,
12
- id: 'deepseek-ai/DeepSeek-V3-0324',
12
+ id: 'deepseek-ai/DeepSeek-R1-0528',
13
13
  },
14
14
  {
15
15
  contextWindowTokens: 131_072,
@@ -479,5 +479,15 @@
479
479
  "bps": true,
480
480
  "folderMillis": 1746724476380,
481
481
  "hash": "0518cd9882f7ea38eb498b31c8dda73fb56bbc3aa55445ecbc7a9e716631d047"
482
+ },
483
+ {
484
+ "sql": [
485
+ "-- Custom SQL migration file, put your code below! --\nUPDATE agents SET chat_config = jsonb_set(chat_config, '{enableReasoningEffort}', 'false') WHERE chat_config ->> 'enableReasoningEffort' = 'true';\n",
486
+ "\nUPDATE agents SET params = params - 'reasoning_effort' WHERE params ? 'reasoning_effort';\n",
487
+ "\nDELETE FROM ai_providers WHERE id = 'doubao';"
488
+ ],
489
+ "bps": true,
490
+ "folderMillis": 1748925630721,
491
+ "hash": "15815e06e3b188933119f380ae12ef8694f2c5f8003cebb397ed00053a065be4"
482
492
  }
483
493
  ]
@@ -0,0 +1,6 @@
1
+ -- Custom SQL migration file, put your code below! --
2
+ UPDATE agents SET chat_config = jsonb_set(chat_config, '{enableReasoningEffort}', 'false') WHERE chat_config ->> 'enableReasoningEffort' = 'true';
3
+ --> statement-breakpoint
4
+ UPDATE agents SET params = params - 'reasoning_effort' WHERE params ? 'reasoning_effort';
5
+ --> statement-breakpoint
6
+ DELETE FROM ai_providers WHERE id = 'doubao';