mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
feat(ui): show fallback notice when using offline model list
This commit is contained in:
parent
a9eec096ce
commit
c04cbd25a8
|
|
@ -249,6 +249,7 @@ class API {
|
||||||
const response = await this.client.get<{
|
const response = await this.client.get<{
|
||||||
models: NomadOllamaModel[]
|
models: NomadOllamaModel[]
|
||||||
hasMore: boolean
|
hasMore: boolean
|
||||||
|
source?: 'api' | 'fallback'
|
||||||
}>('/ollama/models', {
|
}>('/ollama/models', {
|
||||||
params: { sort: 'pulls', ...params },
|
params: { sort: 'pulls', ...params },
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -131,12 +131,20 @@ export default function ModelsPage(props: {
|
||||||
initialData: { models: props.models.availableModels, hasMore: false },
|
initialData: { models: props.models.availableModels, hasMore: false },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isUsingFallback = availableModelData?.source === 'fallback'
|
||||||
|
|
||||||
async function handleForceRefresh() {
|
async function handleForceRefresh() {
|
||||||
forceRefreshRef.current = true
|
forceRefreshRef.current = true
|
||||||
setIsForceRefreshing(true)
|
setIsForceRefreshing(true)
|
||||||
await refetch()
|
const result = await refetch()
|
||||||
setIsForceRefreshing(false)
|
setIsForceRefreshing(false)
|
||||||
addNotification({ message: 'Model list refreshed from remote.', type: 'success' })
|
const refreshSource = result.data?.source
|
||||||
|
addNotification({
|
||||||
|
message: refreshSource === 'fallback'
|
||||||
|
? 'Could not reach model service. Showing offline list.'
|
||||||
|
: 'Model list refreshed from remote.',
|
||||||
|
type: refreshSource === 'fallback' ? 'warning' : 'success',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleInstallModel(modelName: string) {
|
async function handleInstallModel(modelName: string) {
|
||||||
|
|
@ -312,6 +320,11 @@ export default function ModelsPage(props: {
|
||||||
Refresh Models
|
Refresh Models
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
</div>
|
</div>
|
||||||
|
{isUsingFallback && (
|
||||||
|
<Alert variant="info">
|
||||||
|
Showing offline model list. Connect to the internet and refresh for the full catalog.
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
<StyledTable<NomadOllamaModel>
|
<StyledTable<NomadOllamaModel>
|
||||||
className="font-semibold mt-4"
|
className="font-semibold mt-4"
|
||||||
rowLines={true}
|
rowLines={true}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user