@@ -3,15 +3,18 @@ import { tracked } from "@glimmer/tracking";
3
3
import { Input } from " @ember/component" ;
4
4
import { on } from " @ember/modifier" ;
5
5
import { action } from " @ember/object" ;
6
+ import { LinkTo } from " @ember/routing" ;
6
7
import { later } from " @ember/runloop" ;
7
8
import { inject as service } from " @ember/service" ;
8
9
import BackButton from " discourse/components/back-button" ;
9
10
import DButton from " discourse/components/d-button" ;
10
11
import DToggleSwitch from " discourse/components/d-toggle-switch" ;
12
+ import Avatar from " discourse/helpers/bound-avatar-template" ;
11
13
import { popupAjaxError } from " discourse/lib/ajax-error" ;
12
14
import icon from " discourse-common/helpers/d-icon" ;
13
15
import i18n from " discourse-common/helpers/i18n" ;
14
16
import I18n from " discourse-i18n" ;
17
+ import AdminUser from " admin/models/admin-user" ;
15
18
import ComboBox from " select-kit/components/combo-box" ;
16
19
import DTooltip from " float-kit/components/d-tooltip" ;
17
20
@@ -25,6 +28,7 @@ export default class AiLlmEditor extends Component {
25
28
@tracked testRunning = false ;
26
29
@tracked testResult = null ;
27
30
@tracked testError = null ;
31
+ @tracked apiKeySecret = true ;
28
32
29
33
get selectedProviders () {
30
34
const t = (provName ) => {
@@ -36,6 +40,10 @@ export default class AiLlmEditor extends Component {
36
40
});
37
41
}
38
42
43
+ get adminUser () {
44
+ return AdminUser .create (this .args .model ? .user );
45
+ }
46
+
39
47
@action
40
48
async save () {
41
49
this .isSaving = true ;
@@ -94,6 +102,16 @@ export default class AiLlmEditor extends Component {
94
102
return this .testRunning || this .testResult !== null ;
95
103
}
96
104
105
+ @action
106
+ makeApiKeySecret () {
107
+ this .apiKeySecret = true ;
108
+ }
109
+
110
+ @action
111
+ toggleApiKeySecret () {
112
+ this .apiKeySecret = ! this .apiKeySecret ;
113
+ }
114
+
97
115
@action
98
116
delete () {
99
117
return this .dialog .confirm ({
@@ -177,11 +195,19 @@ export default class AiLlmEditor extends Component {
177
195
{{/if }}
178
196
<div class =" control-group" >
179
197
<label >{{I18n.t " discourse_ai.llms.api_key" }} </label >
180
- <Input
181
- class =" ai-llm-editor-input ai-llm-editor__api-key"
182
- @ type =" text"
183
- @ value ={{@ model.api_key }}
184
- />
198
+ <div class =" ai-llm-editor__secret-api-key-group" >
199
+ <Input
200
+ @ value ={{@ model.api_key }}
201
+ class =" ai-llm-editor-input ai-llm-editor__api-key"
202
+ @ type ={{if this . apiKeySecret " password" " text" }}
203
+ {{on " focusout" this . makeApiKeySecret}}
204
+ />
205
+ <DButton
206
+ @ action ={{this .toggleApiKeySecret }}
207
+ @ icon =" far-eye-slash"
208
+ {{on " focusout" this . makeApiKeySecret}}
209
+ />
210
+ </div >
185
211
</div >
186
212
<div class =" control-group" >
187
213
<label >{{I18n.t " discourse_ai.llms.tokenizer" }} </label >
@@ -213,6 +239,21 @@ export default class AiLlmEditor extends Component {
213
239
{{on " click" this . toggleEnabledChatBot}}
214
240
/>
215
241
</div >
242
+ {{#if @ model.user }}
243
+ <div class =" control-group" >
244
+ <label >{{i18n " discourse_ai.llms.ai_bot_user" }} </label >
245
+ <a
246
+ class =" avatar"
247
+ href ={{@ model.user.path }}
248
+ data-user-card ={{@ model.user.username }}
249
+ >
250
+ {{Avatar @ model.user.avatar_template " small" }}
251
+ </a >
252
+ <LinkTo @ route =" adminUser" @ model ={{this .adminUser }} >
253
+ {{@ model.user.username }}
254
+ </LinkTo >
255
+ </div >
256
+ {{/if }}
216
257
<div class =" control-group ai-llm-editor__action_panel" >
217
258
<DButton
218
259
class =" ai-llm-editor__test"
0 commit comments