aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/AssistantManager.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-06-27 16:36:40 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-06-27 16:36:40 -0400
commite297c75cdcc8bb5b1b138d1272f1f6f27b222f4c (patch)
tree2b4c955188a4867d9c018ca0f9d7d4b099f6086d /src/server/ApiManagers/AssistantManager.ts
parent33621442bad6ffe78840dc95984199d3b339d832 (diff)
fixing to work with python API
also added follow up questions
Diffstat (limited to 'src/server/ApiManagers/AssistantManager.ts')
-rw-r--r--src/server/ApiManagers/AssistantManager.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/server/ApiManagers/AssistantManager.ts b/src/server/ApiManagers/AssistantManager.ts
index f2ea83310..f0ca983d7 100644
--- a/src/server/ApiManagers/AssistantManager.ts
+++ b/src/server/ApiManagers/AssistantManager.ts
@@ -7,6 +7,7 @@ import * as uuid from 'uuid';
import { filesDirectory, publicDirectory } from '../SocketData';
import { Method } from '../RouteManager';
import ApiManager, { Registration } from './ApiManager';
+import axios from 'axios';
export enum Directory {
parsed_files = 'parsed_files',
@@ -130,5 +131,37 @@ export default class AssistantManager extends ApiManager {
}
},
});
+
+ register({
+ method: Method.POST,
+ subscription: '/askAgent',
+ secureHandler: async ({ req, res }) => {
+ const { input } = req.body;
+
+ try {
+ const response = await axios.post('http://localhost:8080/ask', { input });
+ res.send({ response: response.data.response });
+ } catch (error: any) {
+ console.error('Error communicating with chatbot:', error);
+ res.status(500).send({ error: 'Failed to communicate with the chatbot', details: error.message });
+ }
+ },
+ });
+ // register({
+ // method: Method.POST,
+ // subscription: '/uploadPDF',
+ // secureHandler: async ({ req, res }) => {
+ // const { file_path } = req.body;
+ // const fullPath = path.join(publicDirectory, file_path);
+ // const fileData = createReadStream(fullPath);
+ // try {
+ // const response = await axios.post('http://localhost:8080/uploadPDF', { fileData });
+ // res.send({ response: response });
+ // } catch (error: any) {
+ // console.error('Error communicating with chatbot:', error);
+ // res.status(500).send({ error: 'Failed to communicate with the chatbot', details: error.message });
+ // }
+ // },
+ // });
}
}