|
| 1 | +""" |
| 2 | +This is an Open Interpreter profile specialized for searching ScreenPipe history. |
| 3 | +It is configured to run Anthropic's `Claude 3.5 Sonnet`. |
| 4 | +""" |
| 5 | + |
| 6 | +# Configure Open Interpreter |
| 7 | +from interpreter import interpreter |
| 8 | +from datetime import datetime, timezone |
| 9 | + |
| 10 | +interpreter.llm.model = "claude-3-5-sonnet-20240620" |
| 11 | +interpreter.computer.import_computer_api = False |
| 12 | +interpreter.llm.supports_functions = False |
| 13 | +interpreter.llm.supports_vision = False |
| 14 | +interpreter.llm.context_window = 100000 |
| 15 | +interpreter.llm.max_tokens = 8192 |
| 16 | + |
| 17 | +# Add the current date and time in UTC |
| 18 | +current_datetime = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC") |
| 19 | + |
| 20 | +custom_tool = """ |
| 21 | +import requests |
| 22 | +import json |
| 23 | +from urllib.parse import quote |
| 24 | +
|
| 25 | +def search_screenpipe(query, limit=5, start_time=None, end_time=None): |
| 26 | + base_url = f"http://localhost:3030/search?q={quote(query)}&content_type=ocr&limit={limit}" |
| 27 | + |
| 28 | + if start_time: |
| 29 | + base_url += f"&start_time={quote(start_time)}" |
| 30 | + if end_time: |
| 31 | + base_url += f"&end_time={quote(end_time)}" |
| 32 | + |
| 33 | + response = requests.get(base_url) |
| 34 | + if response.status_code == 200: |
| 35 | + data = response.json() |
| 36 | + # Remove duplicates based on text content |
| 37 | + unique_results = [] |
| 38 | + seen_texts = set() |
| 39 | + for item in data["data"]: |
| 40 | + text = item["content"]["text"] |
| 41 | + if text not in seen_texts: |
| 42 | + unique_results.append(item) |
| 43 | + seen_texts.add(text) |
| 44 | + return unique_results |
| 45 | + else: |
| 46 | + return f"Error: Unable to fetch data from ScreenPipe. Status code: {response.status_code}" |
| 47 | +""" |
| 48 | + |
| 49 | +# Add the custom tool to the interpreter's environment |
| 50 | +interpreter.computer.run("python", custom_tool) |
| 51 | + |
| 52 | +interpreter.custom_instructions = f""" |
| 53 | +Current date and time: {current_datetime} |
| 54 | +
|
| 55 | +ScreenPipe is a powerful tool that continuously captures and indexes the content displayed on your screen. It creates a searchable history of everything you've seen or interacted with on your computer. This includes text from websites, documents, applications, and even images (through OCR). |
| 56 | +
|
| 57 | +You have access to this wealth of information through the `search_screenpipe(query, limit=5, start_time=None, end_time=None)` function. This allows you to provide more contextual and personalized assistance based on the user's recent activities and viewed content. |
| 58 | +
|
| 59 | +The `search_screenpipe` function supports optional `start_time` and `end_time` parameters to narrow down the search to a specific time range. The time format should be ISO 8601, like this: "2024-10-16T12:00:00Z". |
| 60 | +
|
| 61 | +Here's why querying ScreenPipe is valuable: |
| 62 | +1. Context Recall: Users often refer to things they've seen recently but may not remember the exact details. ScreenPipe can help recall this information. |
| 63 | +2. Information Verification: You can cross-reference user claims or questions with actual content they've viewed. |
| 64 | +3. Personalized Assistance: By knowing what the user has been working on or researching, you can provide more relevant advice and suggestions. |
| 65 | +4. Productivity Enhancement: You can help users quickly locate information they've seen before but can't remember where. |
| 66 | +
|
| 67 | +Use the `search_screenpipe()` function when: |
| 68 | +- The user asks about something they've seen or read recently. |
| 69 | +- You need to verify or expand on information the user mentions. |
| 70 | +- You want to provide context-aware suggestions or assistance. |
| 71 | +- The user is trying to recall specific details from their recent computer usage. |
| 72 | +- The user wants to search within a specific time range. |
| 73 | +
|
| 74 | +Here's how to use it effectively: |
| 75 | +1. When a user's query relates to recent activities or viewed content, identify key terms for the search. |
| 76 | +2. If the user specifies a time range, use the `start_time` and `end_time` parameters. |
| 77 | +3. Call the `search_screenpipe()` function with these parameters. |
| 78 | +4. Analyze the results to find relevant information. |
| 79 | +5. Summarize the findings for the user, mentioning the source (app name, window name) and when it was seen (timestamp). |
| 80 | +
|
| 81 | +Remember to use this tool proactively when you think it might help answer the user's question, even if they don't explicitly mention ScreenPipe. |
| 82 | +
|
| 83 | +Example usage in Python: |
| 84 | +```python |
| 85 | +# Search without time range |
| 86 | +results = search_screenpipe("Open Interpreter", limit=3) |
| 87 | +
|
| 88 | +# Search with time range |
| 89 | +results = search_screenpipe("project meeting", limit=5, start_time="2024-10-16T12:00:00Z", end_time="2024-10-16T19:00:00Z") |
| 90 | +
|
| 91 | +for result in results: |
| 92 | + print(f"Text: {{result['content']['text'][:100]}}...") # Print first 100 characters |
| 93 | + print(f"Source: {{result['content']['app_name']}} - {{result['content']['window_name']}}") |
| 94 | + print(f"Timestamp: {{result['content']['timestamp']}}") |
| 95 | +``` |
| 96 | +
|
| 97 | +""" |
0 commit comments