Skip to content
Charles Sanders edited this page Jan 4, 2024 · 1 revision

Welcome to the chatBOT wiki!

persudocode

Project Overview

This project is a web-based chat application that uses Google's Generative AI to simulate conversation with an AI. The application is written in JavaScript and uses the GoogleGenerativeAI library to generate AI responses.

Features

  1. Dynamic Navigation Bars: The application has two navigation bars, one on the left and one on the right. These bars are hidden by default and appear when the mouse is within 250px of the respective edge of the screen.

  2. Chat Interface: The main part of the application is a chat interface. Users can type messages into an input field and press enter or click a send button to submit them. The application then uses Google's Generative AI to generate a response, which is displayed in the chatbox.

  3. Conversation Management: Each conversation is saved in the local storage of the user's browser. Users can start new conversations, and each conversation is associated with a button in the right navigation bar. Clicking on a conversation button displays that conversation in the chatbox. Users can also delete conversations.

  4. AI Response Generation: The application uses the GoogleGenerativeAI library to generate AI responses. This involves sending a request to Google's servers and then processing the response to extract the AI's message.

  5. Auto-clear Chatbox: The chatbox is automatically cleared after 5 seconds of inactivity.

Usage

To use the application, simply type a message into the input field and press enter or click the send button. The AI's response will appear in the chatbox. You can start a new conversation by clicking the 'New Conversation' button, and you can view previous conversations by clicking on their associated buttons in the right navigation bar.

Future Improvements

Future improvements could include the ability to customize the AI's behavior, such as its response speed or the complexity of its responses. Additionally, the UI could be improved with more modern styles and animations.

  1. Import the Library: First, you need to import the GoogleGenerativeAI library into your JavaScript file. You can do this using the import statement at the top of your file:
import { GoogleGenerativeAI } from "https://esm.run/@google/generative-ai";
  1. Initialize the Library: After importing the library, you need to initialize it with your API key. You can get an API key by creating a project in the Google Cloud Console and enabling the Generative AI API for that project. Once you have the API key, you can initialize the library like this:
const API_KEY = "your-api-key-here";
const genAI = new GoogleGenerativeAI(API_KEY);
  1. Use the Library: Now you can use the library to generate AI responses. You first need to get a generative model, and then you can use that model to generate content. Here's an example:
const model = genAI.getGenerativeModel({ model: "gemini-pro"});
const prompt = "Your input here";
const result = await model.generateContent(prompt);
const response = await result.response;
const text = response.text();

In this example, prompt is the input that you want the AI to respond to, and text is the AI's response.

Please note that the GoogleGenerativeAI library and its usage in this context is hypothetical and for illustrative purposes only. As of my knowledge update in September 2021, Google does not provide a Generative AI library. Please check Google's official resources for the most accurate and up-to-date information.

Clone this wiki locally