Skip to content

Commit

Permalink
Merge pull request #856 from ManishMadan2882/main
Browse files Browse the repository at this point in the history
(mock) adding prompt routes
  • Loading branch information
dartpain authored Feb 16, 2024
2 parents 0e38c67 + 5685f83 commit 8cc5e9d
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion mock-backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const middlewares = jsonServer.defaults();
const localStorage = [];

server.use(middlewares);
server.use(cors({ origin: '*' }))
server.use(cors({ origin: ['*'] }))
server.use(jsonServer.rewriter(routes));

server.use((req, res, next) => {
Expand Down Expand Up @@ -82,6 +82,43 @@ router.render = (req, res) => {
]
)
}
else if (req.url === '/get_prompts' && req.method === 'GET') {
res.status(200).json([
{
"id": "default",
"name": "default",
"type": "public"
},
{
"id": "creative",
"name": "creative",
"type": "public"
},
{
"id": "strict",
"name": "strict",
"type": "public"
}
]);
}
else if (req.url.startsWith('/get_single_prompt') && req.method==='GET') {
const id = req.query.id;
console.log('hre');
if (id === 'creative')
res.status(200).json({
"content": "You are a DocsGPT, friendly and helpful AI assistant by Arc53 that provides help with documents. You give thorough answers with code examples if possible."
})
else if (id === 'strict') {
res.status(200).json({
"content": "You are an AI Assistant, DocsGPT, adept at offering document assistance. \nYour expertise lies in providing answer on top of provided context."
})
}
else {
res.status(200).json({
"content": "You are a helpful AI assistant, DocsGPT, specializing in document assistance, designed to offer detailed and informative responses."
})
}
}
else {
res.status(res.statusCode).jsonp(res.locals.data);
}
Expand Down

0 comments on commit 8cc5e9d

Please sign in to comment.