@electerm/electerm-react 3.15.121 → 3.15.125

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.
@@ -9,3 +9,114 @@ export const aiConfigsArr = [
9
9
  'languageAI',
10
10
  'proxyAI'
11
11
  ]
12
+
13
+ export const defaultAIPresets = [
14
+ {
15
+ id: 'atlascloud',
16
+ nameAI: 'AtlasCloud',
17
+ baseURLAI: 'https://api.atlascloud.ai/v1',
18
+ apiPathAI: '/chat/completions',
19
+ modelAI: 'deepseek-ai/deepseek-v4-flash',
20
+ authHeaderNameAI: 'Authorization: Bearer'
21
+ },
22
+ {
23
+ id: 'deepseek',
24
+ nameAI: 'DeepSeek',
25
+ baseURLAI: 'https://api.deepseek.com/v1',
26
+ apiPathAI: '/chat/completions',
27
+ modelAI: 'deepseek-chat',
28
+ authHeaderNameAI: 'Authorization: Bearer'
29
+ },
30
+ {
31
+ id: 'openai',
32
+ nameAI: 'OpenAI',
33
+ baseURLAI: 'https://api.openai.com/v1',
34
+ apiPathAI: '/chat/completions',
35
+ modelAI: 'gpt-4o',
36
+ authHeaderNameAI: 'Authorization: Bearer'
37
+ },
38
+ {
39
+ id: 'openrouter',
40
+ nameAI: 'OpenRouter',
41
+ baseURLAI: 'https://openrouter.ai/api/v1',
42
+ apiPathAI: '/chat/completions',
43
+ modelAI: 'openai/gpt-4o-mini',
44
+ authHeaderNameAI: 'Authorization: Bearer'
45
+ },
46
+ {
47
+ id: 'google',
48
+ nameAI: 'Google Gemini',
49
+ baseURLAI: 'https://generativelanguage.googleapis.com/v1beta/openai',
50
+ apiPathAI: '/chat/completions',
51
+ modelAI: 'gemini-2.0-flash',
52
+ authHeaderNameAI: 'Authorization: Bearer'
53
+ },
54
+ {
55
+ id: 'groq',
56
+ nameAI: 'Groq',
57
+ baseURLAI: 'https://api.groq.com/openai/v1',
58
+ apiPathAI: '/chat/completions',
59
+ modelAI: 'llama-3.3-70b-versatile',
60
+ authHeaderNameAI: 'Authorization: Bearer'
61
+ },
62
+ {
63
+ id: 'together',
64
+ nameAI: 'Together AI',
65
+ baseURLAI: 'https://api.together.xyz/v1',
66
+ apiPathAI: '/chat/completions',
67
+ modelAI: 'meta-llama/Llama-3.3-70B-Instruct-Turbo',
68
+ authHeaderNameAI: 'Authorization: Bearer'
69
+ },
70
+ {
71
+ id: 'mistral',
72
+ nameAI: 'Mistral AI',
73
+ baseURLAI: 'https://api.mistral.ai/v1',
74
+ apiPathAI: '/chat/completions',
75
+ modelAI: 'mistral-large-latest',
76
+ authHeaderNameAI: 'Authorization: Bearer'
77
+ },
78
+ {
79
+ id: 'xai',
80
+ nameAI: 'xAI (Grok)',
81
+ baseURLAI: 'https://api.x.ai/v1',
82
+ apiPathAI: '/chat/completions',
83
+ modelAI: 'grok-3-mini',
84
+ authHeaderNameAI: 'Authorization: Bearer'
85
+ },
86
+ {
87
+ id: 'perplexity',
88
+ nameAI: 'Perplexity',
89
+ baseURLAI: 'https://api.perplexity.ai',
90
+ apiPathAI: '/chat/completions',
91
+ modelAI: 'sonar',
92
+ authHeaderNameAI: 'Authorization: Bearer'
93
+ },
94
+ {
95
+ id: 'moonshot',
96
+ nameAI: 'Moonshot (Kimi)',
97
+ baseURLAI: 'https://api.moonshot.cn/v1',
98
+ apiPathAI: '/chat/completions',
99
+ modelAI: 'moonshot-v1-8k',
100
+ authHeaderNameAI: 'Authorization: Bearer'
101
+ },
102
+ {
103
+ id: 'siliconflow',
104
+ nameAI: 'SiliconFlow',
105
+ baseURLAI: 'https://api.siliconflow.cn/v1',
106
+ apiPathAI: '/chat/completions',
107
+ modelAI: 'deepseek-ai/DeepSeek-V3',
108
+ authHeaderNameAI: 'Authorization: Bearer'
109
+ }
110
+ ]
111
+
112
+ export function getAIPresets () {
113
+ const presets = [...defaultAIPresets]
114
+ if (window.et?.defaultAIPreset) {
115
+ presets.unshift({
116
+ ...window.et.defaultAIPreset,
117
+ id: 'default',
118
+ nameAI: window.translate('default')
119
+ })
120
+ }
121
+ return presets
122
+ }
@@ -4,9 +4,11 @@ import {
4
4
  Button,
5
5
  AutoComplete,
6
6
  Alert,
7
- Space
7
+ Space,
8
+ Dropdown
8
9
  } from 'antd'
