diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 456cd5e..4feb2b2 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -166,7 +166,7 @@ pub async fn get_inference( dbg!(&req); // Process the inference; set a wrap for a timeout - let timeout = Duration::from_secs(30); + let timeout = Duration::from_secs(config.request_timeout); let res = match time::timeout(timeout, ollama.generate(req)).await { Ok(result) => result, Err(_) => { diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 3ca8343..8da86c6 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -50,6 +50,7 @@ pub struct TParamIteration { #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "snake_case")] pub struct IDefaultConfigs { + pub request_timeout: u64, pub server_url: String, pub system_prompt: String, pub default_options: HashMap, diff --git a/src/Atoms.ts b/src/Atoms.ts index b30dd1f..35d5712 100644 --- a/src/Atoms.ts +++ b/src/Atoms.ts @@ -28,6 +28,7 @@ const atomWithLocalStorage = (key: string, initialValue: unknown) => { }; const defaultConfigs: IDefaultConfigs = { + request_timeout: 300, server_url: "http://localhost:11434/", system_prompt: "", default_options: { diff --git a/src/Interfaces/index.ts b/src/Interfaces/index.ts index 6e971e7..c472bda 100644 --- a/src/Interfaces/index.ts +++ b/src/Interfaces/index.ts @@ -26,6 +26,7 @@ export type TParamIteration = { // Interface for the default configuration options export interface IDefaultConfigs { + request_timeout: number; server_url: string; system_prompt: string; // default_options: { diff --git a/src/components/settings-dialog.tsx b/src/components/settings-dialog.tsx index e62eb4f..e6fad72 100644 --- a/src/components/settings-dialog.tsx +++ b/src/components/settings-dialog.tsx @@ -39,6 +39,7 @@ export function SettingsDialog() { // * default_options has to be valid JSON const FormSchema = z.object({ + request_timeout: z.coerce.number().min(5), server_url: z.string().url(), system_prompt: z.string(), default_options: z.string().refine( @@ -115,7 +116,7 @@ export function SettingsDialog() { form here */} -
+
+
+ ( + + Request Timeout (secs) + + + + + The timeout in seconds for each inference request. + + + + )} + /> +