Skip to content

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

fix: incorrect arg in function call

Louis Beaumont2251d4284add
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.tsx
index b07437921..4b71f550f 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
@@ -96,6 +96,10 @@ export function ChatList({
}
}
+ console.log(
+ "Intl.DateTimeFormat().resolvedOptions().timeZone",
+ Intl.DateTimeFormat().resolvedOptions().timeZone
+ );
// console.log("provider", provider);
console.log("model", model);
@@ -103,26 +107,37 @@ export function ChatList({
model: provider(model),
tools: {
query_screenpipe: {
- description: `Query the local screenpipe instance for relevant information.
- You will return multiple queries under the key 'queries'.
- Make sure to return a list of queries, not a single query.
-
- ONLY USE THIS TOOL ONCE
-
- - MAKE SURE TO RETURN AN ARRAY OF QUERIES e.g. {"queries": [ ... ]}
-
- Example answers from you:
- "{
- "queries": [
- {"q": "goal", "offset": 0, "limit": 10, "content_type": "all", "start_date": "2024-07-21T11:30:25Z", "end_date": "2024-07-21T11:35:25Z", "app_name": "arc"},
- {"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"}
- ]
- }"
-
- `,
+ description: `Query local screenpipe. Return list of queries. Use once, then next tool.
+ - Current time: ${new Date().toISOString()}. Adjust start/end times to match user intent.
+ - Convert user times to UTC. User timezone: ${
+ Intl.DateTimeFormat().resolvedOptions().timeZone
+ }.
+ Example:
+ {
+ "queries": [
+ {"q": "goal", "offset": 0, "limit": 10, "content_type": "all", "start_time": "2024-07-21T11:30:25Z", "end_time": "2024-07-21T11:35:25Z", "app_name": "arc"},
+ {"offset": 0, "limit": 50, "content_type": "ocr", "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"},
+ {"q": "customer", "offset": 0, "limit": 20, "content_type": "audio", "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"}
+ ]
+ }
+ Adapt to user intent.`,
parameters: screenpipeMultiQuery,
execute: async (e: z.infer<typeof screenpipeMultiQuery>) => {
+ // ! just a hack because maxToolRoundtrips is not working
+ // if model called multiple times query_screenpipe while user just sent a single message, just return the result from the last query_screenpipe
+ if (
+ messages.length > 1 &&
+ messages[messages.length - 1].role === "user" &&
+ messages[messages.length - 2].role === "tool" &&
+ // @ts-ignore
+ messages[messages.length - 2].toolInvocations.length > 0 &&
+ // @ts-ignore
+ messages[messages.length - 2].toolInvocations[0].result
+ ) {
+ // @ts-ignore
+ return messages[messages.length - 2].toolInvocations[0].result;
+ }
+
// @ts-ignore
setMessages((prevMessages) => [
...prevMessages,
@@ -209,21 +224,23 @@ export function ChatList({
Based on the user request, use tools to query screenpipe to best help the user.
Rules:
- q should be a single keyword that would properly find in the text found on the user screen some infomation that would help answering the user question.
- Return a list of objects with the key "queries"
- q contains a single query, again, for example instead of "life plan" just use "life"
- 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
- - Date & time now is ${new Date().toISOString()}. Adjust start_date and end_date to properly match the user intent time range.
+ - Date & time now is ${new Date().toISOString()}. Adjust start_time and end_time to properly match the user intent time range.
+ - When the user mentions specific times (e.g., "9 to 10 am"), convert these to UTC before querying. Assume the user's local timezone is ${
+ Intl.DateTimeFormat().resolvedOptions().timeZone
+ }.
- If the user ask about his morning do not use morning as query that's dumb, try to infer some keywords from the user question
- 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
- You typically always query screenpipe in the first user message
- ALWAYS use the "stream_response" tool to stream the final response to the user
- ALWAYS use the "stream_response" tool to stream the final response to the user
- ALWAYS use the "stream_response" tool to stream the final response to the user
+ - ONLY USE query tool ONCE
`,
},
diff --git a/examples/apps/screenpipe-app-tauri/components/chat-list-web-llm.tsx b/examples/apps/screenpipe-app-tauri/components/chat-list-web-llm.tsx
index d016786e6..23ab51e70 100644
--- a/examples/apps/screenpipe-app-tauri/components/chat-list-web-llm.tsx
+++ b/examples/apps/screenpipe-app-tauri/components/chat-list-web-llm.tsx
@@ -24,16 +24,16 @@ async function queryScreenpipe(params: {
q: string;
offset: number;
limit: number;
- start_date: string;
- end_date: string;
+ start_time: string;
+ end_time: string;
}) {
try {
const queryParams = new URLSearchParams({
q: params.q,
offset: params.offset.toString(),
limit: params.limit.toString(),
- start_date: params.start_date,
- end_date: params.end_date,
+ start_time: params.start_time,
+ end_time: params.end_time,
});
const response = await fetch(`http://localhost:3030/search?${queryParams}`);
if (!response.ok) {
@@ -110,16 +110,16 @@ Use this function to answer any questions about the user's activity.
type: "number",
description: "The limit for pagination",
},
- start_date: {
+ start_time: {
type: "string",
- description: "The start date for the query in ISO format",
+ description: "The start time for the query in ISO format",
},
- end_date: {
+ end_time: {
type: "string",
- description: "The end date for the query in ISO format",
+ description: "The end time for the query in ISO format",
},
},
- required: ["q", "offset", "limit", "start_date", "end_date"],
+ required: ["q", "offset", "limit", "start_time", "end_time"],
},
},
],
diff --git a/examples/apps/screenpipe-app-tauri/components/function-call-message.tsx b/examples/apps/screenpipe-app-tauri/components/function-call-message.tsx
index 7fb9bbe2a..71922e1c8 100644
--- a/examples/apps/screenpipe-app-tauri/components/function-call-message.tsx
+++ b/examples/apps/screenpipe-app-tauri/components/function-call-message.tsx
@@ -218,15 +218,16 @@ function MarkdownContent({ content }: { content: string }) {
function generateCurlCommand(query: any): string {
const baseUrl = "http://localhost:3030";
const queryParams = new URLSearchParams({
- q: query.q || "",
content_type: query.contentType || "all",
limit: query.limit?.toString() || "10",
offset: query.offset?.toString() || "0",
start_time: query.start_time || "",
end_time: query.end_time || "",
- app_name: query.app_name || "",
- }).toString();
+ });
+
+ if (query.q) queryParams.append("q", query.q);
+ if (query.app_name) queryParams.append("app_name", query.app_name);
return `curl "${baseUrl}/search?\\
-${queryParams.replace(/&/g, "\\\n&")}"`;
+${queryParams.toString().replace(/&/g, "\\\n&")}"`;
}
diff --git a/examples/apps/screenpipe-app-tauri/components/meeting-summarized.tsx b/examples/apps/screenpipe-app-tauri/components/meeting-summarized.tsx
index ee00ae3fc..a5c529f2f 100644
--- a/examples/apps/screenpipe-app-tauri/components/meeting-summarized.tsx
+++ b/examples/apps/screenpipe-app-tauri/components/meeting-summarized.tsx
@@ -61,8 +61,8 @@ async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {
q: params.q,
offset: params.offset.toString(),
limit: params.limit.toString(),
- start_date: params.start_time,
- end_date: params.end_time,
+ start_time: params.start_time,
+ end_time: params.end_time,
content_type: params.content_type,
app_name: params.app_name,
}).filter(([_, v]) => v != null) as [string, string][]
diff --git a/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts b/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts
index da51e38f5..62a4613ce 100644
--- a/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts
+++ b/examples/apps/screenpipe-app-tauri/lib/screenpipe.ts
@@ -68,8 +68,8 @@ export async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {
q: params.q,
offset: params.offset.toString(),
limit: params.limit.toString(),
- start_date: params.start_time,
- end_date: params.end_time,
+ start_time: params.start_time,
+ end_time: params.end_time,
content_type: params.content_type,
app_name: params.app_name,
}).filter(([_, v]) => v != null) as [string, string][]
diff --git a/examples/typescript/agent-multi-turn-rag/screenpipe.ts b/examples/typescript/agent-multi-turn-rag/screenpipe.ts
index 714c0f217..2f5382806 100644
--- a/examples/typescript/agent-multi-turn-rag/screenpipe.ts
+++ b/examples/typescript/agent-multi-turn-rag/screenpipe.ts
@@ -66,8 +66,8 @@ async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {
q: params.q,
offset: params.offset.toString(),
limit: params.limit.toString(),
- start_date: params.start_time,
- end_date: params.end_time,
+ start_time: params.start_time,
+ end_time: params.end_time,
content_type: params.content_type,
app_name: params.app_name,
}).filter(([_, v]) => v != null) as [string, string][]
@@ -143,7 +143,7 @@ const screenpipe = async () => {
his screen and mics 24/7. The user ask you questions
and you use his screenpipe recordings to answer him.
Based on the user request, use tools to query screenpipe to best help the user.
- Each query should have "q", "offset", "limit", "start_date", "end_date", and "content_type" fields.
+ Each query should have "q", "offset", "limit", "start_time", "end_time", and "content_type" fields.
Rules:
- q should be a single keyword that would properly find in the text found on the user screen some infomation that would help answering the user question.
Return a list of objects with the key "queries"
@@ -152,7 +152,7 @@ const screenpipe = async () => {
- 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
- - Date & time now is ${new Date().toISOString()}. Adjust start_date and end_date to properly match the user intent time range.
+ - Date & time now is ${new Date().toISOString()}. Adjust start_time and end_time to properly match the user intent time range.
- If the user ask about his morning do not use morning as query that's dumb, try to infer some keywords from the user question
- 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
@@ -165,18 +165,18 @@ const screenpipe = async () => {
Example answers from you:
"{
"queries": [
- {"q": "goal", "offset": 0, "limit": 10, "content_type": "all", "start_date": "2024-07-21T11:30:25Z", "end_date": "2024-07-21T11:35:25Z", "app_name": "arc"},
- {"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"}
+ {"q": "goal", "offset": 0, "limit": 10, "content_type": "all", "start_time": "2024-07-21T11:30:25Z", "end_time": "2024-07-21T11:35:25Z", "app_name": "arc"},
+ {"offset": 0, "limit": 50, "content_type": "ocr", "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"},
+ {"q": "customer", "offset": 0, "limit": 20, "content_type": "audio", "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"}
]
}"
or
"{
"queries": [
- {"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"},
- {"offset": 0, "limit": 10, "content_type": "all", "start_date": "2024-07-19T08:00:25Z", "end_date": "2024-07-20T09:00:25Z", "app_name": "notes"}
+ {"q": "sales", "offset": 0, "limit": 10, "content_type": "all", "start_time": "2024-07-21T11:30:25Z", "end_time": "2024-07-21T11:35:25Z"},
+ {"q": "customer", "offset": 0, "limit": 20, "content_type": "all", "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"},
+ {"offset": 0, "limit": 10, "content_type": "all", "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z", "app_name": "notes"}
]
}"
diff --git a/examples/typescript/apple-shortcut/main.js b/examples/typescript/apple-shortcut/main.js
index 3f1404d6d..64690c361 100644
--- a/examples/typescript/apple-shortcut/main.js
+++ b/examples/typescript/apple-shortcut/main.js
@@ -59,7 +59,7 @@ async function runScreenpipe(input) {
messages: [
{
role: "user",
- content: `Based on this user selection: "${input}", generate parameters as JSON for 3 different queries to screenpipe. Each query should have "q", "offset", "limit", and start_date, end_date fields. Rules: - q should be a single keyword that would properly find in the text found on the user screen some information that would help answering the user question. Return a list of objects with the key "queries" - q contains a single query, again, for example instead of "life plan" just use "life" - Respond with only the updated JSON object - User's Date & time now is ${currentDate} - Make sure to respect user's date - Be concise, asnwer as a bullet list - Your answer will be read out loud so make sure it's adapted`
+ content: `Based on this user selection: "${input}", generate parameters as JSON for 3 different queries to screenpipe. Each query should have "q", "offset", "limit", and start_time, end_time fields. Rules: - q should be a single keyword that would properly find in the text found on the user screen some information that would help answering the user question. Return a list of objects with the key "queries" - q contains a single query, again, for example instead of "life plan" just use "life" - Respond with only the updated JSON object - User's Date & time now is ${currentDate} - Make sure to respect user's date - Be concise, asnwer as a bullet list - Your answer will be read out loud so make sure it's adapted`
}
],
model: OPENAI_MODEL,
diff --git a/examples/typescript/daily-detailed-activity-reporter/screenpipe.ts b/examples/typescript/daily-detailed-activity-reporter/screenpipe.ts
index 2ba5f2900..575c9d819 100644
--- a/examples/typescript/daily-detailed-activity-reporter/screenpipe.ts
+++ b/examples/typescript/daily-detailed-activity-reporter/screenpipe.ts
@@ -63,8 +63,8 @@ export async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {
q: params.q,
offset: params.offset.toString(),
limit: params.limit.toString(),
- start_date: params.start_time,
- end_date: params.end_time,
+ start_time: params.start_time,
+ end_time: params.end_time,
content_type: params.content_type,
app_name: params.app_name,
}).filter(([_, v]) => v != null) as [string, string][]
diff --git a/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/screenpipe.ts b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/screenpipe.ts
index cab8d20d1..9a58576c7 100644
--- a/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/screenpipe.ts
+++ b/examples/typescript/perplexity-alike-asking-confirmation-rag-agent/screenpipe.ts
@@ -63,8 +63,8 @@ async function queryScreenpipe(params: z.infer<typeof screenpipeQuery>) {
q: params.q,
offset: params.offset.toString(),
limit: params.limit.toString(),
- start_date: params.start_time,
- end_date: params.end_time,
+ start_time: params.start_time,
+ end_time: params.end_time,
content_type: params.content_type,
app_name: params.app_name,
}).filter(([_, v]) => v != null) as [string, string][]
@@ -168,7 +168,7 @@ const perplexityAlikeAgent = async () => {
- 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
- - Date & time now is ${new Date().toISOString()}. Adjust start_date and end_date to properly match the user intent time range.
+ - Date & time now is ${new Date().toISOString()}. Adjust start_time and end_time to properly match the user intent time range.
`,
parameters: z.object({
suggested_queries: screenpipeMultiQuery,
diff --git a/examples/typescript/rag-over-your-life-in-obsidian/screenpipe.js b/examples/typescript/rag-over-your-life-in-obsidian/screenpipe.js
index 433130f9f..d9ab921ef 100644
--- a/examples/typescript/rag-over-your-life-in-obsidian/screenpipe.js
+++ b/examples/typescript/rag-over-your-life-in-obsidian/screenpipe.js
@@ -27,7 +27,7 @@ const screenpipe = async (conf) => {
{
'role': 'user',
'content': `Based on this user selection: "${msg}", generate parameters as JSON for 3 different queries to screenpipe.
- Each query should have "q", "offset", "limit", and start_date, end_date fields.
+ Each query should have "q", "offset", "limit", and start_time, end_time fields.
Rules:
- q should be a single keyword that would properly find in the text found on the user screen some infomation that would help answering the user question.
Return a list of objects with the key "queries"
@@ -41,18 +41,18 @@ const screenpipe = async (conf) => {
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, "start_time": "2024-07-21T11:30:25Z", "end_time": "2024-07-21T11:35:25Z"},
+ {"q": "stripe", "offset": 0, "limit": 50, "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"},
+ {"q": "customer", "offset": 0, "limit": 20, "start_time": "2024-07-19T08:00:25Z", "end_time": "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, "start_time": "2024-07-21T11:30:25Z", "end_time": "2024-07-21T11:35:25Z"},
+ {"q": "customer", "offset": 0, "limit": 20, "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"},
+ {"q": "goal", "offset": 0, "limit": 10, "start_time": "2024-07-19T08:00:25Z", "end_time": "2024-07-20T09:00:25Z"}
]
}"
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index d8a11ebd7..df972e2ae 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -75,17 +75,6 @@ where
s.parse().map_err(serde::de::Error::custom)
}
-#[derive(Deserialize)]
-struct DateRangeQuery {
- #[allow(dead_code)] // TODO
- start_date: Option<DateTime<Utc>>,
- #[allow(dead_code)]
- end_date: Option<DateTime<Utc>>,
- #[serde(flatten)]
- #[allow(dead_code)]
- pagination: PaginationQuery,
-}
-
// Response structs
#[derive(Serialize)]
pub(crate) struct PaginatedResponse<T> {
@@ -623,7 +612,7 @@ curl "http://localhost:3030/search?limit=5&offset=0&content_type=all&start_time=
curl "http://localhost:3030/search?q=test&limit=5&offset=0&content_type=all&end_time=$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ)" | jq
# Search for content between 2 hours ago and 1 hour ago
-curl "http://localhost:3035/search?limit=50&offset=0&content_type=all&start_time=$(date -u -v-2H +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ)" | jq
+curl "http://localhost:3030/search?limit=50&offset=0&content_type=all&start_time=$(date -u -v-2H +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ)" | jq
# Search for OCR content from yesterday
curl "http://localhost:3030/search?limit=5&offset=0&content_type=ocr&start_time=$(date -u -v-1d -v0H -v0M -v0S +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u -v-1d -v23H -v59M -v59S +%Y-%m-%dT%H:%M:%SZ)" | jq
@@ -633,4 +622,23 @@ curl "http://localhost:3030/search?q=libmp3&limit=5&offset=0&content_type=audio&
curl "http://localhost:3030/search?app_name=cursor"
+curl 'http://localhost:3030/search?q=Matt&offset=0&limit=50&start_time=2024-08-12T04%3A00%3A00Z&end_time=2024-08-12T05%3A00%3A00Z' | jq .
+
+
+curl "http://localhost:3030/search?limit=50&offset=0&content_type=all&start_time=$(date -u -v-2H +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ)" | jq
+
+date -u -v-2H +%Y-%m-%dT%H:%M:%SZ
+2024-08-12T06:51:54Z
+date -u -v-1H +%Y-%m-%dT%H:%M:%SZ
+2024-08-12T07:52:17Z
+
+curl 'http://localhost:3030/search?limit=50&offset=0&content_type=all&start_time=2024-08-12T06:48:18Z&end_time=2024-08-12T07:48:34Z' | jq .
+
+
+curl "http://localhost:3030/search?q=Matt&offset=0&limit=10&start_time=2024-08-12T04:00:00Z&end_time=2024-08-12T05:00:00Z&content_type=all" | jq .
+
+curl "http://localhost:3030/search?q=Matt&offset=0&limit=10&start_time=2024-08-12T06:43:53Z&end_time=2024-08-12T08:43:53Z&content_type=all" | jq .
+
+curl 'http://localhost:3030/search?offset=0&limit=10&start_time=2024-08-12T04%3A00%3A00Z&end_time=2024-08-12T05%3A00%3A00Z&content_type=all' | jq .
+
*/