Skip to content

Commit

Permalink
prompt fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sameelarif committed Jan 7, 2025

Verified

This commit was signed with the committer’s verified signature.
1 parent 955b1ef commit 812f926
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/instructions.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ async function example() {
const stagehand = new Stagehand({
...StagehandConfig,
instructions:
"if the users says `secret12345`, click on the 'quickstart' tab. additionally, if the user says to type something, write the translate their input into french and type it.",
"if the users says `secret12345`, click on the 'quickstart' tab. additionally, if the user says to type something, translate their input into french and type it.",
});
await stagehand.init();

11 changes: 7 additions & 4 deletions lib/prompt.ts
Original file line number Diff line number Diff line change
@@ -120,7 +120,9 @@ export function buildActSystemPrompt(
content: [
actSystemPrompt,
buildUserInstructionsString(userProvidedInstructions),
].join("\n\n"),
]
.filter(Boolean)
.join("\n\n"),
};
}

@@ -261,7 +263,7 @@ ONLY print the content using the print_extracted_data tool provided.
const content =
`${baseContent}${contentDetail}\n\n${instructions}\n${toolInstructions}${
additionalInstructions ? `\n\n${additionalInstructions}` : ""
}\n\n${userInstructions}`.replace(/\s+/g, " ");
}${userInstructions ? `\n\n${userInstructions}` : ""}`.replace(/\s+/g, " ");

return {
role: "system",
@@ -365,8 +367,9 @@ export function buildObserveSystemPrompt(

return {
role: "system",
content:
content + "\n\n" + buildUserInstructionsString(userProvidedInstructions),
content: [content, buildUserInstructionsString(userProvidedInstructions)]
.filter(Boolean)
.join("\n\n"),
};
}

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
"example": "npm run build-dom-scripts && tsx examples/example.ts",
"debug-url": "npm run build-dom-scripts && tsx examples/debugUrl.ts",
"external-client": "npm run build-dom-scripts && tsx examples/external_client.ts",
"instructions": "npm run build-dom-scripts && tsx examples/instructions.ts",
"format": "prettier --write .",
"prettier": "prettier --check .",
"prettier:fix": "prettier --write .",

0 comments on commit 812f926

Please sign in to comment.