You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Esse projeto consistiu em usar o modelo LLAMA 2🦙 da Meta, para criar um chatbot com respostas coerentes, utilizando das seguintes tecnologias abaixo:
HTML
CSS
JavaScript
Node.js
•Para criar o ChatBot, a seleção do modelo precisou ser cautelosa, devido há alguns testes não terem ficados tão claros com as repostas dadas pela IA, já que é um modelo recente feito pela Meta, o modelo usado em questão foi o Llama2-7b-Q8,
que é a versão mais recente baseada no modelo 7B, o processo consistiu em baixar o modelo, e transferir para uma pasta chamada Models, onde importamos no nosso arquivo app.js, como houve integração com Front-End juntamente com Back-End devido as regras de negócio,
utilizou-se do framework Express para fazer esse processo de uma forma mais simplificada, o modelo anteriormente foi testado apenas com chamadas de API de um serviço chamado Replicate, porém houve bastante inconsistência nos dados recebidos do modelo hospedado,
devido a isso, optou-se por testar o modelo localmente sem muitos problemas na aplicação
Clique aqui para assistir ao vídeo de teste do modelo (Duração: 3.54)
-Estrutura Back-End (app.js)
importexpressfrom'express';import{fileURLToPath}from'url';importpathfrom'path';import{LlamaModel,LlamaContext,LlamaChatSession}from'node-llama-cpp';importbodyParserfrom'body-parser';constapp=express();constport=3000;constMODEL_NAME='llama-2-7b-chat.Q8_0.gguf';const__filename=fileURLToPath(import.meta.url);const__dirname=path.dirname(__filename);constmodelsDirectory=path.join(__dirname,'../models');constmodelsPath=path.join(modelsDirectory,MODEL_NAME);constmodel=newLlamaModel({modelPath: modelsPath,});constcontext=newLlamaContext({ model });app.use(bodyParser.json());app.use(express.static(path.join(__dirname,'public')));app.get('/',(req,res)=>{res.sendFile(path.join(__dirname,'/public/index.html'));});app.post('/message',async(req,res)=>{constuserMessage=req.body.message;constsession=newLlamaChatSession({ context });constresponse=awaitsession.prompt(userMessage);res.json({text: response,isBot: true,});});app.listen(port,()=>{console.log(`Server is running at http://localhost:${port}`);});