Skip to content

Commit f45b27f

Browse files
committed
feat(settings): Add discover more models button
- Introduced a new SVG icon for redirect functionality. - Updated ModelSelector component to display a button for adding models when none are available, linking to the Ollama search page. - Enhanced the Selector component to allow for additional content at the bottom of the dropdown. - Updated translations for various languages to include new strings related to model selection and discovery. - Added a constant for the Ollama search URL to facilitate navigation.
1 parent 0bd7bc3 commit f45b27f

File tree

19 files changed

+117
-24
lines changed

19 files changed

+117
-24
lines changed

assets/icons/ollama-redirect.svg

Lines changed: 20 additions & 0 deletions
Loading

assets/icons/redirect.svg

Lines changed: 5 additions & 0 deletions
Loading

components/ModelSelector.vue

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@
33
class="flex justify-between items-center gap-3 relative"
44
@click="onClick"
55
>
6+
<a
7+
v-if="modelList.length === 0 && showDiscoverMore"
8+
:href="OLLAMA_SEARCH_URL"
9+
rel="noopener noreferrer"
10+
target="_blank"
11+
>
12+
<Button
13+
variant="secondary"
14+
class="flex justify-between gap-[6px] items-center cursor-pointer text-[13px] font-medium py-0 px-[10px] h-8"
15+
>
16+
<IconOllamaRedirect class="w-4 h-4" />
17+
{{ t('settings.models.add_model_to_start') }}
18+
</Button>
19+
</a>
620
<Selector
21+
v-else
722
v-model="selectedModel"
823
:options="modelOptions"
9-
placeholder="⚠️ No model"
24+
:placeholder="t('settings.models.no_model')"
1025
class="text-xs max-w-full"
1126
:disabled="modelList.length === 0"
1227
dropdownClass="text-xs text-black w-52"
@@ -75,6 +90,27 @@
7590
/>
7691
</div>
7792
</template>
93+
<template
94+
v-if="showDiscoverMore"
95+
#bottom
96+
>
97+
<div class="text-gray-500 text-xs">
98+
<Divider />
99+
<a
100+
:href="OLLAMA_SEARCH_URL"
101+
target="_blank"
102+
rel="noopener noreferrer"
103+
class="h-8 px-3 flex items-center gap-2 cursor-pointer text-black hover:bg-[#EAECEF]"
104+
>
105+
<IconRedirect />
106+
<Text
107+
size="small"
108+
>
109+
{{ t('settings.models.discover_more') }}
110+
</Text>
111+
</a>
112+
</div>
113+
</template>
78114
</Selector>
79115
</div>
80116
</template>
@@ -83,24 +119,33 @@
83119
import { computed, onMounted, toRefs, watch } from 'vue'
84120
85121
import IconDelete from '@/assets/icons/delete.svg?component'
122+
import IconOllamaRedirect from '@/assets/icons/ollama-redirect.svg?component'
123+
import IconRedirect from '@/assets/icons/redirect.svg?component'
86124
import ModelLogo from '@/components/ModelLogo.vue'
87125
import { useOllamaStatusStore } from '@/entrypoints/content/store'
88126
import { deleteOllamaModel } from '@/entrypoints/content/utils/llm'
89127
import { showSettings } from '@/entrypoints/content/utils/settings'
128+
import { OLLAMA_SEARCH_URL } from '@/utils/constants'
90129
import { formatSize } from '@/utils/formatter'
130+
import { useI18n } from '@/utils/i18n'
91131
import { SUPPORTED_MODELS } from '@/utils/llm/web-llm'
92132
import { getUserConfig } from '@/utils/user-config'
93133
import { classNames } from '@/utils/vue/utils'
94134
95135
import Selector from './Selector.vue'
136+
import Button from './ui/Button.vue'
137+
import Divider from './ui/Divider.vue'
138+
import Text from './ui/Text.vue'
96139
97140
defineProps<{
98141
showDetails?: boolean
142+
showDiscoverMore?: boolean
99143
allowDelete?: boolean
100144
dropdownAlign?: 'left' | 'center' | 'right' | 'stretch' | undefined
101145
containerClass?: string
102146
}>()
103147
148+
const { t } = useI18n()
104149
const { modelList: ollamaModelList } = toRefs(useOllamaStatusStore())
105150
const { updateModelList: updateOllamaModelList } = useOllamaStatusStore()
106151

components/Selector.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@
5757
v-if="isOpen"
5858
ref="dropdownRef"
5959
data-nativemind-selector-dropdown
60-
class="absolute overflow-hidden z-10 bg-bg-component rounded-lg shadow-01 p-1"
60+
class="absolute overflow-hidden z-10 bg-bg-component rounded-lg shadow-01"
6161
:style="{ top: `${dropdownPos.y}px`, left: `${dropdownPos.x}px`, width: dropdownPos.width ? `${dropdownPos.width}px` : undefined, zIndex: String(zIndex) }"
6262
:class="dropdownClass"
6363
>
6464
<ScrollContainer
6565
containerClass="h-full max-h-60"
6666
itemContainerClass="h-max"
67-
class="grow overflow-hidden"
67+
class="grow overflow-hidden p-1"
6868
showScrollbar
6969
:arrivalShadow="false"
7070
>
@@ -89,6 +89,9 @@
8989
{{ props.emptyPlaceholder }}
9090
</div>
9191
</ScrollContainer>
92+
<div>
93+
<slot name="bottom" />
94+
</div>
9295
</div>
9396
</Teleport>
9497
</div>

entrypoints/content/components/Settings/index.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,9 @@
167167
type="buttons"
168168
dropdownAlign="left"
169169
showDetails
170+
showDiscoverMore
170171
allowDelete
171172
/>
172-
<a
173-
href="https://ollama.com/search"
174-
class="text-xs text-icon-link hover:underline flex gap-1 items-center"
175-
target="_blank"
176-
>
177-
<!-- <IconOllamaComponent class="h-[13px]" /> -->
178-
{{ t('settings.models.discover_more') }}
179-
</a>
180173
<a
181174
:href="OLLAMA_TUTORIAL_URL"
182175
target="_blank"

locales/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
"get_ollama": "Holen Sie sich Ollama",
8080
"models": {
8181
"title": "Aktives Modell",
82-
"discover_more": "Entdecken Sie weitere Modelle"
82+
"discover_more": "Entdecken Sie weitere Modelle",
83+
"no_model": "⚠️ Kein Modell",
84+
"add_model_to_start": "Fügen Sie ein Modell hinzu, um zu beginnen"
8385
},
8486
"ollama": {
8587
"already_installed": "Haben Sie Ollama bereits installiert und gestartet?",

locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
},
2929
"models": {
3030
"title": "Models",
31-
"discover_more": " Discover more models"
31+
"discover_more": " Discover more models",
32+
"no_model": "⚠️ No model",
33+
"add_model_to_start": "Add a model to start"
3234
},
3335
"quick_actions": {
3436
"title": "Customize Quick Actions",

0 commit comments

Comments
 (0)