fix: address issues in model pull and chat API
- Refactored model pull logic to improve error handling and user feedback. - Enhanced chat API to ensure better performance and reliability during message fetching. - Updated UI components for a more intuitive user experience when interacting with models and messages.
This commit is contained in:
1 parent
ad9d5d32d2
commit
b2a06ed994
261 files changed
+19968
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
export interface LocalModel {
|
||||
name: string;
|
||||
size: string;
|
||||
id: string;
|
||||
modified_at: string;
|
||||
}
|
||||
|
||||
export function useLocalModels() {
|
||||
const [models, setModels] = useState<LocalModel[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const fetchModels = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const list = await invoke<LocalModel[]>('list_local_models');
|
||||
setModels(list);
|
||||
} catch (error) {
|
||||
console.error("Failed to list models:", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const deleteModel = async (name: string) => {
|
||||
try {
|
||||
await invoke('delete_model', { name });
|
||||
await fetchModels(); // Refresh list
|
||||
} catch (error) {
|
||||
console.error("Failed to delete model:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchModels();
|
||||
}, [fetchModels]);
|
||||
|
||||
return { models, loading, refresh: fetchModels, deleteModel };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user