forked from JawherKl/ai-models-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.mjs
More file actions
25 lines (24 loc) · 717 Bytes
/
Copy pathserver.mjs
File metadata and controls
25 lines (24 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import express from "express";
import { semanticSearch } from "./search.mjs";
import { analyzeData } from "./analyze.mjs";
const app = express();
app.use(express.json());
app.post("/search", async (req, res) => {
try {
const result = await semanticSearch(req.body.query, req.body.model);
res.json({ result });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.post("/analyze", async (req, res) => {
try {
const analysis = await analyzeData(req.body.text, req.body.model);
res.json({ analysis });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(3000, () => {
console.log("Server running on http://localhost:3000");
});