Skip to content

Commit 30e4d1f

Browse files
committed
add cardano course and include sources in ai chat
1 parent 41b16f0 commit 30e4d1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3018
-91
lines changed

apps/docs/.env.example

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
1-
# Mimir RAG backend configuration
2-
MIMIR_BASE_URL=http://localhost:3000
3-
MIMIR_API_KEY=your-api-key-here
4-
5-
# SEO Verification Codes (Optional - Add when ready)
6-
# Get these from respective webmaster tools:
7-
# Google Search Console: https://search.google.com/search-console
8-
# Bing Webmaster Tools: https://www.bing.com/webmasters
9-
# Yandex Webmaster: https://webmaster.yandex.com
10-
11-
NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION=
12-
NEXT_PUBLIC_BING_SITE_VERIFICATION=
13-
NEXT_PUBLIC_YANDEX_SITE_VERIFICATION=
1+
BACKEND_BASE_URL=http://localhost:3000/v1
2+
API_KEY=your-api-key-here

apps/docs/app/api/chat/route.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
export const runtime = 'edge';
2+
3+
const apiKey = process.env.API_KEY;
4+
const backendUrl = process.env.BACKEND_BASE_URL;
5+
6+
export async function POST(req: Request) {
7+
try {
8+
const body = await req.json();
9+
10+
const response = await fetch(`${backendUrl}/chat/completions`, {
11+
method: 'POST',
12+
headers: {
13+
'Content-Type': 'application/json',
14+
'Authorization': `Bearer ${apiKey}`,
15+
},
16+
body: JSON.stringify({
17+
...body,
18+
stream: true,
19+
}),
20+
});
21+
22+
if (!response.ok) {
23+
return new Response(
24+
JSON.stringify({
25+
error: `Backend error: ${response.status} ${response.statusText}`
26+
}),
27+
{
28+
status: response.status,
29+
headers: { 'Content-Type': 'application/json' }
30+
}
31+
);
32+
}
33+
34+
return new Response(response.body, {
35+
headers: {
36+
'Content-Type': 'text/event-stream',
37+
'Cache-Control': 'no-cache',
38+
'Connection': 'keep-alive',
39+
},
40+
});
41+
} catch (error) {
42+
console.error('API route error:', error);
43+
return new Response(
44+
JSON.stringify({ error: 'Internal server error' }),
45+
{
46+
status: 500,
47+
headers: { 'Content-Type': 'application/json' }
48+
}
49+
);
50+
}
51+
}

apps/docs/app/api/chat/routes.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

