Skip to content

Commit e7f07d8

Browse files
feat: convert tanchat demo API route to EJS template (#195)
1 parent 7749dd3 commit e7f07d8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

frameworks/react-cra/examples/tanchat/assets/src/routes/demo/api.tanchat.ts renamed to frameworks/react-cra/examples/tanchat/assets/src/routes/demo/api.tanchat.ts.ejs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createFileRoute } from '@tanstack/react-router'
2-
import { anthropic } from '@ai-sdk/anthropic'
3-
import { convertToModelMessages, stepCountIs, streamText } from 'ai'
2+
<% if (addOnEnabled['netlify']) { %>import { createAnthropic } from '@ai-sdk/anthropic'
3+
<% } else { %>import { anthropic } from '@ai-sdk/anthropic'
4+
<% } %>import { convertToModelMessages, stepCountIs, streamText } from 'ai'
45

56
import getTools from '@/utils/demo.tools'
67

@@ -11,7 +12,16 @@ You can use the following tools to help the user:
1112
- getGuitars: Get all guitars from the database
1213
- recommendGuitar: Recommend a guitar to the user
1314
`
14-
15+
<% if (addOnEnabled['netlify']) { %>const anthropic = createAnthropic({
16+
baseURL: process.env.ANTHROPIC_BASE_URL
17+
? `${process.env.ANTHROPIC_BASE_URL}/v1`
18+
: undefined,
19+
apiKey: process.env.ANTHROPIC_API_KEY,
20+
headers: {
21+
'user-agent': 'anthropic/',
22+
},
23+
})
24+
<% } %>
1525
export const Route = createFileRoute('/api/demo-chat')({
1626
server: {
1727
handlers: {
@@ -22,7 +32,7 @@ export const Route = createFileRoute('/api/demo-chat')({
2232
const tools = await getTools()
2333

2434
const result = await streamText({
25-
model: anthropic('claude-3-5-sonnet-latest'),
35+
model: anthropic('<% if (addOnEnabled['netlify']) { %>claude-sonnet-4-5-20250929<% } else { %>claude-3-5-sonnet-latest<% } %>'),
2636
messages: convertToModelMessages(messages),
2737
temperature: 0.7,
2838
stopWhen: stepCountIs(5),

0 commit comments

Comments
 (0)