@browserbasehq/stagehand
Advanced tools
Comparing version 1.7.0-alpha-55f0cd2fe7976e800833ec6e41e9af62d88d09d5 to 1.7.0-alpha-6b366a9e06b8cf59452cd91d3f3dbc8d6d87c0db
@@ -182,2 +182,3 @@ import { Page, BrowserContext, Browser } from '@playwright/test'; | ||
domSettleTimeoutMs?: number; | ||
useTextExtract?: boolean; | ||
} | ||
@@ -184,0 +185,0 @@ type ExtractResult<T extends z.AnyZodObject> = z.infer<T>; |
@@ -8,3 +8,3 @@ import OpenAI from "openai"; | ||
export declare const actTools: Array<OpenAI.ChatCompletionTool>; | ||
export declare function buildExtractSystemPrompt(isUsingPrintExtractedDataTool?: boolean): ChatMessage; | ||
export declare function buildExtractSystemPrompt(isUsingPrintExtractedDataTool?: boolean, useTextExtract?: boolean): ChatMessage; | ||
export declare function buildExtractUserPrompt(instruction: string, domElements: string, isUsingPrintExtractedDataTool?: boolean): ChatMessage; | ||
@@ -11,0 +11,0 @@ export declare function buildRefineSystemPrompt(): ChatMessage; |
@@ -9,2 +9,3 @@ import { EvalLogger } from "../evals/utils"; | ||
logger: EvalLogger; | ||
useTextExtract: boolean; | ||
}) => Promise<{ | ||
@@ -17,3 +18,3 @@ _success: boolean; | ||
}>; | ||
export declare const EvalCategorySchema: z.ZodEnum<["observe", "act", "combination", "extract", "experimental"]>; | ||
export declare const EvalCategorySchema: z.ZodEnum<["observe", "act", "combination", "extract", "experimental", "text_extract"]>; | ||
export type EvalCategory = z.infer<typeof EvalCategorySchema>; | ||
@@ -20,0 +21,0 @@ export interface EvalInput { |
@@ -65,2 +65,3 @@ import Browserbase from "@browserbasehq/sdk"; | ||
domSettleTimeoutMs?: number; | ||
useTextExtract?: boolean; | ||
} | ||
@@ -67,0 +68,0 @@ export type ExtractResult<T extends z.AnyZodObject> = z.infer<T>; |
@@ -225,3 +225,3 @@ import Anthropic, { ClientOptions } from "@anthropic-ai/sdk"; | ||
model: this.modelName, | ||
max_tokens: options.maxTokens || 1500, | ||
max_tokens: options.maxTokens || 8192, | ||
messages: formattedMessages, | ||
@@ -228,0 +228,0 @@ tools: anthropicTools, |
@@ -204,19 +204,43 @@ import OpenAI from "openai"; | ||
// extract | ||
const extractSystemPrompt = `You are extracting content on behalf of a user. You will be given: | ||
export function buildExtractSystemPrompt( | ||
isUsingPrintExtractedDataTool: boolean = false, | ||
useTextExtract: boolean = true, | ||
): ChatMessage { | ||
const baseContent = `You are extracting content on behalf of a user. | ||
If a user asks you to extract a 'list' of information, or 'all' information, | ||
YOU MUST EXTRACT ALL OF THE INFORMATION THAT THE USER REQUESTS. | ||
You will be given: | ||
1. An instruction | ||
2. A list of DOM elements to extract from | ||
2. `; | ||
Print the exact text from the DOM elements with all symbols, characters, and endlines as is. | ||
const contentDetail = useTextExtract | ||
? `A text representation of a webpage to extract information from.` | ||
: `A list of DOM elements to extract from.`; | ||
const instructions = ` | ||
Print the exact text from the ${ | ||
useTextExtract ? "text-rendered webpage" : "DOM elements" | ||
} with all symbols, characters, and endlines as is. | ||
Print null or an empty string if no new information is found. | ||
`; | ||
`.trim(); | ||
export function buildExtractSystemPrompt( | ||
isUsingPrintExtractedDataTool: boolean = false, | ||
): ChatMessage { | ||
let content = extractSystemPrompt.replace(/\s+/g, " "); | ||
if (isUsingPrintExtractedDataTool) { | ||
content += ` | ||
const toolInstructions = isUsingPrintExtractedDataTool | ||
? ` | ||
ONLY print the content using the print_extracted_data tool provided. | ||
ONLY print the content using the print_extracted_data tool provided.`; | ||
} | ||
ONLY print the content using the print_extracted_data tool provided. | ||
`.trim() | ||
: ""; | ||
const additionalInstructions = useTextExtract | ||
? `Once you are given the text-rendered webpage, | ||
you must thoroughly and meticulously analyze it. Be very careful to ensure that you | ||
do not miss any important information.` | ||
: ""; | ||
const content = | ||
`${baseContent}${contentDetail}\n\n${instructions}\n${toolInstructions}${ | ||
additionalInstructions ? `\n\n${additionalInstructions}` : "" | ||
}`.replace(/\s+/g, " "); | ||
return { | ||
@@ -223,0 +247,0 @@ role: "system", |
{ | ||
"name": "@browserbasehq/stagehand", | ||
"version": "1.7.0-alpha-55f0cd2fe7976e800833ec6e41e9af62d88d09d5", | ||
"version": "1.7.0-alpha-6b366a9e06b8cf59452cd91d3f3dbc8d6d87c0db", | ||
"description": "An AI web browsing framework focused on simplicity and extensibility.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
478792
123
12496