mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-21 16:45:24 -04:00
8e2b8584c5
## Description Updated the `customer_support_small_model.ipynb` example to use non-deprecated API methods and improve TypeScript type safety. ## Changes ### 1. Replace deprecated `_getType()` method - **Before**: `if (trimmedHistory.at(-1)._getType() === "ai")` - **After**: `if (trimmedHistory[trimmedHistory.length - 1].getType() === "ai")` - The `_getType()` method signature is deprecated and should be replaced with `getType()` - Also replaced `.at(-1)` with `[trimmedHistory.length - 1]` to fix TypeScript "possibly undefined" error (ts(2532)) ### 2. Add missing type annotation - **Location**: `addConditionalEdges` callback in `billing_support` node - **Added**: `async (state: typeof StateAnnotation.State) =>` type annotation - Ensures consistency with other conditional edge definitions in the example ## Type of Change - [x] Documentation update - [x] Bug fix (non-breaking change which fixes TypeScript errors) ## Testing - Verified code changes compile without TypeScript errors - Confirmed deprecated method warnings are resolved ## Motivation This PR addresses two issues in the example notebook: 1. **API Deprecation**: The `_getType()` method is deprecated and should be replaced with the public `getType()` API 2. **TypeScript Safety**: Adding explicit type annotations and using safer array access patterns improves type safety and prevents potential runtime errors