9
10
  import { useEffect, useState } from 'react'
11
+ import { DownOutlined } from '@ant-design/icons'
10
12
  import Link from '../common/external-link'
11
13
  import AiCache from './ai-cache'
12
14
  import {
@@ -15,6 +17,7 @@ import {
15
17
  import Password from '../common/password'
16
18
  import AiHistory, { addHistoryItem } from './ai-history'
17
19
  import message from '../common/message'
20
+ import { getAIPresets } from './ai-config-props'
18
21
 
19
22
  const STORAGE_KEY_CONFIG = 'ai_config_history'
20
23
  const EVENT_NAME_CONFIG = 'ai-config-history-update'
@@ -101,6 +104,33 @@ export default function AIConfigForm ({ initialValues, onSubmit, showAIConfig })
101
104
  }
102
105
  }
103
106
 
107
+ function handleSelectPreset (preset) {
108
+ const fields = ['nameAI', 'baseURLAI', 'apiPathAI', 'modelAI', 'authHeaderNameAI', 'modelAI', 'apiKeyAI']
109
+ const values = {}
110
+ fields.forEach(f => {
111
+ if (preset[f] !== undefined) {
112
+ values[f] = preset[f]
113
+ }
114
+ })
115
+ form.setFieldsValue(values)
116
+ }
117
+
118
+ function renderPresetMenu () {
119
+ const presets = getAIPresets()
120
+ const items = presets.map(p => ({
121
+ key: p.id,
122
+ label: p.nameAI,
123
+ onClick: () => handleSelectPreset(p)
124
+ }))
125
+ return (
126
+ <Dropdown menu={{ items }} trigger={['click']}>
127
+ <Button>
128
+ {e('presets') || 'Presets'} <DownOutlined />
129
+ </Button>
130
+ </Dropdown>
131
+ )
132
+ }
133
+
104
134
  function renderHistoryItem (item) {
105
135
  if (!item || typeof item !== 'object') return { label: 'Unknown', title: 'Unknown' }
106
136
  const name = item.nameAI || ''
@@ -133,6 +163,9 @@ export default function AIConfigForm ({ initialValues, onSubmit, showAIConfig })
133
163
  type='info'
134
164
  className='mg2y'
135
165
  />
166
+ <div className='mg1b alignright'>
167
+ {renderPresetMenu()}
168
+ </div>
136
169
  <p>
137
170
  Full Url: {initialValues?.baseURLAI}{initialValues?.apiPathAI}
138
171
  </p>
@@ -46,7 +46,10 @@ async function load () {
46
46
  }
47
47
  document.body.appendChild(rcs)
48
48
  }
49
- window.getLang = (lang = window.store?.config.language || 'en_us') => {
49
+ const initLocale = window.pre.runSync('getInitLocale') || {}
50
+ window.langMap = initLocale.langMap
51
+ window.initLanguage = initLocale.language
52
+ window.getLang = (lang = window.store?.config.language || window.initLanguage || 'en_us') => {
50
53
  return _get(window.langMap, `[${lang}].lang`)
51
54
  }
52
55
  window.translate = txt => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "3.15.121",
3
+ "version": "3.15.125",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",