apps/docs/app/layout.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ export const metadata: Metadata = {
6565
type: 'website',
6666
locale: 'en_US',
6767
url: 'https://meshjs.dev',
68-
siteName: 'Mesh - Cardano TypeScript SDK',
69-
title: 'Mesh - Open-Source TypeScript SDK for Cardano Blockchain Development',
70-
description: 'Ship UTXO dApps faster with Mesh. The open-source TypeScript SDK for Cardano blockchain development with React components, wallet integrations, and transaction builders. Trusted by 1M+ downloads.',
68+
siteName: 'Mesh SDK',
69+
title: 'Mesh - TypeScript SDK for Cardano Blockchain',
70+
description: 'Open-source TypeScript SDK for Cardano. Build dApps faster with React components, wallet integrations & transaction builders. 1M+ downloads.',
7171
images: [
7272
{
73-
url: '/home/hero.png',
74-
width: 1200,
75-
height: 630,
76-
alt: 'Mesh - TypeScript SDK for Cardano - Build dApps faster',
73+
url: 'https://meshjs.dev/logo-mesh/mesh.png',
74+
width: 1000,
75+
height: 500,
76+
alt: 'Mesh SDK - Build Cardano dApps faster',
7777
type: 'image/png',
7878
},
7979
],
@@ -82,9 +82,9 @@ export const metadata: Metadata = {
8282
card: 'summary_large_image',
8383
site: '@meshsdk',
8484
creator: '@meshsdk',
85-
title: 'Mesh - Open-Source TypeScript SDK for Cardano',
86-
description: 'Ship UTXO dApps faster with Mesh. Less than 60kB, production-ready, with 1M+ downloads. Build Cardano blockchain applications with TypeScript.',
87-
images: ['/home/hero.png'],
85+
title: 'Mesh - TypeScript SDK for Cardano Blockchain',
86+
description: 'Open-source TypeScript SDK for Cardano. Build dApps faster with React components & transaction builders. 1M+ downloads.',
87+
images: ['https://meshjs.dev/logo-mesh/mesh.png'],
8888
},
8989
icons: {
9090
icon: '/favicon.ico',

apps/docs/components/ai/search.tsx

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,30 @@ const roleName: Record<string, string> = {
213213

214214
function Message({
215215
message,
216+
isStreaming,
216217
...props
217-
}: { message: UIMessage } & ComponentProps<'div'>) {
218+
}: { message: UIMessage; isStreaming?: boolean } & ComponentProps<'div'>) {
218219
let markdown = '';
219-
let links: z.infer<typeof ProvideLinksToolSchema>['links'] = [];
220+
let sources: Array<{ url: string; title?: string; sourceId: string }> = [];
220221

221222
for (const part of message.parts ?? []) {
222223
if (part.type === 'text') {
223224
markdown += part.text;
224225
continue;
225226
}
226227

227-
if (part.type === 'tool-provideLinks' && part.input) {
228-
links = (part.input as z.infer<typeof ProvideLinksToolSchema>).links;
228+
if (part.type === 'source-url') {
229+
sources.push({
230+
url: part.url,
231+
title: part.title,
232+
sourceId: part.sourceId
233+
});
229234
}
230235
}
231236

237+
// Only show sources if message is not currently streaming (i.e., completed)
238+
const showSources = !isStreaming;
239+
232240
return (
233241
<div {...props}>
234242
<p
@@ -244,29 +252,34 @@ function Message({
244252
<div className="prose text-sm">
245253
<Markdown text={markdown} />
246254
</div>
247-
{links && links.length > 0 ? (
255+
{showSources && sources.length > 0 && (
248256
<div className="mt-2 flex flex-row flex-wrap items-center gap-1">
249-
{links.map((item, i) => (
257+
{sources.map((source, i) => (
250258
<Link
251-
key={i}
252-
href={item.url}
259+
key={source.sourceId || i}
260+
href={source.url}
253261
className="block text-xs rounded-lg border p-3 hover:bg-fd-accent hover:text-fd-accent-foreground"
254262
>
255-
<p className="font-medium">{item.title}</p>
256-
<p className="text-fd-muted-foreground">Reference {item.label}</p>
263+
<p className="font-medium">{source.title || 'Source'}</p>
264+
<p className="text-fd-muted-foreground">Reference {i + 1}</p>
257265
</Link>
258266
))}
259267
</div>
260-
) : null}
268+
)}
261269
</div>
262270
);
263271
}
264272

265273
export function AISearch(props: DialogProps) {
274+
const apiUrl = '/api/chat';
275+
266276
const chat = useChat({
267277
id: 'search',
268278
transport: new DefaultChatTransport({
269-
api: '/api/chat',
279+
api: apiUrl,
280+
body: {
281+
stream: true,
282+
},
270283
}),
271284
messages: getInitialChatHistory()
272285
});
@@ -321,8 +334,12 @@ export function AISearch(props: DialogProps) {
321334
}}
322335
>
323336
<div className="flex flex-col gap-4 p-3">
324-
{messages.map((item) => (
325-
<Message key={item.id} message={item} />
337+
{messages.map((item, index) => (
338+
<Message
339+
key={item.id}
340+
message={item}
341+
isStreaming={index === messages.length - 1 && (chat.status === 'streaming' || chat.status === 'submitted')}
342+
/>
326343
))}
327344
</div>
328345
</List>
@@ -348,10 +365,15 @@ export function AISearch(props: DialogProps) {
348365

349366

350367
export function MobileAISearch(props: DialogProps) {
368+
const apiUrl = '/api/chat';
369+
351370
const chat = useChat({
352371
id: 'search',
353372
transport: new DefaultChatTransport({
354-
api: '/api/chat',
373+
api: apiUrl,
374+
body: {
375+
stream: true,
376+
},
355377
}),
356378
messages: getInitialChatHistory()
357379
});
@@ -407,8 +429,12 @@ export function MobileAISearch(props: DialogProps) {
407429
className='max-h-[calc(100dvh-240px)]'
408430
>
409431
<div className="flex flex-col gap-4 p-3">
410-
{messages.map((item) => (
411-
<Message key={item.id} message={item} />
432+
{messages.map((item, index) => (
433+
<Message
434+
key={item.id}
435+
message={item}
436+
isStreaming={index === messages.length - 1 && (chat.status === 'streaming' || chat.status === 'submitted')}
437+
/>
412438
))}
413439
</div>
414440
</List>

apps/docs/components/ui/Footer.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {linksApi} from "@/data/links-api";
44
import {metaGuides} from "@/data/links-guides";
55
import {metaSolutions} from "@/data/links-solutions";
66
import {metaResources} from "@/data/links-resources";
7+
import {metaCourse} from "@/data/links-course";
78
import {linksAbout} from "@/data/links-about";
89

910
export default function Footer() {
@@ -70,6 +71,15 @@ export default function Footer() {
7071
}
7172
</div>
7273

74+
<div className='flex flex-col gap-3 [&>a]:hover:underline' key={metaCourse.link}>
75+
<Link href={metaCourse.link} className='font-bold'>{metaCourse.title.toUpperCase()}</Link>
76+
{
77+
"items" in metaCourse && metaCourse.items.map((item) => (
78+
<Link href={item.link} key={item.link}>{item.title}</Link>
79+
))
80+
}
81+
</div>
82+
7383
{/* About Mesh */}
7484
<div className='flex flex-col gap-3 [&>a]:hover:underline'>
7585
<div className='font-bold'>ABOUT MESH</div>

apps/docs/content/docs/apis/txbuilder/minting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In this page, you will find the APIs to create transactions for minting and burn
2525

2626
## Minting with One Signature
2727

28-
In this section, we will see how to mint native assets with a `MeshTxBuilder`. For minting assets with a smart contract visit [this documentation](https://meshjs.dev/apis/txbuilder/smart-contracts#minting-assets-with-plutus-script).
28+
In this section, we will see how to mint native assets with a `MeshTxBuilder`. For minting assets with a smart contract visit [this documentation](/apis/txbuilder/smart-contracts#minting-assets-with-plutus-script).
2929

3030
Firstly, we need to define the `forgingScript` with `ForgeScript`. We use the first wallet address as the "minting address" (you can use other addresses).
3131

apps/docs/content/docs/guides/index.mdx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ import {
1313
} from "@/components/ui/card";
1414

1515
<div className="grid md:grid-cols-2 gap-6 items-stretch">
16-
{linksGuides.map((card) => (
17-
<Link key={card.title} href={card.link} className="no-underline">
18-
<Card className="h-full text-center hover:border-primary/50 transition-colors px-4 py-8">
19-
<CardTitle className="font-heading">{card.title}</CardTitle>
20-
<CardDescription>{card.desc}</CardDescription>
21-
</Card>
22-
</Link>
23-
))}
16+
{linksGuides.map((card) => {
17+
const Icon = card.icon;
18+
return (
19+
<Link key={card.title} href={card.link} className="no-underline">
20+
<Card className="h-full text-center hover:border-primary/50 transition-colors px-4 py-8">
21+
{Icon && (
22+
<div className="flex justify-center mb-4">
23+
<Icon className="w-12 h-12 text-primary" />
24+
</div>
25+
)}
26+
<CardTitle className="font-heading">{card.title}</CardTitle>
27+
<CardDescription>{card.desc}</CardDescription>
28+
</Card>
29+
</Link>
30+
);
31+
})}
2432
</div>
2533

apps/docs/content/docs/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"title": "Documentation",
3-
"pages": ["./apis/wallets", "./apis/txbuilder", "./apis/txparser", "providers", "./apis/utilities", "react", "svelte", "smart-contracts", "aiken", "hydra", "midnight", "yaci", "guides"]
3+
"pages": ["./apis/wallets", "./apis/txbuilder", "./apis/txparser", "providers", "./apis/utilities", "react", "svelte", "smart-contracts", "aiken", "hydra", "midnight", "yaci", "resources"]
44
}

apps/docs/content/docs/providers/hydra.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Hydra Provider (beta)"
3-
desceription: "Layer 2 scaling solution for Cardano that increases transaction throughput and ensures cost efficiency while maintaining security."
3+
description: "Layer 2 scaling solution for Cardano that increases transaction throughput and ensures cost efficiency while maintaining security."
44
---
55

66
import Link from "fumadocs-core/link";

0 commit comments

Comments
 (0)