@lobehub/chat 0.155.1 → 0.155.3

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,48 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.155.3](https://github.com/lobehub/lobe-chat/compare/v0.155.2...v0.155.3)
6
+
7
+ <sup>Released on **2024-05-08**</sup>
8
+
9
+ #### 💄 Styles
10
+
11
+ - **misc**: Optimized MaxToken Slider.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Styles
19
+
20
+ - **misc**: Optimized MaxToken Slider, closes [#2258](https://github.com/lobehub/lobe-chat/issues/2258) ([dfb892b](https://github.com/lobehub/lobe-chat/commit/dfb892b))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 0.155.2](https://github.com/lobehub/lobe-chat/compare/v0.155.1...v0.155.2)
31
+
32
+ <sup>Released on **2024-05-08**</sup>
33
+
34
+ <br/>
35
+
36
+ <details>
37
+ <summary><kbd>Improvements and Fixes</kbd></summary>
38
+
39
+ </details>
40
+
41
+ <div align="right">
42
+
43
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
44
+
45
+ </div>
46
+
5
47
  ### [Version 0.155.1](https://github.com/lobehub/lobe-chat/compare/v0.155.0...v0.155.1)
6
48
 
7
49
  <sup>Released on **2024-05-07**</sup>
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "تكوين النموذج المخصص",
73
73
  "tokens": {
74
- "title": "أقصى عدد من الرموز"
74
+ "title": "أقصى عدد من الرموز",
75
+ "unlimited": "غير محدود"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "سيتم تمكين قدرة تكوين تحميل الصور فقط في LobeChat من خلال هذا التكوين، مدى دعم التعرف على الصور يعتمد تمامًا على النموذج نفسه، يرجى اختبار قابلية التعرف على الصور لهذا النموذج بنفسك",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Конфигурация на персонализиран модел",
73
73
  "tokens": {
74
- "title": "Максимален брой токени"
74
+ "title": "Максимален брой токени",
75
+ "unlimited": "неограничен"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Тази конфигурация ще активира само възможността за качване на изображения в LobeChat. Възможността за разпознаване на изображения зависи изцяло от самия модел. Моля, тествайте функционалността за разпознаване на изображения на модела.",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Benutzerdefinierte Modellkonfiguration",
73
73
  "tokens": {
74
- "title": "Maximale Token-Anzahl"
74
+ "title": "Maximale Token-Anzahl",
75
+ "unlimited": "unbegrenzt"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Diese Konfiguration aktiviert nur die Bild-Upload-Konfiguration in LobeChat. Die Unterstützung der Erkennung hängt vollständig von dem Modell selbst ab. Bitte testen Sie die Verfügbarkeit der visuellen Erkennungsfähigkeiten des Modells selbst.",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Custom Model Configuration",
73
73
  "tokens": {
74
- "title": "Maximum Token Count"
74
+ "title": "Maximum Token Count",
75
+ "unlimited": "unlimited"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "This configuration will only enable the image upload configuration in LobeChat. Whether recognition is supported depends entirely on the model itself. Please test the availability of visual recognition in this model on your own.",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Configuración del modelo personalizado",
73
73
  "tokens": {
74
- "title": "Número máximo de tokens"
74
+ "title": "Número máximo de tokens",
75
+ "unlimited": "ilimitado"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Esta configuración solo habilitará la configuración de carga de imágenes en LobeChat. La capacidad de reconocimiento depende completamente del modelo en sí. Por favor, realiza pruebas para verificar la disponibilidad de esta capacidad en el modelo.",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Configuration du modèle personnalisé",
73
73
  "tokens": {
74
- "title": "Nombre maximal de jetons"
74
+ "title": "Nombre maximal de jetons",
75
+ "unlimited": "illimité"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Cette configuration activera uniquement la configuration de téléchargement d'images dans LobeChat. La prise en charge de la reconnaissance dépend entièrement du modèle lui-même. Veuillez tester par vous-même la disponibilité de la capacité de reconnaissance visuelle de ce modèle.",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Configurazione del modello personalizzato",
73
73
  "tokens": {
74
- "title": "Numero massimo di token"
74
+ "title": "Numero massimo di token",
75
+ "unlimited": "illimitato"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Questa configurazione abiliterà solo la funzionalità di caricamento delle immagini in LobeChat. La reale capacità di riconoscimento dipende interamente dal modello stesso, si consiglia di testare autonomamente la disponibilità di questa funzionalità nel modello.",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "カスタムモデルの設定",
73
73
  "tokens": {
74
- "title": "最大トークン数"
74
+ "title": "最大トークン数",
75
+ "unlimited": "無制限"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "この設定は LobeChat での画像アップロード構成のみを有効にします。認識のサポートは完全にモデル自体に依存するため、モデルの視覚認識機能の可用性を自己でテストしてください",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "사용자 정의 모델 구성",
73
73
  "tokens": {
74
- "title": "최대 토큰 수"
74
+ "title": "최대 토큰 수",
75
+ "unlimited": "제한 없는"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "이 구성은 LobeChat에서 이미지 업로드 구성만 활성화하며, 인식 지원 여부는 모델 자체에 따라 달라집니다. 모델의 시각 인식 기능을 테스트해보세요",
@@ -58,30 +58,31 @@
58
58
  },
59
59
  "files": {
60
60
  "extra": "Currently, the file upload implementation in LobeChat is just a temporary solution and is for self-exploration only. Please wait for the full file upload capability in the future.",
61
- "title": "Support File Upload"
61
+ "title": "Ondersteuning voor het uploaden van bestanden"
62
62
  },
63
63
  "functionCall": {
64
- "extra": "This configuration will only enable the function call capability in LobeChat. Whether function calls are supported depends entirely on the model itself. Please test the availability of function calls of this model on your own.",
65
- "title": "Support Function Call"
64
+ "extra": "Deze configuratie schakelt alleen de functieaanroepmogelijkheid in LobeChat in. Of functieaanroepen worden ondersteund, hangt volledig af van het model zelf. Test zelf de beschikbaarheid van functieaanroepen van dit model.",
65
+ "title": "Ondersteuningsfunctie Oproep"
66
66
  },
67
67
  "id": {
68
- "extra": "Will be displayed as the model tag",
69
- "placeholder": "Please enter the model ID, for example gpt-4-turbo-preview or claude-2.1",
68
+ "extra": "Wordt weergegeven als de modeltag",
69
+ "placeholder": "Voer de model ID in, bijvoorbeeld gpt-4-turbo-preview of claude-2.1",
70
70
  "title": "Model ID"
71
71
  },
72
- "modalTitle": "Custom Model Configuration",
72
+ "modalTitle": "Aangepaste modelconfiguratie",
73
73
  "tokens": {
74
- "title": "Maximum Token Count"
74
+ "title": "Maximaal tokenaantal",
75
+ "unlimited": "onbeperkt"
75
76
  },
76
77
  "vision": {
77
- "extra": "This configuration will only enable the image upload feature in LobeChat. Whether image recognition is supported depends entirely on the model itself. Please test the availability of visual recognition capability of this model on your own.",
78
- "title": "Support Visual Recognition"
78
+ "extra": "Deze configuratie schakelt alleen de configuratie voor het uploaden van afbeeldingen in LobeChat in. Of herkenning wordt ondersteund, hangt volledig af van het model zelf. Test zelf de beschikbaarheid van visuele herkenning in dit model.",
79
+ "title": "Ondersteuning van visuele herkenning"
79
80
  }
80
81
  }
81
82
  },
82
83
  "fetchOnClient": {
83
- "desc": "使用客户端请求模式将直接从浏览器发起会话请求,可提升响应速度",
84
- "title": "使用客户端请求模式"
84
+ "desc": "De ophaalmodus aan de clientzijde initieert sessieverzoeken rechtstreeks vanuit de browser, waardoor de reactiesnelheid wordt verbeterd.",
85
+ "title": "Gebruik de ophaalmodus aan de clientzijde"
85
86
  },
86
87
  "fetcher": {
87
88
  "fetch": "Haal model lijst op",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Konfiguracja niestandardowego modelu",
73
73
  "tokens": {
74
- "title": "Maksymalna liczba tokenów"
74
+ "title": "Maksymalna liczba tokenów",
75
+ "unlimited": "Nieograniczony"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Ta konfiguracja aktywuje tylko możliwość przesyłania obrazów w LobeChat. Możliwość rozpoznawania zależy wyłącznie od modelu. Proszę przetestować dostępność rozpoznawania wizyjnego tego modelu",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Configuração de Modelo Personalizado",
73
73
  "tokens": {
74
- "title": "Número Máximo de Tokens"
74
+ "title": "Número Máximo de Tokens",
75
+ "unlimited": "ilimitado"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Esta configuração ativará apenas a configuração de upload de imagens no LobeChat. A capacidade de reconhecimento depende inteiramente do modelo em si. Por favor, teste a disponibilidade da capacidade de reconhecimento visual deste modelo.",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Настройка пользовательской модели",
73
73
  "tokens": {
74
- "title": "Максимальное количество токенов"
74
+ "title": "Максимальное количество токенов",
75
+ "unlimited": "неограниченный"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Эта настройка активирует только конфигурацию загрузки изображений в LobeChat. Поддержка распознавания полностью зависит от самой модели, пожалуйста, протестируйте доступность распознавания изображений этой модели самостоятельно",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Özel Model Yapılandırması",
73
73
  "tokens": {
74
- "title": "Maksimum token sayısı"
74
+ "title": "Maksimum token sayısı",
75
+ "unlimited": "Sınırsız"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Bu yapılandırma yalnızca LobeChat'teki görüntü yükleme yapılandırmasını etkinleştirir, tanıma desteğinin olup olmadığı tamamen modelin kendisine bağlıdır, bu modelin görüntü tanıma yeteneğini test etmek size kalmıştır",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "Cấu hình mô hình tùy chỉnh",
73
73
  "tokens": {
74
- "title": "Số lượng token tối đa"
74
+ "title": "Số lượng token tối đa",
75
+ "unlimited": "vô hạn"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "Cấu hình này chỉ mở khả năng tải lên hình ảnh trong LobeChat, việc hỗ trợ nhận diện hoàn toàn phụ thuộc vào mô hình chính mình, hãy tự kiểm tra tính khả dụng của khả năng nhận diện hình ảnh của mô hình",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "自定义模型配置",
73
73
  "tokens": {
74
- "title": "最大 token 数"
74
+ "title": "最大 token 数",
75
+ "unlimited": "无限制"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "此配置将仅开启 LobeChat 中的图片上传配置,是否支持识别完全取决于模型本身,请自行测试该模型的视觉识别能力可用性",
@@ -71,7 +71,8 @@
71
71
  },
72
72
  "modalTitle": "自定義模型配置",
73
73
  "tokens": {
74
- "title": "最大 token 數"
74
+ "title": "最大 token 數",
75
+ "unlimited": "無限制"
75
76
  },
76
77
  "vision": {
77
78
  "extra": "此配置將僅開啟 LobeChat 中的圖片上傳配置,是否支持識別完全取決於模型本身,請自行測試該模型的視覺識別能力可用性",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.155.1",
3
+ "version": "0.155.3",
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",
@@ -1,23 +1,17 @@
1
- import { InputNumber, Slider, SliderSingleProps } from 'antd';
2
- import { memo } from 'react';
1
+ import { InputNumber, Slider } from 'antd';
2
+ import { memo, useMemo } from 'react';
3
+ import { useTranslation } from 'react-i18next';
3
4
  import { Flexbox } from 'react-layout-kit';
4
5
  import useMergeState from 'use-merge-value';
5
6
 
7
+ import { useServerConfigStore } from '@/store/serverConfig';
8
+ import { serverConfigSelectors } from '@/store/serverConfig/selectors';
9
+
10
+ const Kibi = 1024;
11
+
6
12
  const exponent = (num: number) => Math.log2(num);
7
13
  const getRealValue = (num: number) => Math.round(Math.pow(2, num));
8
-
9
- const marks: SliderSingleProps['marks'] = {
10
- [exponent(1)]: '1k',
11
- [exponent(2)]: '2k',
12
- [exponent(4)]: '4k',
13
- [exponent(8)]: '8k',
14
- [exponent(16)]: '16k',
15
- [exponent(32)]: '32k',
16
- [exponent(64)]: '64k',
17
- [exponent(128)]: '128k',
18
- [exponent(200)]: '200k',
19
- [exponent(1000)]: '1M',
20
- };
14
+ const powerKibi = (num: number) => Math.round(Math.pow(2, num) * Kibi);
21
15
 
22
16
  interface MaxTokenSliderProps {
23
17
  defaultValue?: number;
@@ -26,6 +20,8 @@ interface MaxTokenSliderProps {
26
20
  }
27
21
 
28
22
  const MaxTokenSlider = memo<MaxTokenSliderProps>(({ value, onChange, defaultValue }) => {
23
+ const { t } = useTranslation('setting');
24
+
29
25
  const [token, setTokens] = useMergeState(0, {
30
26
  defaultValue,
31
27
  onChange,
@@ -33,39 +29,57 @@ const MaxTokenSlider = memo<MaxTokenSliderProps>(({ value, onChange, defaultValu
33
29
  });
34
30
 
35
31
  const [powValue, setPowValue] = useMergeState(0, {
36
- defaultValue: exponent(typeof defaultValue === 'undefined' ? 0 : defaultValue / 1000),
37
- value: exponent(typeof value === 'undefined' ? 0 : value / 1000),
32
+ defaultValue: exponent(typeof defaultValue === 'undefined' ? 0 : defaultValue / 1024),
33
+ value: exponent(typeof value === 'undefined' ? 0 : value / Kibi),
38
34
  });
39
35
 
40
36
  const updateWithPowValue = (value: number) => {
41
37
  setPowValue(value);
42
38
 
43
- setTokens(getRealValue(value) * 1024);
39
+ setTokens(getRealValue(value) === 1 ? 0 : powerKibi(value));
44
40
  };
41
+
45
42
  const updateWithRealValue = (value: number) => {
46
- setTokens(value);
43
+ setTokens(Math.round(value));
47
44
 
48
- setPowValue(exponent(value / 1024));
45
+ setPowValue(exponent(value / Kibi));
49
46
  };
50
47
 
48
+ const isMobile = useServerConfigStore(serverConfigSelectors.isMobile);
49
+
50
+ const marks = useMemo(() => {
51
+ return {
52
+ [exponent(1)]: '0',
53
+ [exponent(2)]: isMobile ? '2' : '2K', // 2 Kibi = 2048
54
+ [exponent(4)]: isMobile ? '4' : '4K',
55
+ [exponent(8)]: isMobile ? '8' : '8K',
56
+ [exponent(16)]: isMobile ? '16' : '16K',
57
+ [exponent(32)]: isMobile ? '32' : '32K',
58
+ [exponent(64)]: isMobile ? '64' : '64K',
59
+ [exponent((128 / Kibi) * 1000)]: ' ', // hide tick mark
60
+ [exponent((200 / Kibi) * 1000)]: isMobile ? '200' : '200k', // 200,000
61
+ [exponent(Kibi)]: isMobile ? '1024' : '1M',
62
+ };
63
+ }, [isMobile]);
64
+
51
65
  return (
52
66
  <Flexbox align={'center'} gap={12} horizontal>
53
67
  <Flexbox flex={1}>
54
68
  <Slider
55
69
  marks={marks}
56
- max={exponent(1000)}
70
+ max={exponent(Kibi)}
57
71
  min={0}
58
72
  onChange={updateWithPowValue}
59
- step={1}
73
+ step={null}
60
74
  tooltip={{
61
75
  formatter: (x) => {
62
76
  if (typeof x === 'undefined') return;
77
+ if (x === 0) return t('llm.customModelCards.modelConfig.tokens.unlimited');
63
78
 
64
- const value = getRealValue(x);
65
-
66
- if (value < 1000) return value.toFixed(0) + 'K';
67
-
68
- return (value / 1000).toFixed(0) + 'M';
79
+ let value = getRealValue(x);
80
+ if (value < 125) return value.toFixed(0) + 'K';
81
+ else if (value < Kibi) return ((value * Kibi) / 1000).toFixed(0) + 'k';
82
+ return (value / Kibi).toFixed(0) + 'M';
69
83
  },
70
84
  }}
71
85
  value={powValue}
@@ -73,12 +87,13 @@ const MaxTokenSlider = memo<MaxTokenSliderProps>(({ value, onChange, defaultValu
73
87
  </Flexbox>
74
88
  <div>
75
89
  <InputNumber
90
+ min={0}
76
91
  onChange={(e) => {
77
- if (!e) return;
92
+ if (!e && e !== 0) return;
78
93
 
79
94
  updateWithRealValue(e);
80
95
  }}
81
- step={1024}
96
+ step={2 * Kibi}
82
97
  value={token}
83
98
  />
84
99
  </div>
@@ -1,6 +1,6 @@
1
1
  import { Icon, Tooltip } from '@lobehub/ui';
2
2
  import { createStyles } from 'antd-style';
3
- import { LucideEye, LucidePaperclip, ToyBrick } from 'lucide-react';
3
+ import { Infinity, LucideEye, LucidePaperclip, ToyBrick } from 'lucide-react';
4
4
  import numeral from 'numeral';
5
5
  import { rgba } from 'polished';
6
6
  import { memo } from 'react';
@@ -57,10 +57,14 @@ const useStyles = createStyles(({ css, token }) => ({
57
57
  `,
58
58
  }));
59
59
  const formatTokenNumber = (num: number): string => {
60
- if (num < 1000) return '1K';
61
- const kiloToken = Math.floor(num / 1000);
60
+ if (num > 0 && num < 1024) return '1K';
61
+
62
+ let kiloToken = Math.floor(num / 1024);
63
+ if (num >= 128_000 && num < 1_024_000) {
64
+ kiloToken = Math.floor(num / 1000);
65
+ }
62
66
  return kiloToken < 1000 ? `${kiloToken}K` : `${Math.floor(kiloToken / 1000)}M`;
63
- }
67
+ };
64
68
 
65
69
  interface ModelInfoTagsProps extends ChatModelCard {
66
70
  directionReverse?: boolean;
@@ -83,7 +87,7 @@ export const ModelInfoTags = memo<ModelInfoTagsProps>(
83
87
  )}
84
88
  {model.vision && (
85
89
  <Tooltip placement={placement} title={t('ModelSelect.featureTag.vision')}>
86
- <div className={cx(styles.tag, styles.tagGreen)}>
90
+ <div className={cx(styles.tag, styles.tagGreen)} style={{ cursor: 'pointer' }} title="">
87
91
  <Icon icon={LucideEye} />
88
92
  </div>
89
93
  </Tooltip>
@@ -94,20 +98,26 @@ export const ModelInfoTags = memo<ModelInfoTagsProps>(
94
98
  placement={placement}
95
99
  title={t('ModelSelect.featureTag.functionCall')}
96
100
  >
97
- <div className={cx(styles.tag, styles.tagBlue)}>
101
+ <div className={cx(styles.tag, styles.tagBlue)} style={{ cursor: 'pointer' }} title="">
98
102
  <Icon icon={ToyBrick} />
99
103
  </div>
100
104
  </Tooltip>
101
105
  )}
102
- {model.tokens && (
106
+ {model.tokens !== undefined && (
103
107
  <Tooltip
104
108
  overlayStyle={{ maxWidth: 'unset' }}
105
109
  placement={placement}
106
110
  title={t('ModelSelect.featureTag.tokens', {
107
- tokens: numeral(model.tokens).format('0,0'),
111
+ tokens: model.tokens === 0 ? '∞' : numeral(model.tokens).format('0,0'),
108
112
  })}
109
113
  >
110
- <Center className={styles.token}>{formatTokenNumber(model.tokens)}</Center>
114
+ <Center className={styles.token} title="">
115
+ {model.tokens === 0 ? (
116
+ <Infinity size={17} strokeWidth={1.6} />
117
+ ) : (
118
+ formatTokenNumber(model.tokens)
119
+ )}
120
+ </Center>
111
121
  </Tooltip>
112
122
  )}
113
123
  {/*{model.isCustom && (*/}
@@ -106,7 +106,7 @@ export class BaseModel<N extends keyof BrowserDBSchema = any, T = BrowserDBSchem
106
106
 
107
107
  // skip if the id already exists
108
108
  if (await this.table.get(id)) {
109
- skips.push(id);
109
+ skips.push(id as string);
110
110
  continue;
111
111
  }
112
112
 
@@ -72,7 +72,10 @@ export default {
72
72
  title: '模型 ID',
73
73
  },
74
74
  modalTitle: '自定义模型配置',
75
- tokens: { title: '最大 token 数' },
75
+ tokens: {
76
+ title: '最大 token 数',
77
+ unlimited: '无限制',
78
+ },
76
79
  vision: {
77
80
  extra:
78
81
  '此配置将仅开启 LobeChat 中的图片上传配置,是否支持识别完全取决于模型本身,请自行测试该模型的视觉识别能力可用性',