Skip to content
Draft
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
46 changes: 46 additions & 0 deletions examples/ui-angular/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
__screenshots__/

# System files
.DS_Store
Thumbs.db

# LangGraph API
.langgraph_api
97 changes: 97 additions & 0 deletions examples/ui-angular/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"$schema": "../../node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"example-angular": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "example-angular:build:production"
},
"development": {
"buildTarget": "example-angular:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular/build:extract-i18n"
},
"test": {
"builder": "@angular/build:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
]
}
}
}
}
},
"cli": {
"cache": {
"enabled": false
}
}
}
7 changes: 7 additions & 0 deletions examples/ui-angular/langgraph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"node_version": "22",
"graphs": {
"agent": "./src/agent.mts:graph"
},
"env": ".env"
}
51 changes: 51 additions & 0 deletions examples/ui-angular/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@examples/ui-angular",
"version": "0.0.0",
"scripts": {
"dev": "turbo dev:client dev:server",
"dev:client": "ng serve",
"dev:server": "langgraphjs dev --no-browser",
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"format": "prettier --write src",
"lint": "prettier --check src"
},
"prettier": {
"printWidth": 100,
"singleQuote": true,
"overrides": [
{
"files": "*.html",
"options": {
"parser": "angular"
}
}
]
},
"private": true,
"dependencies": {
"@angular/common": "^20.3.0",
"@angular/compiler": "^20.3.0",
"@angular/core": "^20.3.0",
"@angular/forms": "^20.3.0",
"@angular/platform-browser": "^20.3.0",
"@angular/router": "^20.3.0",
"@langchain/angular": "workspace:*",
"@langchain/core": "^1.0.1",
"@langchain/langgraph": "workspace:*",
"@langchain/langgraph-sdk": "workspace:*",
"@langchain/openai": "^1.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zod": "^3.23.8",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular/build": "^20.3.9",
"@angular/cli": "^20.3.9",
"@angular/compiler-cli": "^20.3.0",
"typescript": "~5.9.2"
}
}
18 changes: 18 additions & 0 deletions examples/ui-angular/src/agent.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { BaseMessage } from "@langchain/core/messages";
import { StateGraph, MessagesZodMeta, START } from "@langchain/langgraph";
import { registry } from "@langchain/langgraph/zod";
import { ChatOpenAI } from "@langchain/openai";
import { z } from "zod/v4";

const llm = new ChatOpenAI({ model: "gpt-4o-mini" });

const schema = z.object({
messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),
});

export const graph = new StateGraph(schema)
.addNode("agent", async ({ messages }) => ({
messages: await llm.invoke(messages),
}))
.addEdge(START, "agent")
.compile();
47 changes: 47 additions & 0 deletions examples/ui-angular/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Component, signal } from '@angular/core';
import { useStream } from '@langchain/angular';
import { FormsModule } from '@angular/forms';
import type { Message } from '@langchain/langgraph-sdk';

@Component({
selector: 'app-root',
imports: [FormsModule],
template: `
<main class="main">
<div>
@for (message of stream.messages(); track message.id) {
<div>{{ message.content }}</div>
}
</div>

<form (ngSubmit)="onSubmit()">
<input type="text" [(ngModel)]="message" name="message" />
<button type="submit">Submit</button>
</form>
</main>
`,
})
export class App {
protected message = signal('');

protected stream = useStream({
assistantId: 'agent',
apiUrl: 'http://localhost:2024',
});

protected onSubmit() {
const newMessage = { content: this.message(), type: 'human' };
this.stream.submit(
{ messages: [newMessage] },
{
optimisticValues: (prev) => ({
...prev,
messages: [...((prev['messages'] ?? []) as Message[]), newMessage],
}),
}
);

// reset form
this.message.set('');
}
}
13 changes: 13 additions & 0 deletions examples/ui-angular/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ExampleAngular</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>
10 changes: 10 additions & 0 deletions examples/ui-angular/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
import { App } from './app';

bootstrapApplication(App, {
providers: [
provideBrowserGlobalErrorListeners(),
provideZoneChangeDetection({ eventCoalescing: true }),
],
}).catch((err) => console.error(err));
1 change: 1 addition & 0 deletions examples/ui-angular/src/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */
15 changes: 15 additions & 0 deletions examples/ui-angular/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/*.spec.ts"
]
}
34 changes: 34 additions & 0 deletions examples/ui-angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"compileOnSave": false,
"compilerOptions": {
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"isolatedModules": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "ES2022",
"module": "preserve"
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"typeCheckHostBindings": true,
"strictTemplates": true
},
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
14 changes: 14 additions & 0 deletions examples/ui-angular/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.ts"
]
}
28 changes: 28 additions & 0 deletions examples/ui-angular/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": [
"//"
],
"tasks": {
"build": {
"outputs": [
"**/dist/**"
]
},
"build:internal": {
"dependsOn": [
"^build:internal"
],
"outputs": [
"**/dist/**"
]
},
"dev:client": {
"cache": false,
"persistent": true
},
"dev:server": {
"cache": false,
"persistent": true
}
}
}
3 changes: 3 additions & 0 deletions examples/ui-svelte/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# LangGraph API
.langgraph_api
Loading
Loading