-
Notifications
You must be signed in to change notification settings - Fork 628
Issue[#689] Solved #703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Issue[#689] Solved #703
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,8 @@ import { z } from "zod"; | |
import { CreateChatCompletionResponseError } from "@/types/stagehandErrors"; | ||
|
||
function validateZodSchema(schema: z.ZodTypeAny, data: unknown) { | ||
try { | ||
schema.parse(data); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
const result = schema.safeParse(data); | ||
return result.success; | ||
} | ||
Comment on lines
24
to
27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: validateZodSchema could return the error details from safeParse instead of just a boolean for better error reporting |
||
|
||
export class CustomOpenAIClient extends LLMClient { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -177,8 +177,13 @@ export class StagehandExtractHandler { | |||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
const result = { page_text: formattedText }; | ||||||||||||||||||||||||||||||||||||||||
return pageTextSchema.parse(result); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
const res = pageTextSchema.safeParse(result); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if (!res.success) { | ||||||||||||||||||||||||||||||||||||||||
throw new Error(JSON.stringify(res.error.format())); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
return res.data; } | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
179
to
+186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Indentation issue - closing brace of extractPageText() is misaligned
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
private async textExtract<T extends z.AnyZodObject>({ | ||||||||||||||||||||||||||||||||||||||||
instruction, | ||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -369,12 +369,8 @@ export function logLineToString(logLine: LogLine): string { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export function validateZodSchema(schema: z.ZodTypeAny, data: unknown) { | ||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||
schema.parse(data); | ||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||
} catch { | ||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
const result = schema.safeParse(data); | ||||||||||||||||||||||||||
return result.success; | ||||||||||||||||||||||||||
Comment on lines
371
to
+373
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider returning result.error for better error reporting, since safeParse provides detailed validation errors
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export async function drawObserveOverlay(page: Page, results: ObserveResult[]) { | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Error.format() returns a complex object that may not stringify well in the catch block's error logging