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 ui issue + add new pipe wip
Louis Beaumontb85fd09bcfd4
diff --git a/examples/typescript/pipe-meeting-summary-by-email/README.md b/examples/typescript/pipe-meeting-summary-by-email/README.mdindex 3ebc600e3..ba958ea1f 100644--- a/examples/typescript/pipe-meeting-summary-by-email/README.md+++ b/examples/typescript/pipe-meeting-summary-by-email/README.md@@ -1,109 +1,3 @@-### pipe-email-daily-log+work in progress, will share how to use soon (092624)-<img width="988" alt="Screenshot 2024-09-25 at 17 56 00" src="https://github.com/user-attachments/assets/f9d604af-b098-4f93-b923-b2fc455a6172">---https://github.com/user-attachments/assets/a81963c9-54ee-4587-aac1-2eba0df4a5fc----llama3.2 looks at your screen 24/7 and send you emails summarizing your activity or action items (e.g. follow up on this lead, or anything, you can customise the prompt and windows/tabs/apps being used as prompt)--#### quick setup--1. run ollama:- ```- ollama run phi3.5:3.8b-mini-instruct-q4_K_M- ```--2. [create app specific password](https://support.google.com/accounts/answer/185833?hl=en) in your google account that will be used to send yourself emails--3. configure pipe in the app ui, save, enable, restart screenpipe recording (you can config to either receive a mail a day or several every x hours)--<img width="1312" alt="Screenshot 2024-09-25 at 18 16 54" src="https://github.com/user-attachments/assets/9669b2f1-c67d-4055-9e03-067c67fb51f8">--boom!--wanna tweak it? check `pipe.ts`.--can be used through CLI also, you can tweak the `pipe.json` to your needs, mine looks like this:--```json-{- "fields": [- {- "name": "interval",- "type": "number",- "default": 60,- "description": "Interval in seconds to read your screen data"- },- {- "name": "summaryFrequency",- "type": "string",- "default": "daily",- "description": "Frequency of summary emails: 'daily' for once a day at emailTime, or 'hourly:X' for every X hours (e.g., 'hourly:4' for every 4 hours)",- "value": "hourly:1"- },- {- "name": "emailTime",- "type": "time",- "default": "11:00",- "description": "Time to send daily summary email (used only if summaryFrequency is 'daily')"- },- {- "name": "emailAddress",- "type": "string",- "default": "<fill your email address here>",- "description": "Email Address",- "value": "[email protected]"- },- {- "name": "emailPassword",- "type": "string",- "default": "<fill your email password here>",- "description": "Email Password https://support.google.com/accounts/answer/185833?hl=en",- "value": "mypassword"- },- {- "name": "ollamaApiUrl",- "type": "string",- "default": "http://localhost:11434/api",- "description": "Ollama API URL"- },- {- "name": "ollamaModel",- "type": "string",- "default": "llama3.2:3b-instruct-q4_K_M",- "description": "Ollama Model"- },- {- "name": "pageSize",- "type": "number",- "default": 100,- "description": "Number of records to retrieve from screenpipe per page, keep in mind LLMs have a context window limit"- },- {- "name": "customPrompt",- "type": "string",- "default": "You are an AI assistant tasked with extracting structured information from screen data (OCR). Analyze the following screen data and extract relevant information about my daily activity.",- "description": "Custom prompt for the AI assistant"- },- {- "name": "summaryPrompt",- "type": "string",- "default": "You are an AI assistant tasked with summarizing information that has previously been extracted from screen data (OCR) by another AI assistant. Analyze the following structured data extracted from my screen data and summarize my daily activity, this will be send as a mail to my email address.",- "description": "Summary prompt for the AI assistant"- },- {- "name": "windowName",- "type": "window",- "default": "",- "description": "Specific window name to filter the screen data, for example 'gmail', 'john', 'slack', 'myCodeFile.tsx', etc.",- "value": "matt"- }- ],- "source": "https://github.com/mediar-ai/screenpipe/tree/main/examples/typescript/pipe-email-daily-log",- "enabled": true-}-```diff --git a/examples/typescript/pipe-meeting-summary-by-email/pipe.json b/examples/typescript/pipe-meeting-summary-by-email/pipe.jsonindex 82ee98a8b..758e7eb88 100644--- a/examples/typescript/pipe-meeting-summary-by-email/pipe.json+++ b/examples/typescript/pipe-meeting-summary-by-email/pipe.json@@ -21,8 +21,8 @@{"name": "aiApiUrl","type": "string",- "default": "http://localhost:11434/api",- "description": "ai api url, can be ollama, openai, any openai compatible api"+ "default": "http://localhost:11434/api/chat",+ "description": "ai api url, can be ollama, openai, any openai compatible api, for openai use https://api.openai.com/v1/chat/completions"},{"name": "aiModel",@@ -31,9 +31,9 @@"description": "ai model"},{- "name": "summaryPrompt",+ "name": "customSummaryPrompt","type": "string",- "default": "summarize the following meeting transcript, focusing on key points, action items, and decisions made:",+ "default": "summarize the following meeting transcript, there might be multiple meeting in the transcript, make sure to properly separate them, focusing on key points, action items, and decisions made:","description": "custom prompt for summarizing the meeting"}]diff --git a/examples/typescript/pipe-meeting-summary-by-email/pipe.ts b/examples/typescript/pipe-meeting-summary-by-email/pipe.tsindex ab2ae99f1..939712612 100644--- a/examples/typescript/pipe-meeting-summary-by-email/pipe.ts+++ b/examples/typescript/pipe-meeting-summary-by-email/pipe.ts@@ -1,15 +1,18 @@async function summarizeAudio(audioData: ContentItem[],aiApiUrl: string,- aiModel: string+ aiModel: string,+ customSummaryPrompt: string): Promise<string> {- const prompt = `summarize the following meeting transcript:+ const prompt = `Very important intructions to follow: "${customSummaryPrompt}"++ summarize the following meeting transcript:${JSON.stringify(audioData)}provide a concise summary of the key points discussed in the meeting.`;- const response = await fetch(`${aiApiUrl}/chat`, {+ const response = await fetch(aiApiUrl, {method: "POST",body: JSON.stringify({model: aiModel,@@ -46,14 +49,117 @@ async function sendEmail(console.log(`email sent to ${to} with subject: ${subject}`);}+interface TimeAdjustment {+ shouldAdjust: boolean;+ shouldPollDataBeforeOrAfter: boolean;+}++async function checkTimeAdjustment(+ audioData: ContentItem[],+ aiApiUrl: string,+ aiModel: string+): Promise<TimeAdjustment> {+ const prompt = `Analyze the following meeting transcript:++ ${JSON.stringify(audioData)}++ Determine if this appears to be a complete meeting or if it might be truncated.+ Return a JSON object with the following structure:+ {+ "shouldAdjust": boolean,+ "shouldPollDataBeforeOrAfter": boolean,+ }++ Rules:+ - Set shouldAdjust to true if the meeting seems incomplete+ - set shouldPollDataBeforeOrAfter to true if we need to get data before or after the meeting timestamp to make it complete+ - If the meeting seems complete, set all values to 0+ - Do not add backticks to the JSON+ - Return only the JSON object, no additional text, if you return anything but JSON, the whole code will crash and the user will be very sad+ `;++ const response = await fetch(aiApiUrl, {+ method: "POST",+ body: JSON.stringify({+ model: aiModel,+ messages: [{ role: "user", content: prompt }],+ stream: false,+ response_format: { type: "json_object" },+ }),+ });++ if (!response.ok) {+ console.log("ollama response:", await response.text());+ throw new Error(`http error! status: ${response.status}`);+ }++ const result = await response.json();++ console.log("ai answer:", result);++ let content;+ try {+ content = extractJsonFromLlmResponse(result.message.content);+ } catch (error) {+ console.warn("failed to parse ai response:", error, result);+ throw new Error("invalid ai response format");+ }++ return content;+}++function extractJsonFromLlmResponse(response: string): any {+ // Remove any markdown code block syntax+ let cleaned = response.replace(/^```(?:json)?\s*|\s*```$/g, "");++ // Try to find JSON-like content+ const jsonMatch = cleaned.match(/\{[\s\S]*\}/);+ if (jsonMatch) {+ cleaned = jsonMatch[0];+ }++ // Remove any non-JSON content before or after the main object+ cleaned = cleaned.replace(/^[^{]*/, "").replace(/[^}]*$/, "");++ // Replace any escaped newlines and remove actual newlines+ cleaned = cleaned.replace(/\\n/g, "").replace(/\n/g, "");++ try {+ return JSON.parse(cleaned);+ } catch (error) {+ console.warn("failed to parse json:", error);+ console.warn("cleaned content:", cleaned);++ // Attempt to fix common issues+ cleaned = cleaned+ .replace(/,\s*}/g, "}") // Remove trailing commas+ .replace(/'/g, '"') // Replace single quotes with double quotes+ .replace(/(\w+):/g, '"$1":') // Add quotes to keys+ .replace(/:\s*'([^']*)'/g, ': "$1"'); // Replace single-quoted values with double-quoted values++ try {+ return JSON.parse(cleaned);+ } catch (secondError) {+ console.warn("failed to parse json after attempted fixes:", secondError);+ throw new Error("invalid json format in llm response");+ }+ }+}+async function meetingSummaryPipeline(): Promise<void> {console.log("starting meeting summary pipeline");const config = await pipe.loadConfig();console.log("loaded config:", JSON.stringify(config, null, 2));- const { pollingInterval, emailAddress, emailPassword, aiApiUrl, aiModel } =- config;+ const {+ pollingInterval,+ emailAddress,+ emailPassword,+ aiApiUrl,+ aiModel,+ customSummaryPrompt,+ } = config;console.log("pollingInterval:", pollingInterval);console.log("emailAddress:", emailAddress);@@ -68,7 +174,7 @@ async function meetingSummaryPipeline(): Promise<void> {console.log("oneHourAgo:", oneHourAgo);console.log("now:", now);- const audioData = await pipe.queryScreenpipe({+ let audioData = await pipe.queryScreenpipe({start_time: oneHourAgo.toISOString(),end_time: now.toISOString(),content_type: "audio",@@ -79,7 +185,52 @@ async function meetingSummaryPipeline(): Promise<void> {if (audioData && audioData.data && audioData.data.length > 0) {console.log("audioData.data:", audioData.data);- const summary = await summarizeAudio(audioData.data, aiApiUrl, aiModel);++ // Check if we need to adjust the time range+ const timeAdjustment = await checkTimeAdjustment(+ audioData.data,+ aiApiUrl,+ aiModel+ );++ if (timeAdjustment.shouldAdjust) {+ // if we need to adjust the time range, we need to query the data before or after the meeting timestamp to make it complete+ // if it's before, we need to remove 30 minutes from the start+ // if it's after, we need to add 30 minutes to the end++ const adjustedStart = timeAdjustment.shouldPollDataBeforeOrAfter+ ? new Date(oneHourAgo.getTime() - 30 * 60 * 1000)+ : oneHourAgo;+ const adjustedEnd = timeAdjustment.shouldPollDataBeforeOrAfter+ ? new Date(now.getTime() + 30 * 60 * 1000)+ : now;++ console.log("Adjusting time range:");+ console.log("New start:", adjustedStart);+ console.log("New end:", adjustedEnd);++ // Query additional data+ const additionalData = await pipe.queryScreenpipe({+ start_time: adjustedStart.toISOString(),+ end_time: adjustedEnd.toISOString(),+ content_type: "audio",+ limit: 10_000,+ });++ // Merge the additional data with the original data+ if (additionalData && additionalData.data) {+ audioData.data = [...audioData.data, ...additionalData.data];+ }+ }++ console.log("now summarizing");++ const summary = await summarizeAudio(+ audioData.data,+ aiApiUrl,+ aiModel,+ customSummaryPrompt+ );console.log("summary:", summary);await sendEmail(diff --git a/screenpipe-app-tauri/components/pipe-config-form.tsx b/screenpipe-app-tauri/components/pipe-config-form.tsxindex f70a441b8..b02082cb7 100644--- a/screenpipe-app-tauri/components/pipe-config-form.tsx+++ b/screenpipe-app-tauri/components/pipe-config-form.tsx@@ -44,6 +44,10 @@ export const PipeConfigForm: React.FC<PipeConfigFormProps> = ({console.log("pipe", pipe);console.log("config", config);+ useEffect(() => {+ setConfig(pipe.config);+ }, [pipe]);+const handleInputChange = (name: string, value: any) => {if (!config) return;setConfig((prevConfig) => ({diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex 4a3f56a7c..6b3b76c42 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -139,11 +139,23 @@ const PipeDialog: React.FC = () => {pipe.id,"README.md");- const readme = await readFile(pathToReadme);- const readmeString = new TextDecoder().decode(readme);- pipe.fullDescription = convertHtmlToMarkdown(readmeString);+ try {+ const readme = await readFile(pathToReadme);+ const readmeString = new TextDecoder().decode(readme);+ pipe.fullDescription = convertHtmlToMarkdown(readmeString);+ } catch (error) {+ console.warn(`no readme found for pipe ${pipe.id}`);+ pipe.fullDescription = "no description available for this pipe.";+ }}setPipes(data);+ // Update selectedPipe if it exists in the new data+ if (selectedPipe) {+ const updatedSelectedPipe = data.find(+ (pipe: Pipe) => pipe.id === selectedPipe.id+ );+ setSelectedPipe(updatedSelectedPipe || null);+ }} catch (error) {console.error("Error fetching installed pipes:", error);toast({@@ -332,14 +344,6 @@ const PipeDialog: React.FC = () => {}};- const formatUpdatedTime = (date: string) => {- const now = new Date();- const updated = new Date(date);- const diffTime = Math.abs(now.getTime() - updated.getTime());- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));- return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;- };-const renderPipeContent = () => {if (!selectedPipe) {return (@@ -391,14 +395,15 @@ const PipeDialog: React.FC = () => {</TooltipProvider>)}- <Button- onClick={() => openUrl(selectedPipe.source, "_blank")}- variant="outline"- disabled={!selectedPipe.source.startsWith("http")}- >- <ExternalLink className="mr-2 h-4 w-4" />- view source- </Button>+ {selectedPipe.source.startsWith("http") && (+ <Button+ onClick={() => openUrl(selectedPipe.source, "_blank")}+ variant="outline"+ >+ <ExternalLink className="mr-2 h-4 w-4" />+ view source+ </Button>+ )}<Button disabled variant="outline"><Heart className="mr-2 h-4 w-4" />donate@@ -673,27 +678,7 @@ const PipeDialog: React.FC = () => {read the docs</a></DialogDescription>-- {/* {selectedPipe && <FeatureRequestLink className="w-80" />} */}</DialogHeader>- {/* center message in big */}- {/* <div className="flex flex-col justify-center items-center h-[500px]">- <p className="text-center">- currently you need to enable pipes through `screenpipe pipe`- commands or `/pipes` api- <br />- we're going to make this nontechnical next week.- </p>- <br />- <a- href="https://github.com/mediar-ai/screenpipe/tree/main/examples/typescript"- className="text-blue-500 hover:underline"- target="_blank"- rel="noopener noreferrer"- >- check out more examples on github- </a>- </div> */}{renderContent()}</DialogContent></Dialog>diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 5ad6c7d51..d5c11a479 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.2.70"+version = "0.2.71"description = ""authors = ["you"]license = ""