File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ To run framework integration sketches:
9999Install optional framework dependencies first:
100100
101101``` bash
102- npm install @openai/agents @langchain/openai @langchain/core
102+ npm install @openai/agents @langchain/openai @langchain/core zod
103103```
104104
105105``` bash
Original file line number Diff line number Diff line change 1+ import "dotenv/config" ;
12import { NutrientClient } from "@nutrient-sdk/dws-client-typescript" ;
23import { ChatOpenAI } from "@langchain/openai" ;
34import { tool } from "@langchain/core/tools" ;
5+ import { z } from "zod" ;
6+
7+ const nutrientApiKey = process . env . NUTRIENT_API_KEY ;
8+ if ( ! nutrientApiKey ) {
9+ throw new Error ( "Missing NUTRIENT_API_KEY. Add it to examples/.env before running." ) ;
10+ }
11+
12+ if ( ! process . env . OPENAI_API_KEY ) {
13+ throw new Error ( "Missing OPENAI_API_KEY. Add it to examples/.env before running." ) ;
14+ }
415
516const client = new NutrientClient ( {
6- apiKey : process . env . NUTRIENT_API_KEY ?? "nutr_sk_placeholder" ,
17+ apiKey : nutrientApiKey ,
718} ) ;
819
920const redactEmails = tool (
@@ -14,13 +25,16 @@ const redactEmails = tool(
1425 {
1526 name : "redact_emails" ,
1627 description : "Redact email addresses from a document via Nutrient DWS." ,
28+ schema : z . object ( {
29+ path : z . string ( ) . describe ( "Local path to the input PDF file." ) ,
30+ } ) ,
1731 }
1832) ;
1933
2034async function main ( ) {
2135 const model = new ChatOpenAI ( {
2236 model : "gpt-4.1-mini" ,
23- apiKey : process . env . OPENAI_API_KEY ?? "sk-placeholder" ,
37+ apiKey : process . env . OPENAI_API_KEY ,
2438 } ) ;
2539
2640 const response = await model . bindTools ( [ redactEmails ] ) . invoke (
Original file line number Diff line number Diff line change 1+ import "dotenv/config" ;
12import { NutrientClient } from "@nutrient-sdk/dws-client-typescript" ;
23import { Agent , Runner , tool } from "@openai/agents" ;
34
5+ const nutrientApiKey = process . env . NUTRIENT_API_KEY ;
6+ if ( ! nutrientApiKey ) {
7+ throw new Error ( "Missing NUTRIENT_API_KEY. Add it to examples/.env before running." ) ;
8+ }
9+
10+ if ( ! process . env . OPENAI_API_KEY ) {
11+ throw new Error ( "Missing OPENAI_API_KEY. Add it to examples/.env before running." ) ;
12+ }
13+
414const client = new NutrientClient ( {
5- apiKey : process . env . NUTRIENT_API_KEY ?? "nutr_sk_placeholder" ,
15+ apiKey : nutrientApiKey ,
616} ) ;
717
818const extractText = tool ( {
You can’t perform that action at this time.
0 commit comments