Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 870e98b

Browse files
committed
update examples
1 parent cc9c86f commit 870e98b

16 files changed

Lines changed: 108 additions & 14 deletions

File tree

.github/workflows/ci-typescript.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ on:
1515
permissions:
1616
contents: read
1717

18-
defaults:
19-
run:
20-
working-directory: typescript
21-
2218
jobs:
2319
lint-test:
2420
name: Lint + Test (Node ${{ matrix.node }})
2521
runs-on: ubuntu-latest
22+
defaults:
23+
run:
24+
working-directory: typescript
2625
strategy:
2726
fail-fast: false
2827
matrix:
@@ -54,3 +53,35 @@ jobs:
5453

5554
- name: Verify packed artifact
5655
run: npm pack --dry-run
56+
57+
type-check-examples:
58+
name: Type-check example (${{ matrix.example }})
59+
runs-on: ubuntu-latest
60+
needs: lint-test
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
example: [langchain, mastra, mcp, strands, vercel-ai]
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Set up Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: '22'
72+
cache: 'npm'
73+
cache-dependency-path: typescript/package-lock.json
74+
75+
- name: Build SDK (populates typescript/dist for file: deps)
76+
working-directory: typescript
77+
run: |
78+
npm ci
79+
npm run build
80+
81+
- name: Install example dependencies
82+
working-directory: typescript/examples/${{ matrix.example }}
83+
run: npm install --no-package-lock
84+
85+
- name: Type-check example
86+
working-directory: typescript/examples/${{ matrix.example }}
87+
run: npx tsc --noEmit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ typescript/node_modules/
5151
typescript/dist/
5252
typescript/.tsbuildinfo
5353
typescript/docs-api/
54+
typescript/examples/*/node_modules/
55+
typescript/examples/*/package-lock.json
5456

5557
# Build outputs
5658
*.log

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help install install-all install-dev lint format typecheck test test-unit test-integration test-integration-mcp test-e2e test-all test-docker test-ci test-no-docker test-quick test-file test-match test-aws test-nams-unit test-nams-integration test-nams coverage coverage-all coverage-ci coverage-mcp test-examples test-examples-quick test-examples-no-neo4j test-docs test-docs-syntax test-docs-build test-docs-links neo4j-start neo4j-stop neo4j-logs clean build publish docs docs-diagrams-list docs-diagrams-status docs-diagrams-missing docs-diagrams-manifest docs-diagrams-add-refs docs-diagrams-generate example-basic example-resolution example-langchain example-pydantic examples chat-agent-install chat-agent-backend chat-agent-frontend chat-agent ts-install ts-build ts-test ts-test-unit ts-test-integration ts-lint ts-docs ts-conformance ts-pack ts-clean
1+
.PHONY: help install install-all install-dev lint format typecheck test test-unit test-integration test-integration-mcp test-e2e test-all test-docker test-ci test-no-docker test-quick test-file test-match test-aws test-nams-unit test-nams-integration test-nams coverage coverage-all coverage-ci coverage-mcp test-examples test-examples-quick test-examples-no-neo4j test-docs test-docs-syntax test-docs-build test-docs-links neo4j-start neo4j-stop neo4j-logs clean build publish docs docs-diagrams-list docs-diagrams-status docs-diagrams-missing docs-diagrams-manifest docs-diagrams-add-refs docs-diagrams-generate example-basic example-resolution example-langchain example-pydantic examples chat-agent-install chat-agent-backend chat-agent-frontend chat-agent ts-install ts-build ts-test ts-test-unit ts-test-integration ts-lint ts-docs ts-conformance ts-pack ts-clean ts-test-examples
22

33
# Default target
44
help:
@@ -643,3 +643,14 @@ ts-pack:
643643
# Remove TS build artifacts
644644
ts-clean:
645645
rm -rf $(TS_DIR)/dist $(TS_DIR)/docs-api $(TS_DIR)/.tsbuildinfo
646+
647+
# Type-check every TS example against the freshly built SDK. Catches
648+
# API drift between examples and the SDK without needing API keys.
649+
# Mirrors the ci-typescript.yml type-check-examples matrix.
650+
ts-test-examples:
651+
cd $(TS_DIR) && npm ci && npm run build
652+
@for ex in langchain mastra mcp strands vercel-ai; do \
653+
echo "=== Type-checking $$ex ==="; \
654+
(cd $(TS_DIR)/examples/$$ex && npm install --no-package-lock && npx tsc --noEmit) || exit 1; \
655+
done
656+
@echo "All TS examples type-check cleanly."

typescript/examples/langchain/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"start": "tsx src/index.ts"
88
},
99
"dependencies": {
10-
"@neo4j-labs/agent-memory": "file:.."
10+
"@neo4j-labs/agent-memory": "file:../.."
1111
},
1212
"devDependencies": {
13+
"@types/node": "^20.0.0",
1314
"tsx": "^4.0.0",
14-
"@types/node": "^20.0.0"
15+
"typescript": "^5.9.3"
1516
}
1617
}

typescript/examples/langchain/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222

2323
console.log("Persisting messages via Neo4jChatMessageHistory ...");
2424
await history.addUserMessage("Tell me about graph databases.");
25-
await history.addAIMessage(
25+
await history.addAIChatMessage(
2626
"Graph databases store data as nodes and relationships, making path queries fast.",
2727
);
2828
await history.addUserMessage("How does that compare to relational?");
@@ -37,7 +37,7 @@ async function main() {
3737
await memory.longTerm.addEntity("Neo4j", "concept", {
3838
description: "Graph database; mentioned in this demo.",
3939
});
40-
const retriever = new Neo4jEntityRetriever(memory, { limit: 3 });
40+
const retriever = new Neo4jEntityRetriever(memory, { topK: 3 });
4141
const docs = await retriever.invoke("graph database");
4242
console.log(`Found ${docs.length} entity-shaped documents.`);
4343
for (const d of docs) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"include": ["src/**/*"]
4+
}

typescript/examples/mastra/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"start": "tsx src/index.ts"
88
},
99
"dependencies": {
10-
"@neo4j-labs/agent-memory": "file:.."
10+
"@neo4j-labs/agent-memory": "file:../.."
1111
},
1212
"devDependencies": {
1313
"tsx": "^4.0.0",
14+
"typescript": "^5.5.0",
1415
"@types/node": "^20.0.0"
1516
}
1617
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"include": ["src/**/*"]
4+
}

typescript/examples/mcp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"start": "tsx src/index.ts"
88
},
99
"dependencies": {
10-
"@neo4j-labs/agent-memory": "file:..",
10+
"@neo4j-labs/agent-memory": "file:../..",
1111
"@modelcontextprotocol/sdk": "^1.0.0"
1212
},
1313
"devDependencies": {
1414
"tsx": "^4.0.0",
15+
"typescript": "^5.5.0",
1516
"@types/node": "^20.0.0"
1617
}
1718
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"include": ["src/**/*"]
4+
}

0 commit comments

Comments
 (0)