* feat: Introduce structured error handling for llamacpp extension This commit introduces a structured error handling system for the `llamacpp` extension. Instead of returning simple string errors, we now use a custom `LlamacppError` struct with a specific `ErrorCode` enum. This allows the frontend to display more user-friendly and actionable error messages based on the code, rather than raw debug logs. The changes include: - A new `ErrorCode` enum to categorize errors (e.g., `OutOfMemory`, `ModelArchNotSupported`, `BinaryNotFound`). - A `LlamacppError` struct to encapsulate the code, a user-facing message, and optional detailed logs. - A static method `from_stderr` that intelligently parses llama.cpp's standard error output to identify and map common issues like Out of Memory errors to a specific error code. - Refactored `ServerError` enum to wrap the new `LlamacppError` and provide a consistent serialization format for the Tauri frontend. - Updated all relevant functions (`load_llama_model`, `get_devices`) to return the new structured error type, ensuring a more robust and predictable error flow. - A reduced timeout for model loading from 300 to 180 seconds. This work lays the groundwork for a more intuitive and helpful user experience, as the application can now provide clear guidance to users when a model fails to load. * Update src-tauri/src/core/utils/extensions/inference_llamacpp_extension/server.rs Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Update src-tauri/src/core/utils/extensions/inference_llamacpp_extension/server.rs Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * chore: update FE handle error object from extension * chore: fix property type --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Faisal Amir <urmauur@gmail.com>
12 lines
334 B
TypeScript
12 lines
334 B
TypeScript
import { create } from 'zustand'
|
|
|
|
type ModelLoadState = {
|
|
modelLoadError?: string | ErrorObject
|
|
setModelLoadError: (error: string | ErrorObject | undefined) => void
|
|
}
|
|
|
|
export const useModelLoad = create<ModelLoadState>()((set) => ({
|
|
modelLoadError: undefined,
|
|
setModelLoadError: (error) => set({ modelLoadError: error }),
|
|
}))
|