Update import statements, set TTSEnabled in TTSModeSettings, and fix fetchChatModels error handling
This commit is contained in:
@@ -113,11 +113,18 @@ export const deleteModel = async (model: string) => {
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export const fetchChatModels = async () => {
|
||||
export const fetchChatModels = async ({
|
||||
returnEmpty = false
|
||||
}: {
|
||||
returnEmpty?: boolean
|
||||
}) => {
|
||||
try {
|
||||
const baseUrl = await getOllamaURL()
|
||||
const response = await fetch(`${cleanUrl(baseUrl)}/api/tags`)
|
||||
if (!response.ok) {
|
||||
if (returnEmpty) {
|
||||
return []
|
||||
}
|
||||
throw new Error(response.statusText)
|
||||
}
|
||||
const json = await response.json()
|
||||
@@ -127,8 +134,8 @@ export const fetchChatModels = async () => {
|
||||
modified_at: string
|
||||
size: number
|
||||
digest: string
|
||||
details: {
|
||||
parent_model: string
|
||||
details?: {
|
||||
parent_model?: string
|
||||
format: string
|
||||
family: string
|
||||
families: string[]
|
||||
@@ -136,7 +143,7 @@ export const fetchChatModels = async () => {
|
||||
quantization_level: string
|
||||
}
|
||||
}[]
|
||||
return models.filter((model) => {
|
||||
return models?.filter((model) => {
|
||||
return (
|
||||
!model?.details?.families?.includes("bert") &&
|
||||
!model?.details?.families?.includes("nomic-bert")
|
||||
@@ -144,7 +151,7 @@ export const fetchChatModels = async () => {
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return []
|
||||
return await getAllModels({ returnEmpty })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ export const setVoice = async (voice: string) => {
|
||||
|
||||
export const isTTSEnabled = async () => {
|
||||
const data = await storage.get("isTTSEnabled")
|
||||
if(!data || data.length === 0) {
|
||||
return true
|
||||
}
|
||||
return data === "true"
|
||||
}
|
||||
|
||||
@@ -45,6 +48,9 @@ export const setTTSEnabled = async (isTTSEnabled: boolean) => {
|
||||
|
||||
export const isSSMLEnabled = async () => {
|
||||
const data = await storage.get("isSSMLEnabled")
|
||||
if(!data || data.length === 0) {
|
||||
return true
|
||||
}
|
||||
return data === "true"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user