Skip to content

Commit

Permalink
fix: unable to load internal models, improved loading routine
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Oct 10, 2024
1 parent 67206c1 commit 8dd5f58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/constants/Characters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ export namespace Characters {

const greetingdata =
typeof data?.alternate_greetings === 'object'
? data?.alternate_greetings?.map((item) => ({
? (data?.alternate_greetings?.map((item) => ({
character_id: id,
greeting: item,
})) ?? []
})) ?? [])
: []
if (greetingdata.length > 0)
for (const greeting of greetingdata)
Expand Down
20 changes: 7 additions & 13 deletions app/constants/LlamaLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,11 @@ export namespace Llama {
if (!presetString) return
const preset: LlamaPreset = JSON.parse(presetString)

if (!modelName) {
Logger.log('Invalid File Name', true)
return
}

switch (modelName) {
case '':
return Logger.log('No Model Chosen', true)
case get().modelName:
return Logger.log('Model Already Loaded!', true)
if (get().modelId === modelId) {
return Logger.log('Model Already Loaded!', true)
}

if (!filePath.startsWith('content') && !(await modelExists(modelName))) {
if (!(await FS.getInfoAsync(filePath)).exists) {
Logger.log('Model Does Not Exist!', true)
return
}
Expand Down Expand Up @@ -450,16 +442,18 @@ export namespace Llama {
}

export const verifyModelList = async () => {
const modelList = await db.query.model_data.findMany()
let modelList = await db.query.model_data.findMany()
const fileList = await getModelList()

// cull missing models
modelList.forEach(async (item) => {
if (!(await FS.getInfoAsync(item.file_path)).exists) {
if (item.name === '' || !(await FS.getInfoAsync(item.file_path)).exists) {
Logger.log(`Model Missing, its entry will be deleted: ${item.name}`)
await db.delete(model_data).where(eq(model_data.id, item.id))
}
})
// refresh as some may have been deleted
modelList = await db.query.model_data.findMany()

// create data as migration step
fileList.forEach(async (item) => {
Expand Down

0 comments on commit 8dd5f58

Please sign in to comment.