Skip to content

Commit

Permalink
iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Feb 9, 2024
1 parent c0bd3ed commit 7a30706
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
29 changes: 29 additions & 0 deletions api/src/controllers/discovery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

export const chat = async (req, res, next) => {
try{
let resp = await axios.post(`${process.env.LLM_INDEXER_HOST}/chat/stream`, req.body, {
responseType: 'stream'
})
res.set(resp.headers);
resp.data.pipe(res);
} catch (error) {
// Handle the exception
console.error('An error occurred:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
};


export const search = async (req, res, next) => {
try{
let resp = await axios.post(`${process.env.LLM_INDEXER_HOST}/search/query`, req.body, {
responseType: 'stream'
})
res.set(resp.headers);
resp.data.pipe(res);
} catch (error) {
// Handle the exception
console.error('An error occurred:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
};
25 changes: 9 additions & 16 deletions api/src/packages/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ app.delete('/embeddings', authCheckMiddleware, validator.body(Joi.object({
category: Joi.string().required()
})), embeddingController.deleteEmbedding);

app.post('/chat_stream', validator.body(Joi.object({

app.post('/discovery/search', validator.body(Joi.object({
query: Joi.string().required(),
indexIds: Joi.array().items(Joi.string()).required(),
})), discoveryController.search)

app.post('/discovery/chat', validator.body(Joi.object({
id: Joi.string().required(),
messages: Joi.array().required(),
did: Joi.string().optional(),
Expand All @@ -163,21 +169,8 @@ app.post('/chat_stream', validator.body(Joi.object({
then: Joi.string().valid('owned', 'starred').optional(),
otherwise: Joi.forbidden()
}),
indexes: Joi.array().items(Joi.string()).optional(),
}).or('did', 'indexes')), async (req, res) => {
try{
let resp = await axios.post(`${process.env.LLM_INDEXER_HOST}/chat_stream`, req.body, {
responseType: 'stream'
})
res.set(resp.headers);
resp.data.pipe(res);
} catch (error) {
// Handle the exception
console.error('An error occurred:', error);
res.status(500).json({ error: 'Internal Server Error' });
}

})
indexIds: Joi.array().items(Joi.string()).optional(),
}).or('did', 'indexIds')), discoveryController.chat)

app.post('/web2/webpage', authCheckMiddleware, validator.body(Joi.object({
title: Joi.string().required(),
Expand Down

0 comments on commit 7a30706

Please sign in to comment.