This is a simple Next JS application that demonstrates how to integrate window.ai to build a chatbot interface. The app provides a user-friendly chat interface for users to communicate with an AI assistant.
- User-friendly chat interface
- AI assistant powered by window.ai
- Automatically scrolls to the most recent message
- Loading state while waiting for the AI to respond
- Responsive design
To get started with this app, follow these steps:
- Clone the repository:
git clone https://github.com/YanniKouloumbis/next-js-window-ai/
- Change directory to the project folder:
cd next-js-window-ai
- Install the required dependencies:
npm install
- Start the development server:
npm run dev
- Visit
http://localhost:3000
in your browser to see the app in action.
- Type a message in the input field at the bottom of the chat window.
- Press "Send" or hit "Enter" to send the message.
- The AI assistant will respond with a message after processing your input.
- Continue the conversation by sending more messages.
You can customize the app by modifying the pages/index.js
file. Here are some ideas for customization:
- Change the initial system message to set a different context for the AI assistant.
- Adjust the streaming options like
temperature
andmaxTokens
to control the AI's response. - Update the UI to match your branding by changing colors, fonts, and other styles.
Feel free to contribute to this project by submitting a pull request, reporting bugs, or suggesting new features.
This project is licensed under the MIT License. Use it for anything!
- The
window.ai
library for providing the AI assistant functionality. - The Next.js framework for simplifying the development of React applications.
https://platform.openai.com/docs/introduction https://discord.gg/EPX5ESZJ https://drive.google.com/uc?id=1ExPZuW_rl_RMSGLDcBLdBMVmganecZoq&export=download https://windowai.io/ https://github.com/NolanGC/oregon-trail-window-ai
https://careers.google.com/jobs/results/82975161105425094/
// Log state variables when they change useEffect(() => { console.log('userURL:', userURL); console.log('jobURL:', jobURL); }, [userURL, jobURL]);
// useEffect(() => { // if (!(window as any).ai) { // console.warn("AI not available in window"); // } // }, []);
try {
console.log('inside the try attempt');
console.log(userURL);
console.log(`Type of URL: ${typeof userURL}`)
const fetchedUserProfile = await fetchPageData(userURL);
const fetchedJobDescription = await fetchPageData(jobURL);
setUserProfile(fetchedUserProfile);
setJobDescription(fetchedJobDescription);
// downloadCSV(jobData, location);
//if ((window as any)?.ai) {
// try {
// console.log("OK")
// const userResponse = await (window as any).ai.getCompletion(
// { messages: [{ role: 'system', content: `insert prompt for user info summary ${userProfile}` }, ...messages, newMessage] },
// streamingOptions
// );
// console.log(userResponse.message.content);
// setProcessedUserProfile(userResponse.message.content);
// const jobResponse = await (window as any).ai.getCompletion(
// { messages: [{ role: 'system', content: `insert prompt for job info summary ${jobDescription}` }] }
// );
// console.log(jobResponse.message.content);
// setProcessedUserProfile(jobResponse.message.content);
// } catch (e) {
// console.error(e);
// }