diff --git a/ui/app/api/roast-video/route.ts b/ui/app/api/roast-video/route.ts new file mode 100644 index 00000000..d063e77a --- /dev/null +++ b/ui/app/api/roast-video/route.ts @@ -0,0 +1,6 @@ +export async function POST(req: Request) { + const { input } = await req.json(); + return new Response( + JSON.stringify({ output: `You sent this message to the server: ${input}` }), + ); +} diff --git a/ui/app/components/stacks/roast-video.tsx b/ui/app/components/stacks/roast-video.tsx new file mode 100644 index 00000000..2fcfd8c3 --- /dev/null +++ b/ui/app/components/stacks/roast-video.tsx @@ -0,0 +1,69 @@ +import { useState } from 'react'; +import { IoSend } from 'react-icons/io5'; +import ReactMarkdown from 'react-markdown'; + +export const ChatWithOpenAIStreaming = () => { + const [inputValue, setInputValue] = useState(''); + const [output, setOutput] = useState(''); + const [loading, setLoading] = useState(false); + + const handleSubmit = async (event: React.FormEvent) => { + event.preventDefault(); + console.log('Submitting:', inputValue); + if (inputValue.trim()) { + setOutput(''); + setLoading(true); + + const response = await fetch('/api/boilerplate-basic', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ input: inputValue }), + }); + const data = await response.json(); + console.log('data', data); + setOutput(data.output); + setLoading(false); + } + }; + return ( +
+
+
+ setInputValue(e.target.value)} + placeholder="Ask anything..." + className="focus:shadow-outline w-full rounded-full border border-gray-400 py-2 pl-4 pr-10 focus:outline-none" + onKeyDown={(e) => { + if (e.key === 'Enter') + handleSubmit(e as unknown as React.FormEvent); + }} + /> + +
+
+
+ {loading ? ( + Generating... + ) : output ? ( + {output} + ) : ( +

Output here...

+ )} +
+
+ ); +}; + +export default ChatWithOpenAIStreaming; diff --git a/ui/public/stack-pictures/roast-video.png b/ui/public/stack-pictures/roast-video.png new file mode 100644 index 00000000..b761b40e Binary files /dev/null and b/ui/public/stack-pictures/roast-video.png differ