Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/cf_typecheck_stagehand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Playwright for Cloudflare - Stagehand Typecheck"

on:
pull_request:
paths:
- "packages/playwright-cloudflare/examples/stagehand/**"
- ".github/workflows/cf_typecheck_stagehand.yml"
push:
branches: [main]
paths:
- "packages/playwright-cloudflare/examples/stagehand/**"
- ".github/workflows/cf_typecheck_stagehand.yml"

permissions:
contents: read

jobs:
typecheck:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/playwright-cloudflare/examples/stagehand
env:
WRANGLER_SEND_METRICS: "false"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "24.x"
cache: npm
cache-dependency-path: packages/playwright-cloudflare/examples/stagehand/package-lock.json
- run: npm ci
- run: npx wrangler types
- run: npm run typecheck
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"typecheck": "tsc --noEmit",
"preview": "npm run build && vite preview",
"deploy": "npm run build && wrangler deploy"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type WorkersAIOptions = AiOptions & {
};

const modelId = "@cf/meta/llama-3.3-70b-instruct-fp8-fast";
type ModelInputs = AiModels[typeof modelId]["inputs"];

// Basic implementation of LLMClient for Workers AI.
// This uses @cf/meta/llama-3.3-70b-instruct-fp8-fast model. If you want to
Expand All @@ -29,16 +30,17 @@ export class WorkersAIClient extends LLMClient {
async createChatCompletion<T>({ options }: CreateChatCompletionOptions): Promise<T> {
const schema = options.response_model?.schema;
this.options?.logger?.({ category: "workersai", message: "thinking..." });
const { response } = await this.binding.run(this.modelName as keyof AiModels, {
// Stagehand's message and tool types are broader than the Workers AI declarations.
const inputs = {
messages: options.messages,
// @ts-ignore
tools: options.tools,
response_format: schema ? {
type: "json_schema",
json_schema: zodToJsonSchema(schema),
} : undefined,
temperature: 0,
}, this.options) as AiTextGenerationOutput;
} as unknown as ModelInputs;
const { response } = await this.binding.run(modelId, inputs, this.options) as AiTextGenerationOutput;
this.options?.logger?.({ category: "workersai", message: "completed thinking!" });

return {
Expand Down