// chat.js const express = require('express'); const bodyParser = require('body-parser'); const LangChain = require('langchain'); // Stellen Sie sicher, dass Sie die LangChain-Bibliothek installiert haben const app = express(); app.use(bodyParser.json()); // Erstellen des LangChain-Modells const llm = LangChain.CTransformers({ model: 'TheBloke/CodeLlama-7B-GGUF', model_type: 'llama', max_new_tokens: 1096, temperature: 0.2, repetition_penalty: 1.13, gpu_layers: 2 }); // API-Endpunkt für Chatbot-Anfragen app.post('/chatbot', async (req, res) => { const userQuery = req.body.query; if (!userQuery) { return res.status(400).send({ error: 'Query is required' }); } try { const response = await llm.run({query: userQuery}); res.send({ reply: response }); } catch (error) { res.status(500).send({ error: 'Error processing request' }); } }); // Starten des Servers const PORT = 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); });