Skip to content

Commit

Permalink
fix: creating appAssets folder on first launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Jul 18, 2024
1 parent e953d48 commit c47d387
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions constants/Tokenizer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { copyFileRes } from '@dr.pogodin/react-native-fs'
import { initLlama, LlamaContext } from 'cui-llama.rn'
import { deleteAsync, documentDirectory, getInfoAsync } from 'expo-file-system'
import { deleteAsync, documentDirectory, getInfoAsync, makeDirectoryAsync } from 'expo-file-system'
import { create } from 'zustand'

import { Logger } from './Logger'
Expand All @@ -24,9 +24,13 @@ export namespace Tokenizer {
},
loadModel: async () => {
if (get().model) return
const modelExists = (
await getInfoAsync(`${documentDirectory}appAssets/llama3tokenizer.gguf`)
).exists

const folderDir = `${documentDirectory}appAssets/`
const folderExists = (await getInfoAsync(folderDir)).exists
if (!folderExists) await makeDirectoryAsync(`${documentDirectory}appAssets`)

const modelDir = `${folderDir}llama3tokenizer.gguf`
const modelExists = (await getInfoAsync(modelDir)).exists
if (!modelExists) await importModelFromRes()

const context = await initLlama({
Expand All @@ -47,7 +51,7 @@ export namespace Tokenizer {
}

export const debugDeleteModel = async () => {
await deleteAsync(documentDirectory + 'appAssets/llama3tokenizer.gguf')
await deleteAsync(documentDirectory + 'appAssets')
}
}

Expand Down
2 changes: 1 addition & 1 deletion constants/global.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const initializeApp = async () => {

export const generateDefaultDirectories = async () => {
// Removed: 'characters', 'instruct', 'persona',
const dirs = ['presets', 'lorebooks', 'models', 'appAssets']
const dirs = ['presets', 'lorebooks', 'models']

dirs.map(async (dir: string) => {
await FS.makeDirectoryAsync(`${FS.documentDirectory}${dir}`, {})
Expand Down

0 comments on commit c47d387

Please sign in to comment.