Skip to content

Commit 125a49b

Browse files
committed
fix: tanchat ai fixups
1 parent 40bf6b6 commit 125a49b

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

src/create-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,6 @@ Use the following commands to start your app:
725725
% cd ${options.projectName}
726726
% ${startCommand}
727727
728-
Please read README.md for more information on testing, styling, adding routes, react-query, etc.${errorStatement}`)
728+
Please read the README.md for more information on testing, styling, adding routes, react-query, etc.${errorStatement}`)
729729
}
730730
}

templates/react/example/tanchat/assets/src/utils/demo.ai.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ export interface Message {
1010
content: string
1111
}
1212

13-
const SYSTEM_PROMPT = `You are TanStack Chat, an AI assistant using Markdown for clear and structured responses.`
13+
const SYSTEM_PROMPT = `You are a helpful assistant for a store that sells guitars.
1414
15-
export const genAIResponse = createServerFn({ method: 'GET', response: 'raw' })
15+
You can use the following tools to help the user:
16+
17+
- getGuitars: Get all guitars from the database
18+
- recommendGuitar: Recommend a guitar to the user
19+
`
20+
21+
export const genAIResponse = createServerFn({ method: 'POST', response: 'raw' })
1622
.validator(
1723
(d: {
1824
messages: Array<Message>
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
import { experimental_createMCPClient, tool } from 'ai'
2+
//import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
23
import { z } from 'zod'
34
import guitars from '../data/example-guitars'
45

5-
// Example of using an MCP server to get tools
6-
// const mcpCient = await experimental_createMCPClient({
6+
// Example of using an SSE MCP server
7+
// const mcpClient = await experimental_createMCPClient({
78
// transport: {
8-
// type: 'stdio',
9+
// type: "sse",
10+
// url: "http://localhost:8081/sse",
11+
// },
12+
// name: "Demo Service",
13+
// });
14+
15+
// Example of using an STDIO MCP server
16+
// const mcpClient = await experimental_createMCPClient({
17+
// transport: new StdioClientTransport({
18+
// command: "node",
919
// args: [
10-
// '--directory',
11-
// '~/mcp/servers/src/sqlite',
12-
// 'run',
13-
// 'mcp-server-sqlite',
14-
// '--db-path',
15-
// '~/sqlite-example/orders.db',
20+
// "stdio-server.js",
1621
// ],
17-
// command: 'uv',
18-
// },
19-
// })
22+
// }),
23+
// });
2024

21-
const getProducts = tool({
25+
const getGuitars = tool({
2226
description: 'Get all products from the database',
2327
parameters: z.object({}),
2428
execute: async () => {
@@ -37,7 +41,7 @@ export default async function getTools() {
3741
// const mcpTools = await mcpCient.tools()
3842
return {
3943
// ...mcpTools,
40-
getProducts,
44+
getGuitars,
4145
recommendGuitar,
4246
}
4347
}

templates/react/example/tanchat/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
"dependencies": {
33
"@ai-sdk/anthropic": "^1.1.17",
44
"@ai-sdk/react": "^1.1.23",
5-
"ai": "^4.1.61",
5+
"ai": "^4.1.65",
66
"highlight.js": "^11.11.1",
77
"react-markdown": "^9.0.1",
88
"rehype-highlight": "^7.0.0",
99
"rehype-raw": "^7.0.0",
1010
"rehype-sanitize": "^6.0.0",
1111
"remark-gfm": "^4.0.1",
12-
"lucide-react": "^0.475.0"
12+
"lucide-react": "^0.475.0",
13+
"zod": "^3.24.2"
1314
}
1415
}

0 commit comments

Comments
 (0)