Skip to content

Commit

Permalink
fix: remove model also remove yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Jun 5, 2024
1 parent f7284c5 commit 2adee26
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ export class ModelsCliUsecases {
* @param modelId
*/
async pullModel(modelId: string) {
if (await this.modelsUsecases.findOne(modelId)) {
console.error('Model already exists');
process.exit(1);
}

if (modelId.includes('/') || modelId.includes(':')) {
await this.pullHuggingFaceModel(modelId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const normalizeModelId = (modelId: string): string => {
return modelId.replace(':', '-');
return modelId.replace(':', '-').replace('/', '-');
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FileManagerService } from '@/file-manager/file-manager.service';

@Injectable()
export default class CortexProvider extends OAIEngineExtension {
provider: string = 'cortex';
provider: string = 'cortex.llamacpp';
apiUrl = `http://${defaultCortexCppHost}:${defaultCortexCppPort}/inferences/server/chat_completion`;

private loadModelUrl = `http://${defaultCortexCppHost}:${defaultCortexCppPort}/inferences/server/loadmodel`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
mkdirSync,
readFileSync,
readdirSync,
rmSync,
writeFileSync,
} from 'fs';
import { load, dump } from 'js-yaml';
Expand Down Expand Up @@ -103,8 +104,13 @@ export class ModelRepositoryImpl implements ModelRepository {
* This would remove the model yaml file from the models folder
* @param id model id
*/
remove(id: string): Promise<void> {
async remove(id: string): Promise<void> {
this.models.delete(id);
const yamlFilePath = join(
await this.fileService.getModelsPath(),
this.fileModel.get(id) ?? id,
);
if (existsSync(yamlFilePath)) rmSync(yamlFilePath);
return Promise.resolve();
}

Expand Down

0 comments on commit 2adee26

Please sign in to comment.