Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 3d715e2

Browse files
authored
Merge pull request #42 from picahq/fix/execute-tool-custom-headers
fix: custom headers in execute tool
2 parents 6d2794d + b8441cf commit 3d715e2

File tree

7 files changed

+17
-6
lines changed

7 files changed

+17
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@picahq/ai",
3-
"version": "2.7.0",
3+
"version": "2.8.0",
44
"description": "Pica AI SDK for Vercel AI SDK integration",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -32,4 +32,4 @@
3232
"typescript": "^5.7.3"
3333
},
3434
"type": "commonjs"
35-
}
35+
}

src/pica.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ ${this.system.trim()}
362362
requestConfig: RequestConfig;
363363
}> {
364364
try {
365-
const newHeaders = {
365+
const allHeaders = {
366366
...this.generateHeaders(),
367367
'x-pica-connection-key': connectionKey,
368368
'x-pica-action-id': actionId,
@@ -371,12 +371,19 @@ ${this.system.trim()}
371371
...headers
372372
};
373373

374+
// Remove Content-Type header if no data is being sent
375+
const finalHeaders = !data
376+
? Object.entries(allHeaders)
377+
.filter(([key]) => key.toLowerCase() !== 'content-type')
378+
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})
379+
: allHeaders;
380+
374381
const url = `${this.baseUrl}/v1/passthrough${path.startsWith('/') ? path : '/' + path}`;
375382

376383
const requestConfig: RequestConfig = {
377384
url,
378385
method,
379-
headers: newHeaders,
386+
headers: finalHeaders,
380387
params: queryParams
381388
};
382389

src/prompts/defaultSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Your capabilities must be used in this exact sequence FOR EACH EXECUTION:
6161
* data: The request payload (optional)
6262
* pathVariables: Values for path variables (if needed)
6363
* queryParams: Query parameters (if needed)
64+
* headers: Headers (if needed)
6465
* isFormData: Set to true to send data as multipart/form-data
6566
* isFormUrlEncoded: Set to true to send data as application/x-www-form-urlencoded
6667

src/prompts/defaultSystemWithAuthkit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const getDefaultSystemWithAuthkitPrompt = (connectionsInfo: string, avail
7676
* data: The request payload (optional)
7777
* pathVariables: Values for path variables (if needed)
7878
* queryParams: Query parameters (if needed)
79+
* headers: Headers (if needed)
7980
* isFormData: Set to true to send data as multipart/form-data
8081
* isFormUrlEncoded: Set to true to send data as application/x-www-form-urlencoded
8182

src/prompts/knowledgeAgentSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ You MUST follow this exact sequence for EACH EXECUTION:
107107
* data: Request payload (optional)
108108
* pathVariables: Values for path variables (if needed)
109109
* queryParams: Query parameters (if needed)
110+
* headers: Headers (if needed)
110111
* isFormData: Set to true for multipart/form-data
111112
* isFormUrlEncoded: Set to true for application/x-www-form-urlencoded
112113

src/prompts/knowledgeAgentWithAuthkitSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ You MUST follow this exact sequence for EACH EXECUTION:
129129
* data: Request payload (optional)
130130
* pathVariables: Values for path variables (if needed)
131131
* queryParams: Query parameters (if needed)
132+
* headers: Headers (if needed)
132133
* isFormData: Set to true for multipart/form-data
133134
* isFormUrlEncoded: Set to true for application/x-www-form-urlencoded
134135

0 commit comments

Comments
 (0)