import express from 'express';
const app = express();
app.use(express.json());
app.get('/', (req, res) => {
res.send(`
Hermes AI Agent
Hermes AI Agent
`);
});
app.post('/api/chat', async (req, res) => {
try {
const response = await fetch('http://127.0.0.1:11434/api/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'hermes3',
prompt: req.body.message,
stream: false
})
});
const data = await response.json();
res.json({ reply: data.response });
} catch (err) {
res.status(500).json({ reply: 'Gagal terhubung ke model Hermes.' });
}
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log('Server running'));