YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
feat: embedded AI on windows & linux with cuda
Louis Beaumont96c7ac71de05
diff --git a/screenpipe-app-tauri/components/chat-message-v2.tsx b/screenpipe-app-tauri/components/chat-message-v2.tsxindex fbd7de99e..4b5f78d98 100644--- a/screenpipe-app-tauri/components/chat-message-v2.tsx+++ b/screenpipe-app-tauri/components/chat-message-v2.tsx@@ -35,11 +35,11 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {>{message.role === "user" ? (<IconUser />- ) : !settings.aiUrl.includes("openai") ||- !settings.aiUrl.includes("worker") ? (- <>🦙</>- ) : (+ ) : settings.aiUrl.includes("openai") ||+ settings.aiUrl.includes("worker") ? (<IconOpenAI />+ ) : (+ <>🦙</>)}</div><div className="flex-1 px-1 ml-4 space-y-2 overflow-hidden w-[96em]">diff --git a/screenpipe-app-tauri/components/screenpipe-status.tsx b/screenpipe-app-tauri/components/screenpipe-status.tsxindex 4e954c61d..f074b003a 100644--- a/screenpipe-app-tauri/components/screenpipe-status.tsx+++ b/screenpipe-app-tauri/components/screenpipe-status.tsx@@ -207,96 +207,137 @@ const HealthStatus = ({ className }: { className?: string }) => {title: "try fixing setup",description: "attempt to automatically fix common setup issues",action: (- <Button- variant="outline"- onClick={handleFixSetup}- disabled={isFixingSetup}- >- <Wrench className="mr-2 h-4 w-4" />- {isFixingSetup ? "fixing..." : "fix setup"}- </Button>+ <div className="flex flex-col items-center">+ <Button+ variant="outline"+ onClick={handleFixSetup}+ disabled={isFixingSetup}+ >+ <Wrench className="mr-2 h-4 w-4" />+ {isFixingSetup ? "fixing..." : "fix setup"}+ </Button>+ <p className="text-xs mt-2 text-gray-500">+ this will download AI models, check permissions, and dependencies+ </p>+ </div>),},{title: "restart screenpipe recording",description: "click stop and start again",action: (- <Button- variant="outline"- onClick={async () => {- const toastId = toast({- title: "stopping screenpipe",- description: "please wait...",- duration: Infinity,- });- try {- await invoke("kill_all_sreenpipes");- await new Promise((resolve) => setTimeout(resolve, 2000));- toastId.update({- id: toastId.id,- title: "screenpipe stopped",- description: "screenpipe is now stopped.",- duration: 3000,- });- } catch (error) {- console.error("failed to stop screenpipe:", error);- toastId.update({- id: toastId.id,- title: "error",- description: "failed to stop screenpipe.",- variant: "destructive",- duration: 3000,+ <div className="flex flex-col items-center">+ <Button+ variant="outline"+ onClick={async () => {+ const toastId = toast({+ title: "restarting screenpipe",+ description: "please wait...",+ duration: Infinity,});- } finally {- toastId.dismiss();- }- }}- >- <RefreshCw className="mr-2 h-4 w-4" />- restart recording- </Button>+ try {+ await invoke("kill_all_sreenpipes");+ await new Promise((resolve) => setTimeout(resolve, 2000));+ toastId.dismiss();+ toastId.update({+ id: toastId.id,+ title: "screenpipe stopped",+ description: "screenpipe is now stopped.",+ duration: 3000,+ });+ await invoke("spawn_screenpipe");++ toastId.dismiss();+ toastId.update({+ id: toastId.id,+ title: "screenpipe started",+ description: "screenpipe is now started.",+ duration: 3000,+ });+ } catch (error) {+ console.error("failed to stop screenpipe:", error);+ toastId.update({+ id: toastId.id,+ title: "error",+ description: "failed to stop screenpipe.",+ variant: "destructive",+ duration: 3000,+ });+ } finally {+ await new Promise((resolve) => setTimeout(resolve, 2000));+ toastId.dismiss();+ }+ }}+ >+ <RefreshCw className="mr-2 h-4 w-4" />+ restart recording+ </Button>+ <p className="text-xs mt-2 text-gray-500">+ this will stop and start the recording process+ </p>+ </div>),},{title: "check permissions",description: "ensure screen and audio recording permissions are granted",action: isMac ? (- <Button variant="outline" onClick={openScreenPermissions}>- <Lock className="mr-2 h-4 w-4" />- open screen permissions- </Button>+ <div className="flex flex-col items-center">+ <Button variant="outline" onClick={openScreenPermissions}>+ <Lock className="mr-2 h-4 w-4" />+ open screen permissions+ </Button>+ <p className="text-xs mt-2 text-gray-500">+ opens system preferences for screen recording+ </p>+ </div>) : null,},{title: "contact support",description: "if the issue persists, reach out to our support team",action: (- <div className="flex flex-col space-y-2 ">+ <div className="flex flex-col space-y-2 items-center"><div className="flex items-center space-x-2 justify-center"><p className="text-sm">please share your logs with support:</p><LogFileButton /></div>- <Button- variant="outline"- onClick={() => open("mailto:[email protected]")}- >- <FileText className="mr-2 h-4 w-4" />- email founders- </Button>- <Button- variant="outline"- onClick={() => open("https://cal.com/louis030195/screenpipe")}- >- <Activity className="mr-2 h-4 w-4" />- book a call w founders- </Button>- <Button- variant="outline"- onClick={() => open("https://discord.gg/dU9EBuw7Uq")}- >- <HelpCircle className="mr-2 h-4 w-4" />- join our discord- </Button>+ <div className="flex flex-col items-center">+ <Button+ variant="outline"+ onClick={() => open("mailto:[email protected]")}+ >+ <FileText className="mr-2 h-4 w-4" />+ email founders+ </Button>+ <p className="text-xs mt-2 text-gray-500">+ we'll respond within 24 hours+ </p>+ </div>+ <div className="flex flex-col items-center">+ <Button+ variant="outline"+ onClick={() => open("https://cal.com/louis030195/screenpipe")}+ >+ <Activity className="mr-2 h-4 w-4" />+ book a call w founders+ </Button>+ <p className="text-xs mt-2 text-gray-500">+ schedule a 15-minute troubleshooting call+ </p>+ </div>+ <div className="flex flex-col items-center">+ <Button+ variant="outline"+ onClick={() => open("https://discord.gg/dU9EBuw7Uq")}+ >+ <HelpCircle className="mr-2 h-4 w-4" />+ join our discord+ </Button>+ <p className="text-xs mt-2 text-gray-500">+ we're more responsive on discord (or the community)+ </p>+ </div></div>),},@@ -349,7 +390,7 @@ const HealthStatus = ({ className }: { className?: string }) => {</Badge><Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}><DialogContent- className="max-w-4xl max-h-[100vh] flex flex-col p-8"+ className="max-w-4xl max-h-[90vh] flex flex-col p-8"aria-describedby="status-dialog-description"><DialogHeader className="flex flex-row items-center justify-between">diff --git a/screenpipe-app-tauri/components/settings.tsx b/screenpipe-app-tauri/components/settings.tsxindex 5c09a120a..65de88588 100644--- a/screenpipe-app-tauri/components/settings.tsx+++ b/screenpipe-app-tauri/components/settings.tsx@@ -11,7 +11,7 @@ import {DialogTrigger,} from "@/components/ui/dialog";import { Button } from "@/components/ui/button";-import { useSettings } from "@/lib/hooks/use-settings";+import { useSettings, AIProviderType } from "@/lib/hooks/use-settings";import {Tooltip,TooltipContent,@@ -54,6 +54,7 @@ import {SelectTrigger,SelectValue,} from "@/components/ui/select";+import { useInterval } from "@/lib/hooks/use-interval";export function Settings({ className }: { className?: string }) {const { settings, updateSettings, resetSetting } = useSettings();@@ -69,6 +70,9 @@ export function Settings({ className }: { className?: string }) {const [currentShortcut, setCurrentShortcut] = useState<string>(settings.showScreenpipeShortcut);+ const [embeddedAIStatus, setEmbeddedAIStatus] = useState<+ "idle" | "running" | "error"+ >("idle");useEffect(() => {setCurrentShortcut(settings.showScreenpipeShortcut);@@ -221,6 +225,7 @@ export function Settings({ className }: { className?: string }) {});setOllamaStatus("running");+ setEmbeddedAIStatus("running");toast({title: "ai ready",description: `${localSettings.embeddedLLM.model} is running.`,@@ -235,6 +240,7 @@ export function Settings({ className }: { className?: string }) {} catch (error) {console.error("Error starting ai sidecar:", error);setOllamaStatus("error");+ setEmbeddedAIStatus("error");toast({title: "error starting ai",description: "check the console for more details",@@ -247,12 +253,14 @@ export function Settings({ className }: { className?: string }) {try {await invoke("stop_ollama_sidecar");setOllamaStatus("idle");+ setEmbeddedAIStatus("idle");toast({title: "ai stopped",description: "the embedded ai has been shut down",});} catch (error) {console.error("error stopping ai:", error);+ setEmbeddedAIStatus("error");toast({title: "error stopping ai",description: "check the console for more details",@@ -261,24 +269,52 @@ export function Settings({ className }: { className?: string }) {}};+ const handleAiProviderChange = (newValue: AIProviderType) => {+ let newUrl = "";+ switch (newValue) {+ case "openai":+ newUrl = "https://api.openai.com/v1";+ break;+ case "native-ollama":+ newUrl = "http://localhost:11434/v1";+ break;+ case "embedded":+ newUrl = `http://localhost:${localSettings.embeddedLLM.port}/v1`;+ break;+ case "screenpipe-cloud":+ newUrl = "https://ai-proxy.i-f9f.workers.dev/v1";+ break;+ case "custom":+ newUrl = localSettings.aiUrl; // Keep the existing custom URL+ break;+ }++ setLocalSettings({+ ...localSettings,+ embeddedLLM: { ...localSettings.embeddedLLM, type: newValue },+ aiUrl: newUrl,+ });+ updateSettings({+ embeddedLLM: { ...localSettings.embeddedLLM, type: newValue },+ aiUrl: newUrl,+ });+ };+const handleAiUrlChange = (newValue: string) => {if (newValue === "custom") {setLocalSettings({ ...localSettings, aiUrl: "" });+ } else if (newValue === "embedded") {+ setLocalSettings({ ...localSettings, aiUrl: "embedded" });} else {setLocalSettings({ ...localSettings, aiUrl: newValue });}updateSettings({ aiUrl: newValue });};- const handleCustomUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {- const newValue = e.target.value;- setLocalSettings({ ...localSettings, aiUrl: newValue });- updateSettings({ aiUrl: newValue });- };-const isApiKeyRequired =localSettings.aiUrl !== "https://ai-proxy.i-f9f.workers.dev/v1" &&- localSettings.aiUrl !== "http://localhost:11434/v1";+ localSettings.aiUrl !== "http://localhost:11434/v1" &&+ localSettings.aiUrl !== "embedded";const getProviderTooltipContent = () => {switch (localSettings.aiUrl) {@@ -334,6 +370,14 @@ export function Settings({ className }: { className?: string }) {</pre></p>);+ case "embedded":+ return (+ <p>+ use the embedded ai provided by screenpipe.+ <br />+ no api key required. model is predefined.+ </p>+ );default:return (<p>@@ -378,6 +422,10 @@ export function Settings({ className }: { className?: string }) {</a></p>);+ case "embedded":+ return (+ <p>the model for embedded ai is predefined and cannot be changed.</p>+ );default:return (<p>enter the model name appropriate for your custom AI provider.</p>@@ -389,13 +437,45 @@ export function Settings({ className }: { className?: string }) {"https://api.openai.com/v1","http://localhost:11434/v1","https://ai-proxy.i-f9f.workers.dev/v1",+ "embedded",].includes(localSettings.aiUrl);const getSelectValue = () => {if (isCustomUrl) return "custom";+ if (localSettings.aiUrl === "embedded" && embeddedAIStatus !== "running") {+ // Fallback to a default option if embedded AI is selected but not running+ return "https://ai-proxy.i-f9f.workers.dev/v1";+ }return localSettings.aiUrl;};+ // Add this function to check the embedded AI status+ const checkEmbeddedAIStatus = useCallback(async () => {+ if (localSettings.embeddedLLM.enabled) {+ try {+ const response = await fetch(+ `http://localhost:${localSettings.embeddedLLM.port}/api/tags`,+ {+ method: "GET",+ }+ );+ if (response.ok) {+ setEmbeddedAIStatus("running");+ } else {+ setEmbeddedAIStatus("error");+ }+ } catch (error) {+ console.error("Error checking embedded AI status:", error);+ setEmbeddedAIStatus("error");+ }+ } else {+ setEmbeddedAIStatus("idle");+ }+ }, [localSettings.embeddedLLM.enabled, localSettings.embeddedLLM.port]);++ // Use the useInterval hook to periodically check the status+ useInterval(checkEmbeddedAIStatus, 10000); // Check every 10 seconds+return (<DialogonOpenChange={(open) => {@@ -438,23 +518,24 @@ export function Settings({ className }: { className?: string }) {</Label><div className="flex-grow flex items-center"><Select- onValueChange={handleAiUrlChange}- value={getSelectValue()}+ onValueChange={handleAiProviderChange}+ value={localSettings.embeddedLLM.type}><SelectTrigger className="w-full"><SelectValue placeholder="Select AI provider" /></SelectTrigger><SelectContent>- <SelectItem value="https://api.openai.com/v1">- openai- </SelectItem>- <SelectItem value="http://localhost:11434/v1">+ <SelectItem value="openai">openai</SelectItem>+ <SelectItem value="native-ollama">ollama (local)</SelectItem>- <SelectItem value="https://ai-proxy.i-f9f.workers.dev/v1">+ <SelectItem value="screenpipe-cloud">screenpipe cloud</SelectItem><SelectItem value="custom">custom</SelectItem>+ {embeddedAIStatus === "running" && (+ <SelectItem value="embedded">embedded ai</SelectItem>+ )}</SelectContent></Select></div>@@ -470,7 +551,7 @@ export function Settings({ className }: { className?: string }) {</TooltipProvider></div></div>- {isCustomUrl && (+ {localSettings.embeddedLLM.type === "custom" && (<div className="w-full"><div className="flex items-center gap-4 mb-4"><Label@@ -482,7 +563,11 @@ export function Settings({ className }: { className?: string }) {<Inputid="customAiUrl"value={localSettings.aiUrl}- onChange={handleCustomUrlChange}+ onChange={(e) => {+ const newUrl = e.target.value;+ setLocalSettings({ ...localSettings, aiUrl: newUrl });+ updateSettings({ aiUrl: newUrl });+ }}className="flex-grow"placeholder="enter custom ai url"autoCorrect="off"@@ -531,39 +616,44 @@ export function Settings({ className }: { className?: string }) {</div></div>)}- <div className="w-full">- <div className="flex items-center gap-4 mb-4">- <Label htmlFor="aiModel" className="min-w-[80px] text-right">- ai model- </Label>- <div className="flex-grow relative">- <Input- id="aiModel"- value={localSettings.aiModel}- onChange={handleModelChange}- className="flex-grow"- placeholder={- localSettings.aiUrl === "http://localhost:11434/v1"- ? "e.g., llama2:7b-chat"- : "e.g., gpt-4"- }- autoCorrect="off"- autoCapitalize="off"- autoComplete="off"- />+ {localSettings.embeddedLLM.type !== "embedded" && (+ <div className="w-full">+ <div className="flex items-center gap-4 mb-4">+ <Label+ htmlFor="aiModel"+ className="min-w-[80px] text-right"+ >+ ai model+ </Label>+ <div className="flex-grow relative">+ <Input+ id="aiModel"+ value={localSettings.aiModel}+ onChange={handleModelChange}+ className="flex-grow"+ placeholder={+ localSettings.embeddedLLM.type === "native-ollama"+ ? "e.g., llama2:7b-chat"+ : "e.g., gpt-4"+ }+ autoCorrect="off"+ autoCapitalize="off"+ autoComplete="off"+ />+ </div>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <HelpCircle className="ml-2 h-4 w-4 cursor-default" />+ </TooltipTrigger>+ <TooltipContent side="left">+ {getModelTooltipContent()}+ </TooltipContent>+ </Tooltip>+ </TooltipProvider></div>- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <HelpCircle className="ml-2 h-4 w-4 cursor-default" />- </TooltipTrigger>- <TooltipContent side="left">- {getModelTooltipContent()}- </TooltipContent>- </Tooltip>- </TooltipProvider></div>- </div>+ )}<div className="w-full"><div className="flex items-center gap-4 mb-4">@@ -658,53 +748,45 @@ export function Settings({ className }: { className?: string }) {local machine or elsewhere and the exact model name.</p>- <Separator className="my-4" />+ <Separator className="my-4" />- <div className="w-full">- <div className="flex items-center gap-4 mb-4">- <div className="flex items-center min-w-[80px] justify-end">- <Label- htmlFor="embeddedLLM"- className="text-right mr-2"- >- embedded ai- </Label>- <Badge variant="outline" className="ml-2">- experimental- </Badge>- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <HelpCircle className="h-4 w-4 cursor-help ml-2" />- </TooltipTrigger>- <TooltipContent- side="right"- className="max-w-[300px]"- >- <p>- enable this to use local ai features in- screenpipe. this is an experimental feature that- may be unstable or change in future updates. you- can use it through search or pipes for enhanced- functionality without relying on external- services.- </p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- </div>- <div className="flex items-center gap-4">- <Switch- id="embeddedLLM"- checked={localSettings.embeddedLLM.enabled}- onCheckedChange={handleEmbeddedLLMChange}- />+ <div className="w-full">+ <div className="flex items-center gap-4 mb-4">+ <div className="flex items-center min-w-[80px] justify-end">+ <Label htmlFor="embeddedLLM" className="text-right mr-2">+ embedded ai+ </Label>+ <Badge variant="outline" className="ml-2">+ experimental+ </Badge>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <HelpCircle className="h-4 w-4 cursor-help ml-2" />+ </TooltipTrigger>+ <TooltipContent side="right" className="max-w-[300px]">+ <p>+ enable this to use local ai features in screenpipe.+ this is an experimental feature that may be unstable+ or change in future updates. you can use it through+ search or pipes for enhanced functionality without+ relying on external services.+ </p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ </div>+ <div className="flex items-center gap-4">+ <Switch+ id="embeddedLLM"+ checked={localSettings.embeddedLLM.enabled}+ onCheckedChange={handleEmbeddedLLMChange}+ />+ {localSettings.embeddedLLM.enabled && (+ <><ButtononClick={startOllamaSidecar}- disabled={- !localSettings.embeddedLLM.enabled ||- ollamaStatus === "running"- }+ disabled={ollamaStatus === "running"}className="ml-auto">{ollamaStatus === "running" ? (@@ -731,69 +813,72 @@ export function Settings({ className }: { className?: string }) {stop ai</Button><LogFileButton />- </div>- </div>+ <Badge>{embeddedAIStatus}</Badge>+ </>+ )}</div>+ </div>+ </div>- {localSettings.embeddedLLM.enabled && (- <>- <div className="w-full">- <div className="flex items-center gap-4 mb-4">- <Label- htmlFor="embeddedLLMModel"- className="min-w-[80px] text-right"- >- llm model- </Label>- <div className="flex-grow flex items-center">- <Input- id="embeddedLLMModel"- value={localSettings.embeddedLLM.model}- onChange={handleEmbeddedLLMModelChange}- className="flex-grow"- placeholder="enter embedded llm model"- />- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <HelpCircle className="ml-2 h-4 w-4 cursor-help" />- </TooltipTrigger>- <TooltipContent- side="right"- className="max-w-[300px]"- >- <p>- supported models are the same as ollama.- check the ollama documentation for a list of- available models.- </p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- </div>- </div>+ {localSettings.embeddedLLM.enabled && (+ <>+ <div className="w-full">+ <div className="flex items-center gap-4 mb-4">+ <Label+ htmlFor="embeddedLLMModel"+ className="min-w-[80px] text-right"+ >+ llm model+ </Label>+ <div className="flex-grow flex items-center">+ <Input+ id="embeddedLLMModel"+ value={localSettings.embeddedLLM.model}+ onChange={handleEmbeddedLLMModelChange}+ className="flex-grow"+ placeholder="enter embedded llm model"+ />+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <HelpCircle className="ml-2 h-4 w-4 cursor-help" />+ </TooltipTrigger>+ <TooltipContent+ side="right"+ className="max-w-[300px]"+ >+ <p>+ supported models are the same as ollama. check+ the ollama documentation for a list of available+ models.+ </p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider></div>+ </div>+ </div>- <div className="w-full">- <div className="flex items-center gap-4 mb-4">- <Label- htmlFor="embeddedLLMPort"- className="min-w-[80px] text-right"- >- llm port- </Label>- <Input- id="embeddedLLMPort"- type="number"- value={localSettings.embeddedLLM.port}- onChange={handleEmbeddedLLMPortChange}- className="flex-grow"- placeholder="enter embedded llm port"- />- </div>- </div>- </>- )}+ <div className="w-full">+ <div className="flex items-center gap-4 mb-4">+ <Label+ htmlFor="embeddedLLMPort"+ className="min-w-[80px] text-right"+ >+ llm port+ </Label>+ <Input+ id="embeddedLLMPort"+ type="number"+ value={localSettings.embeddedLLM.port}+ onChange={handleEmbeddedLLMPortChange}+ className="flex-grow"+ placeholder="enter embedded llm port"+ />+ </div>+ </div>+ </>+ )}</CardContent></Card>diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex 4cad6a0da..5b87b4aa5 100644--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -7,10 +7,19 @@ import posthog from "posthog-js";import { Language } from "@/lib/language";export type VadSensitivity = "low" | "medium" | "high";++export type AIProviderType =+ | "native-ollama"+ | "openai"+ | "custom"+ | "embedded"+ | "screenpipe-cloud";+export type EmbeddedLLMConfig = {enabled: boolean;model: string;port: number;+ type: AIProviderType;};export interface Settings {@@ -265,7 +274,6 @@ export function useSettings() {const savedShowScreenpipeShortcut =(await store!.get<string>("showScreenpipeShortcut")) || "Super+Alt+S";-let savedIsFirstTimeUser = await store!.get<boolean>("isFirstTimeUser");if (savedIsFirstTimeUser === null) {savedIsFirstTimeUser = true;diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 823c823d6..ccffc279d 100644--- a/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.6.7"+version = "0.6.8"description = ""authors = ["you"]license = ""diff --git a/screenpipe-app-tauri/src-tauri/src/llm_sidecar.rs b/screenpipe-app-tauri/src-tauri/src/llm_sidecar.rsindex d0e7087f6..9499b2bc0 100644--- a/screenpipe-app-tauri/src-tauri/src/llm_sidecar.rs+++ b/screenpipe-app-tauri/src-tauri/src/llm_sidecar.rs@@ -1,7 +1,9 @@use anyhow::{anyhow, Result};use serde::{Deserialize, Serialize};+use std::env;use std::time::Duration;use tauri::Emitter;+use tauri::Manager;use tauri_plugin_shell::ShellExt;use tokio::time::sleep;use tracing::{error, info};@@ -36,12 +38,26 @@ impl LLMSidecar {self.status = OllamaStatus::Running;app.emit("ollama_status", &self.status)?;+ // Get the resource directory path+ let resource_path = app.path().resource_dir().unwrap();++ // Append the resource path to CUDA_PATH+ let cuda_path = env::var("CUDA_PATH").unwrap_or_default();+ let new_cuda_path = format!("{}:{}", cuda_path, resource_path.display());+info!("Starting Ollama serve command...");let serve_command = app.shell().sidecar("ollama").unwrap();- let serve_command = serve_command.args(&["serve"]).env(- "OLLAMA_HOST",- &format!("http://localhost:{}", self.settings.port),- );+ let serve_command = serve_command+ .args(&["serve"])+ .env(+ "OLLAMA_HOST",+ &format!("http://localhost:{}", self.settings.port),+ )+ .env("CUDA_PATH", &new_cuda_path);++ #[cfg(target_os = "windows")]+ let serve_command = serve_command.env("OLLAMA_ORIGINS", "*");+let (_, _child) = serve_command.spawn().map_err(|e| {@@ -56,7 +72,13 @@ impl LLMSidecar {// now ollama run the modellet model_command = app.shell().sidecar("ollama").unwrap();- let model_command = model_command.args(&["run", &self.settings.model]);+ let model_command = model_command+ .args(&["run", &self.settings.model])+ .env("CUDA_PATH", &new_cuda_path);++ #[cfg(target_os = "windows")]+ let model_command = model_command.env("OLLAMA_ORIGINS", "*");+let (_, _child) = model_command.spawn().map_err(|e| {diff --git a/screenpipe-app-tauri/src-tauri/src/main.rs b/screenpipe-app-tauri/src-tauri/src/main.rsindex 33220920c..b6004d25c 100755--- a/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/screenpipe-app-tauri/src-tauri/src/main.rs@@ -4,6 +4,7 @@use commands::load_pipe_config;use commands::save_pipe_config;use commands::show_main_window;+use llm_sidecar::EmbeddedLLMSettings;use serde_json::Value;use sidecar::SidecarManager;use std::env;@@ -34,6 +35,7 @@ use uuid::Uuid;mod analytics;use crate::analytics::start_analytics;+use crate::llm_sidecar::LLMSidecar;mod commands;mod llm_sidecar;@@ -365,6 +367,30 @@ async fn main() {#[cfg(target_os = "macos")]app.set_activation_policy(tauri::ActivationPolicy::Regular);+ // LLM Sidecar setup+ let embedded_llm: EmbeddedLLMSettings = store+ .get("embeddedLLM")+ .and_then(|v| serde_json::from_value(v.clone()).ok())+ .unwrap_or_else(|| EmbeddedLLMSettings {+ enabled: false,+ model: "llama3.2:3b-instruct-q4_K_M".to_string(),+ port: 11438,+ });++ if embedded_llm.enabled {+ let app_handle = app.handle().clone();+ tauri::async_runtime::spawn(async move {+ match LLMSidecar::new(embedded_llm).start(app_handle).await {+ Ok(result) => {+ info!("LLM Sidecar started successfully: {}", result);+ }+ Err(e) => {+ error!("Failed to start LLM Sidecar: {}", e);+ }+ }+ });+ }+Ok(())}).build(tauri::generate_context!())