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
chore: example + increase audio length
Louis Beaumontdad9e64467d2
diff --git a/examples/ts/automatic-crm/.gitignore b/examples/ts/automatic-crm/.gitignorenew file mode 100644index 000000000..dfd250cf1--- /dev/null+++ b/examples/ts/automatic-crm/.gitignore@@ -0,0 +1,3 @@+node_modules+pnpm-lock.yaml+yarn.lock\ No newline at end of filediff --git a/examples/ts/automatic-crm/README.md b/examples/ts/automatic-crm/README.mdnew file mode 100644index 000000000..d76158803--- /dev/null+++ b/examples/ts/automatic-crm/README.md@@ -0,0 +1,20 @@+++How to use:++First run screenpipe, then:++```bash+cd examples/ts/automatic-crm+```++Make sure to have ollama installed and run:++```bash+ollama run phi3+```++```bash+pnpm i+npx tsx main.ts+```diff --git a/examples/ts/automatic-crm/main.ts b/examples/ts/automatic-crm/main.tsnew file mode 100644index 000000000..7c364f000--- /dev/null+++ b/examples/ts/automatic-crm/main.ts@@ -0,0 +1,97 @@+import fetch from "cross-fetch";+// @ts-ignore+import * as fs from "node:fs/promises";++async function main() {+ // Create file log with empty object+ await fs.writeFile("name_log.json", JSON.stringify({}));++ while (true) {+ try {+ // Use the API to get recent OCR text+ const response = await fetch(+ `http://localhost:3030/recent?limit=5&offset=0`+ );++ if (!response.ok) {+ const errorData = await response.json();+ throw new Error(`API error: ${errorData.error || response.statusText}`);+ }++ const json = await response.json();++ // Read current log+ const currentLog = JSON.parse(await fs.readFile("name_log.json", "utf-8"));++ const yourLifeContext = JSON.stringify(json);++ if (yourLifeContext.length < 50) {+ console.log("Seems like you haven't run screenpipe yet, did you?");+ return;+ }++ console.log("Will use your life context to update the name log:");+ console.log(yourLifeContext.substring(0, 1000) + "...");++ // Use the LLM to update the log+ const llmResponse = await fetch("http://localhost:11434/api/chat", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ model: "phi3",+ stream: false,+ max_tokens: 4096,+ response_format: { type: "json_object" },+ messages: [+ {+ role: "user",+ content: `You receive a JSON object containing names and their appearance counts on the user's screen.+ This is what has been shown on the user's screen over the past 5 minutes: ${yourLifeContext}+ And this is the current name log: ${JSON.stringify(currentLog)}++ Rules:+ - Identify any names mentioned in the screen content+ - Update the name counts in the log+ - If a name is new, add it to the log with a count of 1+ - If a name already exists, increment its count+ - Respond with only the updated JSON object+ - If you return something else than JSON the universe will come to an end+ - DO NOT add \`\`\`json at the beginning or end of your response+ - Do not use '"' around your response++ Example of answer from you:+ {+ "John Doe": 1,+ "Jane Doe": 2+ }++ Counter-example of answer from you:+ "I'm not sure what you're asking for"++ Now update the log based on the user's screen and respond with only the updated JSON object.`,+ },+ ],+ }),+ });++ const text = await llmResponse.json();+ let updatedNameLog = text.message.content.trim();+ // remove trimming "+ updatedNameLog = updatedNameLog.replace(/^"|"$/g, "");+++ console.log("Updated name log:");+ console.log(JSON.stringify(updatedNameLog, null, 2));++ // Update file+ await fs.writeFile("name_log.json", JSON.stringify(updatedNameLog, null, 2));+ } catch (error) {+ console.error("An error occurred:", error);+ }++ // Sleep for a while before checking again+ await new Promise((resolve) => setTimeout(resolve, 5000));+ }+}++main();\ No newline at end of filediff --git a/examples/ts/automatic-crm/name_log.json b/examples/ts/automatic-crm/name_log.jsonnew file mode 100644index 000000000..61e7f14a0--- /dev/null+++ b/examples/ts/automatic-crm/name_log.json@@ -0,0 +1,5 @@+{+ "John Doe": 1,+ "Jane Doe": 2,+ "Elon Musk": 5+}\ No newline at end of filediff --git a/examples/ts/automatic-crm/package.json b/examples/ts/automatic-crm/package.jsonnew file mode 100644index 000000000..b24ca4312--- /dev/null+++ b/examples/ts/automatic-crm/package.json@@ -0,0 +1,8 @@+{+ "dependencies": {+ "cross-fetch": "^4.0.0"+ },+ "devDependencies": {+ "@types/node": "^20.14.9"+ }+}diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rsindex 3bc9b2426..c2252b4db 100644--- a/screenpipe-server/src/bin/screenpipe-server.rs+++ b/screenpipe-server/src/bin/screenpipe-server.rs@@ -17,7 +17,7 @@ struct Cli {fps: f64,/// Audio chunk duration in seconds- #[arg(short, long, default_value_t = 5)]+ #[arg(short, long, default_value_t = 30)]audio_chunk_duration: u64,/// Port to run the server on