ryu-js / index.js
randydev's picture
Update index.js
17f2e27 verified
raw
history blame
1.17 kB
const express = require('express')
const app = express()
const port = 7860
const axios = require('axios')
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.get('/api/test', async (req, res) => {
try {
res.json({message: "Hello world"})
} catch (error) {
res.status(401).json({error: error.message})
}
})
const AkenoXWeb = async (prompt) => {
try {
const payload = {
"prompt": prompt,
"bid": "040d0481"
};
const type_urls = "openai-gpt";
const url = "https://bot-management-4tozrh7z2a-ue.a.run.app/chat/web";
const response = await axios.post(url, payload);
console.log('Response:', response.data);
const output = response.data.answer;
return output;
} catch (error) {
return "Error data" + error.message;
}
};
app.post('/api/akenoweb', async (req, res) => {
try {
const query = req.params.query;
const output = await AkenoXWeb(query);
res.json({ message: output });
} catch (error) {
res.status(401).json({ error: error.message });
}
});
on Hugging face without semicolon works
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})