Git Product home page Git Product logo

mern-ai-chatbot's Introduction

Hello, Hope everything is working fine ๐Ÿ˜…

Check appropriate branches.

Check appropriate branches where you need to find the code.

Starting project

Includes base project template for NodeJs, MongoDB, Typescript and Lint

Final

Includes final code. ๐Ÿ˜ƒ

Feel Free to share any doubts or corrections.

mern-ai-chatbot's People

Contributors

nikhilthadani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mern-ai-chatbot's Issues

HI

I want to contribute

Feature req: Please integrate apipie.ai

Users want access to as much AI as they can get, they dont want to manage 50 accounts, they want the fastest AI they want the cheapest AI, and you can provide all of that for them with this update.

in addition to or in place of integrating with any aggregators - Please integrate APIpie so devs can access them all from one place/subscription and plus it also provides:

-The most affordable, reliable and fastest AI available
-One API to access ~500 Models and growing
-Language, embedding, voice, image, vision and more
-Global AI load balancing, route queries based on price or latency
-Redundancy for major models providing the greatest up time possible
-Global reporting of AI availability, pricing and performance

Its the same API format as openai, just change the domain name and your API key and enjoy a plethora of models without changing any of your code other than how you handle the models list.

This is a win win for everyone, any new AI's from any providers will be automatically integrated into your stack with this one integration. Not to mention all the other advantages.

Chat Completion Request Message

Enjoying the tutorial and around 3:48 I was having an error with { ChatCompletionRequestMessage } and { OpenAIApi }. As of January 2024, I have node v21.20 and openai 4.26.00 installed. The following code is updated with the new openai library. Hopefully this is helpful and if there are any errors let me know. Thanks so much! ๐Ÿ‘ ~Lydia

import { NextFunction, Request, Response } from "express";
import User from "../models/User.js";
import { configureOpenAI } from "../config/openai-config.js";
import OpenAI from "openai";

export const generateChatCompletion = async (
req: Request,
res: Response,
next: NextFunction
) => {
const { message } = req.body;
try {
const user = await User.findById(res.locals.jwtData.id);
if (!user)
return res
.status(401)
.json({ message: "User not registered OR Token malfunctioned" });

    // Specify the type for the messages array
    const messages: { role: string; content: string }[] = [
        ...user.chats.map(({ role, content }) => ({ role, content })),
        { content: message, role: "user" },
    ];

    // send all chats with the new one to OpenAI API
    const config = configureOpenAI();
    const openai = new OpenAI({ apiKey: config.apiKey });

    // chat completion response
    const chatCompletion = await openai.chat.completions.create({
        model: "gpt-3.5-turbo",
        messages: [{ role: "system", content: "You are a helpful assistant." }],
    });

    user.chats.push({
        role: "assistant",
        content: chatCompletion.choices[0].message.content,
    });

    await user.save();
    return res.status(200).json({ chats: user.chats });
} catch (error) {
    console.log(error);
    return res.status(500).json({ message: "Something went wrong" });

};
};

Dockerize the app

Hello Nikhilthadani,
I would like to create a docker with this project, my chat bot is finally finished and 'works fine' please can you hrlp me?
Thanks for your time

Gennaro Migliaccio (italy)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.