Skip to content

Commit e344df8

Browse files
committed
Remove default model assignment from new web configuration
- newly created configuration has model assigned (first on the list), should not.
1 parent e95aa02 commit e344df8

1 file changed

Lines changed: 71 additions & 63 deletions

File tree

‎apps/editor/src/views/actions/create-web-configuration.ts‎

Lines changed: 71 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,72 @@ export const create_web_configuration = async (params: {
1515
let insertion_index: number | undefined
1616

1717
if (params.reference_index !== undefined) {
18-
const position_quick_pick = await new Promise<string | undefined>((resolve) => {
18+
const position_quick_pick = await new Promise<string | undefined>(
19+
(resolve) => {
20+
const quick_pick = vscode.window.createQuickPick()
21+
quick_pick.items = [
22+
{ label: 'Insert a new item above' },
23+
{ label: 'Insert a new item below' }
24+
]
25+
quick_pick.title = 'Placement'
26+
quick_pick.placeholder = 'Where to insert?'
27+
quick_pick.buttons = [
28+
{
29+
iconPath: new vscode.ThemeIcon('close'),
30+
tooltip: 'Close'
31+
}
32+
]
33+
34+
let accepted = false
35+
const disposables: vscode.Disposable[] = []
36+
37+
disposables.push(
38+
quick_pick.onDidTriggerButton(() => {
39+
quick_pick.hide()
40+
}),
41+
quick_pick.onDidAccept(() => {
42+
accepted = true
43+
resolve(quick_pick.selectedItems[0]?.label)
44+
quick_pick.hide()
45+
}),
46+
quick_pick.onDidHide(() => {
47+
if (!accepted) resolve(undefined)
48+
disposables.forEach((d) => d.dispose())
49+
quick_pick.dispose()
50+
})
51+
)
52+
53+
quick_pick.show()
54+
}
55+
)
56+
57+
if (!position_quick_pick) return undefined
58+
59+
insertion_index =
60+
position_quick_pick == 'Insert a new item above'
61+
? params.reference_index
62+
: params.reference_index + 1
63+
} else if (params.placement == 'top') {
64+
insertion_index = 0
65+
}
66+
67+
const selected_chatbot = await new Promise<keyof typeof CHATBOTS | undefined>(
68+
(resolve) => {
69+
const chatbots = Object.entries(CHATBOTS)
70+
const items: vscode.QuickPickItem[] = chatbots.map(
71+
([chatbot, { url }]) => ({
72+
label: chatbot,
73+
description:
74+
chatbot == 'Open WebUI'
75+
? 'localhost'
76+
: url.replace(/^https?:\/\//, '').split('/')[0]
77+
})
78+
)
79+
1980
const quick_pick = vscode.window.createQuickPick()
20-
quick_pick.items = [
21-
{ label: 'Insert a new item above' },
22-
{ label: 'Insert a new item below' }
23-
]
24-
quick_pick.title = 'Placement'
25-
quick_pick.placeholder = 'Where to insert?'
81+
quick_pick.items = items
82+
quick_pick.title = 'Chatbots'
83+
quick_pick.placeholder = 'Choose a chatbot for the new web configuration'
2684
quick_pick.buttons = [
2785
{
2886
iconPath: new vscode.ThemeIcon('close'),
@@ -39,8 +97,10 @@ export const create_web_configuration = async (params: {
3997
}),
4098
quick_pick.onDidAccept(() => {
4199
accepted = true
42-
resolve(quick_pick.selectedItems[0]?.label)
100+
const chatbot = quick_pick.selectedItems[0]
101+
?.label as keyof typeof CHATBOTS
43102
quick_pick.hide()
103+
resolve(chatbot)
44104
}),
45105
quick_pick.onDidHide(() => {
46106
if (!accepted) resolve(undefined)
@@ -50,71 +110,19 @@ export const create_web_configuration = async (params: {
50110
)
51111

52112
quick_pick.show()
53-
})
54-
55-
if (!position_quick_pick) return undefined
56-
57-
insertion_index =
58-
position_quick_pick == 'Insert a new item above'
59-
? params.reference_index
60-
: params.reference_index + 1
61-
} else if (params.placement == 'top') {
62-
insertion_index = 0
63-
}
64-
65-
const selected_chatbot = await new Promise<keyof typeof CHATBOTS | undefined>((resolve) => {
66-
const chatbots = Object.entries(CHATBOTS)
67-
const items: vscode.QuickPickItem[] = chatbots.map(([chatbot, { url }]) => ({
68-
label: chatbot,
69-
description:
70-
chatbot == 'Open WebUI' ? 'localhost' : url.replace(/^https?:\/\//, '').split('/')[0]
71-
}))
72-
73-
const quick_pick = vscode.window.createQuickPick()
74-
quick_pick.items = items
75-
quick_pick.title = 'Chatbots'
76-
quick_pick.placeholder = 'Choose a chatbot for the new web configuration'
77-
quick_pick.buttons = [
78-
{
79-
iconPath: new vscode.ThemeIcon('close'),
80-
tooltip: 'Close'
81-
}
82-
]
83-
84-
let accepted = false
85-
const disposables: vscode.Disposable[] = []
86-
87-
disposables.push(
88-
quick_pick.onDidTriggerButton(() => {
89-
quick_pick.hide()
90-
}),
91-
quick_pick.onDidAccept(() => {
92-
accepted = true
93-
const chatbot = quick_pick.selectedItems[0]?.label as keyof typeof CHATBOTS
94-
quick_pick.hide()
95-
resolve(chatbot)
96-
}),
97-
quick_pick.onDidHide(() => {
98-
if (!accepted) resolve(undefined)
99-
disposables.forEach((d) => d.dispose())
100-
quick_pick.dispose()
101-
})
102-
)
103-
104-
quick_pick.show()
105-
})
113+
}
114+
)
106115

107116
if (!selected_chatbot) return undefined
108117

109118
const new_name = generate_unique_name(
110119
undefined,
111-
current_web_configurations.map(c => c.name)
120+
current_web_configurations.map((c) => c.name)
112121
)
113122

114123
const new_web_configuration: ConfigWebConfigurationFormat = {
115124
name: new_name,
116125
chatbot: selected_chatbot,
117-
model: Object.keys(CHATBOTS[selected_chatbot].models ?? {})[0],
118126
systemInstructions: CHATBOTS[selected_chatbot].supports_system_instructions
119127
? CHATBOTS[selected_chatbot].default_system_instructions
120128
: undefined

0 commit comments

Comments
 (0)