Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
1 change: 0 additions & 1 deletion examples/nextjs-ai-chatbot/app/api/chats/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createConfigFromEnv } from '@stream-io/ai-sdk-storage/dist/utils';

const storage = createStreamStorageClient(createConfigFromEnv());


export async function GET(_req: Request, { params }: any) {
const { id } = await params;
try {
Expand Down
16 changes: 8 additions & 8 deletions examples/nextjs-ai-chatbot/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ export const metadata: Metadata = {

export default function RootLayout({ children }: LayoutProps) {
return (
<html lang='en' data-theme='dim'>
<html lang="en" data-theme="dim">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased prose`}
>
<AppProvider>
<div className='grid grid-cols-1 md:grid-cols-[300px_auto] h-screen w-screen'>
<div className='bg-base-200 px-5 py-2 md:relative absolute top-0 bottom-0 translate-x-[-100%] md:translate-x-0 transition-all duration-300'>
<div className="grid grid-cols-1 md:grid-cols-[300px_auto] h-screen w-screen">
<div className="bg-base-200 px-5 py-2 md:relative absolute top-0 bottom-0 translate-x-[-100%] md:translate-x-0 transition-all duration-300">
<Sidebar />
</div>
<div className='flex flex-col h-full relative px-5'>
<div className='w-full mx-auto flex flex-col h-[100vh] gap-2'>
<div className='flex-1 overflow-y-auto'>{children}</div>
<div className='flex-shrink-0 pb-5'>
<div className='max-w-3xl mx-auto'>
<div className="flex flex-col h-full relative px-5">
<div className="w-full mx-auto flex flex-col h-[100vh] gap-2">
<div className="flex-1 overflow-y-auto">{children}</div>
<div className="flex-shrink-0 pb-5">
<div className="max-w-3xl mx-auto">
<Composer />
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions examples/nextjs-ai-chatbot/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Weather from './tools/weather';
export const NonMemoizedMarkdown = ({ children }: { children: string }) => {
const components = {
p: ({ children }: { children: string }) => {
return <div className='no-prose'>{children}</div>;
return <div className="no-prose">{children}</div>;
},
pre: ({ children, ...props }: any) => {
const codeElement = React.Children.only(children);
Expand All @@ -33,21 +33,21 @@ export const NonMemoizedMarkdown = ({ children }: { children: string }) => {
},
ol: ({ node, children, ...props }: any) => {
return (
<ol className='list-decimal list-inside ml-4' {...props}>
<ol className="list-decimal list-inside ml-4" {...props}>
{children}
</ol>
);
},
li: ({ node, children, ...props }: any) => {
return (
<li className='py-1' {...props}>
<li className="py-1" {...props}>
{children}
</li>
);
},
ul: ({ node, children, ...props }: any) => {
return (
<ul className='list-decimal list-inside ml-4' {...props}>
<ul className="list-decimal list-inside ml-4" {...props}>
{children}
</ul>
);
Expand Down
28 changes: 14 additions & 14 deletions examples/nextjs-ai-chatbot/components/messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ export default function Messages() {

if (isLoadingMessages) {
return (
<div className='flex justify-center items-center h-full animate__animated animate__fadeIn'>
<span className='loading loading-spinner loading-md'></span>
<div className="flex justify-center items-center h-full animate__animated animate__fadeIn">
<span className="loading loading-spinner loading-md"></span>
</div>
);
}

if (!id) {
return (
<div className='flex justify-center items-center flex-col h-full '>
<h1 className='animate__animated animate__fadeInUp mb-0 '>
<span className='ai-thinking'>Welcome to AI Assistant</span>
<div className="flex justify-center items-center flex-col h-full ">
<h1 className="animate__animated animate__fadeInUp mb-0 ">
<span className="ai-thinking">Welcome to AI Assistant</span>
</h1>
<p className='animate__animated animate__fadeInUp animate__delay-1s text-gray-500'>
<p className="animate__animated animate__fadeInUp animate__delay-1s text-gray-500">
Ready to help you with any questions or tasks. How can I assist you
today?
</p>
Expand All @@ -44,29 +44,29 @@ export default function Messages() {
}

return (
<div className='py-15 pl-3 max-w-3xl mx-auto space-y-5'>
<div className="py-15 pl-3 max-w-3xl mx-auto space-y-5">
{messages.map((m: UIMessage) => (
<div
key={m.id}
className={`chat animate__animated animate__fadeIn ${
m.role === 'user' ? 'chat-end' : 'chat-start'
}`}
>
<div className='flex gap-2 flex-wrap'>
<div className="flex gap-2 flex-wrap">
{m.parts.map(
(part, index) =>
part.type === 'file' &&
part.url && (
<a
key={'file-' + index + m.id}
href={part.url}
target='_blank'
className='not-prose mb-2'
target="_blank"
className="not-prose mb-2"
>
<Image
src={part.url}
alt={part.filename || 'unknown'}
className='w-30 h-30 rounded-lg object-cover'
className="w-30 h-30 rounded-lg object-cover"
width={300}
height={300}
/>
Expand All @@ -91,9 +91,9 @@ export default function Messages() {
</div>
))}
{status === 'submitted' && (
<div className='flex gap-1 items-center text-sm my-4 animate-pulse'>
<Sparkles className='w-3 h-3 animate-pulse text-[#00ffe0]' />
<span className='ai-thinking'>Thinking</span>
<div className="flex gap-1 items-center text-sm my-4 animate-pulse">
<Sparkles className="w-3 h-3 animate-pulse text-[#00ffe0]" />
<span className="ai-thinking">Thinking</span>
</div>
)}
<div ref={messagesEndRef} />
Expand Down
20 changes: 10 additions & 10 deletions examples/nextjs-ai-chatbot/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export default function Sidebar({ title = 'Chats' }) {
const { id } = useParams();
return (
<>
<h3 className='flex items-center gap-2'>
<MessageSquareText className='w-5 h-5' /> {title}
<h3 className="flex items-center gap-2">
<MessageSquareText className="w-5 h-5" /> {title}
</h3>
<div className='animate__animated animate__fadeIn relative'>
<div className="animate__animated animate__fadeIn relative">
{chats?.length > 0 ? (
chats.map((chat: ChatType) => (
<Link
Expand All @@ -25,23 +25,23 @@ export default function Sidebar({ title = 'Chats' }) {
id === chat.id ? 'text-primary' : ''
}`}
>
<div className='flex items-center gap-1 min-w-0'>
<Dot className='flex-shrink-0' />
<span className='truncate'>{chat.name}</span>
<div className="flex items-center gap-1 min-w-0">
<Dot className="flex-shrink-0" />
<span className="truncate">{chat.name}</span>
</div>
</Link>
))
) : (
<div className='flex items-center gap-2 text-gray-600'>
<div className="flex items-center gap-2 text-gray-600">
No chats found
</div>
)}
</div>
<Link
href='/'
className='mb-2 btn btn-default btn-soft left-4 right-4 absolute bottom-2'
href="/"
className="mb-2 btn btn-default btn-soft left-4 right-4 absolute bottom-2"
>
<MessageSquarePlus className='w-4 h-4' />
<MessageSquarePlus className="w-4 h-4" />
New Chat
</Link>
</>
Expand Down
18 changes: 9 additions & 9 deletions examples/nextjs-ai-chatbot/components/tools/weather.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { CloudSunIcon, MapPinIcon } from 'lucide-react';
export default function Weather({ data }: { data: string }) {
const weather: WeatherToolResponse = JSON.parse(data);
return (
<div className='bg-base-200 p-4 pb-8 rounded-lg relative overflow-hidden min-w-sm'>
<div className='text-lg font-bold flex items-center gap-2'>
<MapPinIcon className='w-4 h-4' />
<div className="bg-base-200 p-4 pb-8 rounded-lg relative overflow-hidden min-w-sm">
<div className="text-lg font-bold flex items-center gap-2">
<MapPinIcon className="w-4 h-4" />
{weather.location?.name || 'Unknown'}
</div>
<div className='grid grid-cols-[1fr_2fr] gap-4 items-center justify-center my-4 font-bold'>
<div className="grid grid-cols-[1fr_2fr] gap-4 items-center justify-center my-4 font-bold">
<div>
<img
src={weather.current?.condition?.icon}
alt={weather.current?.condition?.text}
className='object-cover not-prose bg-base-100 rounded-lg p-2'
className="object-cover not-prose bg-base-100 rounded-lg p-2"
width={64}
height={64}
/>
Expand All @@ -24,15 +24,15 @@ export default function Weather({ data }: { data: string }) {
<br /> Feels like: {weather.current?.feelslike_c}°C
</div>
</div>
<div className='text-sm text-gray-500'>
<div className="text-sm text-gray-500">
<div>Condition: {weather.current?.condition?.text}</div>
<div>Wind: {weather.current?.wind_kph} km/h</div>
<div>Humidity: {weather.current?.humidity}%</div>
<div>Pressure: {weather.current?.pressure_mb} mb</div>
</div>
<div className='flex items-center gap-1 opacity-50 text-xs absolute bottom-2 right-2 text-[#00ffe0]'>
<CloudSunIcon className='w-3 h-3' />
<span className='ai-thinking'>weather tool</span>
<div className="flex items-center gap-1 opacity-50 text-xs absolute bottom-2 right-2 text-[#00ffe0]">
<CloudSunIcon className="w-3 h-3" />
<span className="ai-thinking">weather tool</span>
</div>
</div>
);
Expand Down
3 changes: 0 additions & 3 deletions examples/nextjs-ai-chatbot/hooks/usetranscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export function useTranscriber(options: Options = {}) {
mr.onstop = handleStop;
mr.start(250);
}

} catch (e: any) {
setError(e?.message || 'Something went wrong');
console.error(e);
Expand Down Expand Up @@ -185,7 +184,6 @@ export function useTranscriber(options: Options = {}) {
});
streamRef.current = stream;
const ctx = new (window.AudioContext ||

(window as any).webkitAudioContext)();
audioCtxRef.current = ctx;

Expand Down Expand Up @@ -216,7 +214,6 @@ export function useTranscriber(options: Options = {}) {
recordingStartedAtRef.current = performance.now();

rafRef.current = requestAnimationFrame(checkSilence);

} catch (e: any) {
setError(e?.message || 'Mic access failed');
console.error(e);
Expand Down
12 changes: 6 additions & 6 deletions examples/react-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ function App() {
return (
<>
<div>
<a href='https://vite.dev' target='_blank'>
<img src={viteLogo} className='logo' alt='Vite logo' />
<a href="https://vite.dev" target="_blank">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter changes, please ignore

<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href='https://react.dev' target='_blank'>
<img src={reactLogo} className='logo react' alt='React logo' />
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className='card'>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className='read-the-docs'>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"@khanacademy/simple-markdown": "^2.1.0",
"linkifyjs": "^4.3.2",
"lodash": "4.17.21",
"react-native-syntax-highlighter": "^2.1.0",
"react-syntax-highlighter": "15.5.0"
},
"devDependencies": {
"@types/lodash": "4.17.20",
"@types/node": "^24",
"@types/react": "19.2.2",
"@types/react-syntax-highlighter": "^15.5.13",
"concurrently": "catalog:",
"react": "19.2.0",
"react-native": "^0.82.1",
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './markdown';
export * from './MarkdownRichText';
export * from './syntax-highlighting';
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Pressable, type PressableProps, Text, View } from 'react-native';
import type { MarkdownComponentProps, RuleRenderFunction } from '../types.ts';
import { MarkdownReactiveScrollView } from '../../components';
// @ts-expect-error need to check what's up with the lib
import SyntaxHighlighter from 'react-native-syntax-highlighter';
import SyntaxHighlighter from '../../syntax-highlighting/SyntaxHighlighter.tsx';
import { type PropsWithChildren, useCallback, useMemo } from 'react';

export const CodeBlockCopyButton = ({
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-sdk/src/markdown/components/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const List = ({

if (item === null) {
return (
<ListRow key={index} style={styles?.listRow} testID='list-item'>
<ListRow key={index} style={styles?.listRow}>
<Bullet
index={node.ordered && indexAfterStart}
style={
Expand All @@ -40,7 +40,7 @@ export const List = ({
const style = isSublistWithinText ? { marginBottom: 0 } : {};

return (
<ListRow key={index} style={styles?.listRow} testID='list-item'>
<ListRow key={index} style={styles?.listRow}>
<Bullet
index={node.ordered && indexAfterStart}
style={
Expand Down
Loading