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
fix: ollama
Louis Beaumonta25806b377d8
diff --git a/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsx b/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsxindex 511afc303..5a8718e9b 100644--- a/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsx+++ b/examples/apps/screenpipe-app-tauri/components/chat-list-openai-v2.tsx@@ -28,6 +28,8 @@ import { useScrollAnchor } from "@/lib/hooks/use-scroll-anchor";import { FunctionCallMessage } from "./function-call-message";import { EmptyScreen } from "./empty-screen";import { IconOllama } from "./ui/icons";+import { useSettings } from "@/lib/hooks/use-settings";+const screenpipeQuery = z.object({q: z@@ -37,6 +39,7 @@ const screenpipeQuery = z.object({),contentType: z.enum(["ocr", "audio", "all"])+ .default("all").describe("The type of content to search for: screenshot data or audio transcriptions"),@@ -172,22 +175,23 @@ export function ChatList({- Very important: your output will be given to another LLM so make sure not to return too much data (typically each row returns lot of data)- Use between 2-5 queries with very different keywords that could maximally match the user's screen text or audio transcript- Use "all" for querying the same keyword over vision and audio+ - Keep in mind, use "q", "offset", "limit", "start_date", "end_date", and "content_type" as keys in your JSON object. q is optional.Example answers from you:"{"queries": [- {"q": "goal", "offset": 0, "limit": 10, "start_date": "2024-07-21T11:30:25Z", "end_date": "2024-07-21T11:35:25Z"},- {"q": "stripe", "offset": 0, "limit": 50, "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"},- {"q": "customer", "offset": 0, "limit": 20, "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"}+ {"q": "goal", "offset": 0, "limit": 10, "content_type": "all", "start_date": "2024-07-21T11:30:25Z", "end_date": "2024-07-21T11:35:25Z"},+ {"q": "stripe", "offset": 0, "limit": 50, "content_type": "ocr", "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"},+ {"q": "customer", "offset": 0, "limit": 20, "content_type": "audio", "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"}]}"or"{"queries": [- {"q": "sales", "offset": 0, "limit": 10, "start_date": "2024-07-21T11:30:25Z", "end_date": "2024-07-21T11:35:25Z"},- {"q": "customer", "offset": 0, "limit": 20, "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"},- {"q": "goal", "offset": 0, "limit": 10, "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"}+ {"q": "sales", "offset": 0, "limit": 10, "content_type": "all", "start_date": "2024-07-21T11:30:25Z", "end_date": "2024-07-21T11:35:25Z"},+ {"q": "customer", "offset": 0, "limit": 20, "content_type": "all", "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"},+ {"q": "goal", "offset": 0, "limit": 10, "content_type": "all", "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z"}]}"@@ -217,25 +221,50 @@ export function ChatList({// console.log("toolCalls", text.toolCalls);// console.log("toolResults", text.toolResults);- const { textStream } = await streamText({- model: provider("gpt-4o"),- messages: [- {- role: "user",- content:- messages.findLast((msg) => msg.role === "user")?.content ||- inputMessage,- },- {- role: "assistant",- content: text.toolCalls,- },- {- role: "tool",- content: text.toolResults,- },- ],- });+ const { textStream } = ollama+ ? await streamText({+ model: ollama(model),+ prompt: JSON.stringify([+ {+ role: "user",+ content:+ messages.findLast((msg) => msg.role === "user")?.content ||+ inputMessage,+ },+ {+ role: "assistant",+ content: text.toolCalls,+ },+ {+ role: "tool",+ content: text.toolResults,+ },+ // just a hack because ollama is drunk+ {+ role: "user",+ content: "MAKE SURE TO ANSWER THE USER QUESTION ROLE 'USER'",+ },+ ]),+ })+ : await streamText({+ model: provider(model),+ messages: [+ {+ role: "user",+ content:+ messages.findLast((msg) => msg.role === "user")?.content ||+ inputMessage,+ },+ {+ role: "assistant",+ content: text.toolCalls,+ },+ {+ role: "tool",+ content: text.toolResults,+ },+ ],+ });// console.log("textStream", textStream);@@ -360,10 +389,11 @@ export function ChatList({}export function SpinnerMessage() {+ const { settings } = useSettings();return (<div className="group relative flex items-start md:-ml-12"><div className="flex size-[24px] shrink-0 select-none items-center justify-center rounded-md border bg-primary text-primary-foreground shadow-sm">- <IconOpenAI />+ {settings.useOllama ? <>🦙</> : <IconOpenAI />}</div><div className="ml-4 h-[24px] flex flex-row items-center flex-1 space-y-2 overflow-hidden px-1">{spinner}diff --git a/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsx b/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsxindex 82230857c..65fc99c4a 100644--- a/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsx+++ b/examples/apps/screenpipe-app-tauri/components/chat-message-v2.tsx@@ -10,12 +10,14 @@ import { CodeBlock } from "@/components/ui/codeblock";import { MemoizedReactMarkdown } from "@/components/markdown";import { IconOpenAI, IconUser, IconOllama } from "@/components/ui/icons";import { ChatMessageActions } from "@/components/chat-message-actions";+import { useSettings } from "@/lib/hooks/use-settings";export interface ChatMessageProps {message: Message;}export function ChatMessage({ message, ...props }: ChatMessageProps) {+ const { settings } = useSettings();return (<divclassName={cn("group relative mb-4 flex items-start md:-ml-12 w-full")}@@ -31,8 +33,9 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {>{message.role === "user" ? (<IconUser />- ) : message.content.includes("Cannot reach local Ollama instance") || message.content.includes("I cannot reach your local Ollama instance") ? (- <IconOllama />+ ) : settings.useOllama ? (+ // <IconOllama />+ <>🦙</>) : (<IconOpenAI />)}diff --git a/examples/apps/screenpipe-app-tauri/components/function-call-message.tsx b/examples/apps/screenpipe-app-tauri/components/function-call-message.tsxindex d19af5589..1a4287a2f 100644--- a/examples/apps/screenpipe-app-tauri/components/function-call-message.tsx+++ b/examples/apps/screenpipe-app-tauri/components/function-call-message.tsx@@ -22,6 +22,7 @@ import {DialogTrigger,} from "@/components/ui/dialog";import { Button } from "./ui/button";+import { useSettings } from "@/lib/hooks/use-settings";interface FunctionCallMessageProps {message: Message;@@ -32,6 +33,7 @@ export function FunctionCallMessage({message,isResult = false,}: FunctionCallMessageProps) {+ const { settings } = useSettings();const [isDialogOpen, setIsDialogOpen] = useState(false);console.log("FunctionCallMessage", message);// @ts-ignore TODO@@ -45,7 +47,7 @@ export function FunctionCallMessage({return (<div className="group relative mb-4 flex items-start md:-ml-12"><div className="flex size-8 shrink-0 select-none items-center justify-center rounded-md border shadow bg-primary text-primary-foreground">- <IconOpenAI />+ {settings.useOllama ? <>🦙</> : <IconOpenAI />}</div><div className="flex-1 px-1 ml-4 space-y-2 overflow-hidden"><Card className="w-[600px]">diff --git a/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx b/examples/apps/screenpipe-app-tauri/components/pipe-store.tsxindex c9434ab89..ce2f9e3c9 100644--- a/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx+++ b/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx@@ -72,10 +72,10 @@ const PipeDialog: React.FC = () => {return (<Dialog><DialogTrigger asChild>- {/* <Button variant="ghost">pipe store</Button> */}- <PrettyLink variant="outline" href="#">+ <Button variant="ghost">Pipe Store</Button>+ {/* <PrettyLink variant="outline" href="">Pipe Store- </PrettyLink>+ </PrettyLink> */}</DialogTrigger><DialogContent className="max-w-[90vw] w-full max-h-[90vh] h-full"><DialogHeader>diff --git a/examples/apps/screenpipe-app-tauri/components/settings.tsx b/examples/apps/screenpipe-app-tauri/components/settings.tsxindex 58d2636f9..93ad9fc98 100644--- a/examples/apps/screenpipe-app-tauri/components/settings.tsx+++ b/examples/apps/screenpipe-app-tauri/components/settings.tsx@@ -20,6 +20,9 @@ import {} from "@/components/ui/tooltip";import { Badge } from "@/components/ui/badge";import { PrettyLink } from "./pretty-link";+import { MemoizedReactMarkdown } from "./markdown";+import { Separator } from "@/components/ui/separator";+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";export function Settings({ className }: { className?: string }) {const { settings, updateSettings } = useSettings();@@ -60,86 +63,145 @@ export function Settings({ className }: { className?: string }) {Choose your AI provider and enter necessary credentials.</DialogDescription></DialogHeader>- <div className="grid gap-6 py-4">- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <div className="flex items-center space-x-4">- <Switch- id="use-ollama"- checked={localSettings.useOllama}- onCheckedChange={handleOllamaToggle}- />- <Label- htmlFor="use-ollama"- className="flex items-center space-x-2"- >- Use Ollama- </Label>- </div>- </TooltipTrigger>- <TooltipContent>- <p>- toggle to use ollama instead of openai api. make sure to have- ollama running locally.- </p>- </TooltipContent>- </Tooltip>- </TooltipProvider>+ <div className="mt-8 space-y-6">+ <Card>+ <CardHeader>+ <CardTitle className="text-center">OpenAI</CardTitle>+ </CardHeader>+ <CardContent>+ <div className="grid grid-cols-4 items-center gap-4">+ <Label htmlFor="apiKey" className="text-right">+ API Key+ </Label>+ <Input+ id="apiKey"+ value={settings.openaiApiKey}+ onChange={handleApiKeyChange}+ className="col-span-3"+ placeholder="Enter your OpenAI API Key"+ />+ </div>+ <p className="mt-2 text-sm text-muted-foreground">+ OpenAI's GPT models are currently the most reliable for+ this application.+ </p>+ <p className="mt-1 text-sm text-muted-foreground">+ Don't have an API key? Get one from{" "}+ <a+ href="https://platform.openai.com/api-keys"+ target="_blank"+ rel="noopener noreferrer"+ className="text-primary hover:underline"+ >+ OpenAI's website+ </a>+ .+ </p>+ </CardContent>+ </Card>++ <Separator />- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <div className="flex items-center space-x-4">- <Switch- id="use-embedded-llm"- checked={false}- disabled={true}- />- <Label- htmlFor="use-embedded-llm"- className="flex items-center space-x-2"+ <Card>+ <CardHeader>+ <CardTitle className="text-center">+ Alternative AI Providers+ </CardTitle>+ </CardHeader>+ <CardContent className="space-y-6">+ <div className="flex flex-col items-center space-y-2">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <div className="flex items-center space-x-4">+ <Switch+ id="use-ollama"+ checked={localSettings.useOllama}+ onCheckedChange={handleOllamaToggle}+ />+ <Label+ htmlFor="use-ollama"+ className="flex items-center space-x-2"+ >+ Use Ollama+ <Badge variant="outline" className="ml-2">+ Beta+ </Badge>+ </Label>+ </div>+ </TooltipTrigger>+ <TooltipContent>+ <p>+ Toggle to use Ollama instead of OpenAI API. Expect+ errors as this is experimental.+ <br />+ Function calling was just announced and doesn't+ work well, usually requiring more prompt engineering+ compared to OpenAI.+ </p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <div className="text-sm text-muted-foreground mt-1">+ <MemoizedReactMarkdown+ components={{+ a: ({ href, children }) => (+ <a+ className="text-primary hover:underline"+ href={href}+ target="_blank"+ rel="noopener noreferrer"+ >+ {children}+ </a>+ ),+ code: ({ children }) => (+ <code className="px-1 py-0.5 rounded-sm bg-gray-100 dark:bg-gray-800 font-mono text-sm">+ {children}+ </code>+ ),+ }}>- Use Embedded LLM- <Badge variant="outline" className="ml-2">- Soon- </Badge>- </Label>+ You need to [install Ollama](https://ollama.com/) and run+ `ollama run llama3.1` first. Currently only supports Llama+ 3.1.+ </MemoizedReactMarkdown></div>- </TooltipTrigger>- <TooltipContent>- <p>- Embedded LLM support coming soon. Run locally without- installation. No need Ollama.- </p>- </TooltipContent>- </Tooltip>- </TooltipProvider>- <div className="grid grid-cols-4 items-center gap-4">- <Label htmlFor="apiKey" className="text-right">- OpenAI API Key- </Label>- <Input- id="apiKey"- value={settings.openaiApiKey}- onChange={handleApiKeyChange}- className="col-span-3"- placeholder="Enter your OpenAI API Key"- />- </div>+ </div>++ <Separator />++ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <div className="flex items-center justify-center space-x-4">+ <Switch+ id="use-embedded-llm"+ checked={false}+ disabled={true}+ />+ <Label+ htmlFor="use-embedded-llm"+ className="flex items-center space-x-2"+ >+ Use Embedded LLM+ <Badge variant="outline" className="ml-2">+ Soon+ </Badge>+ </Label>+ </div>+ </TooltipTrigger>+ <TooltipContent>+ <p>+ Embedded LLM support coming soon. Run locally without+ installation. No need Ollama.+ </p>+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ </CardContent>+ </Card></div>- <p className="text-sm text-muted-foreground">- Don't have an API key? Get one from{" "}- <a- href="https://platform.openai.com/api-keys"- target="_blank"- rel="noopener noreferrer"- className="text-primary hover:underline"- >- OpenAI's website- </a>- .- </p></DialogContent></Dialog>);