aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/AssistantManager.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-10-10 11:39:19 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-10-10 11:39:19 -0400
commitd347fc59feefd91a796012892da57511787bb6d0 (patch)
tree83b8950ade694a795a38fd2969d50978c1179b83 /src/server/ApiManagers/AssistantManager.ts
parent75b98f184260567c0dabb54dd8ef22a8e2510512 (diff)
added new file header comments and fixed some error handling
Diffstat (limited to 'src/server/ApiManagers/AssistantManager.ts')
-rw-r--r--src/server/ApiManagers/AssistantManager.ts22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/server/ApiManagers/AssistantManager.ts b/src/server/ApiManagers/AssistantManager.ts
index b4ebb1eae..b7d4191ca 100644
--- a/src/server/ApiManagers/AssistantManager.ts
+++ b/src/server/ApiManagers/AssistantManager.ts
@@ -1,3 +1,13 @@
+/**
+ * @file AssistantManager.ts
+ * @description This file defines the AssistantManager class, responsible for managing various
+ * API routes related to the Assistant functionality. It provides features such as file handling,
+ * web scraping, and integration with third-party APIs like OpenAI and Google Custom Search.
+ * It also handles job tracking and progress reporting for tasks like document creation and web scraping.
+ * Utility functions for path manipulation and file operations are included, along with
+ * a mechanism for handling retry logic during API calls.
+ */
+
import { Readability } from '@mozilla/readability';
import axios from 'axios';
import { spawn } from 'child_process';
@@ -76,12 +86,6 @@ export default class AssistantManager extends ApiManager {
* @param register The registration method to register routes and handlers.
*/
protected initialize(register: Registration): void {
- // Initialize OpenAI API with client key
- const openai = new OpenAI({ // bcz: is this needed? variable is never used...
- apiKey: process.env._CLIENT_OPENAI_KEY,
- dangerouslyAllowBrowser: true,
- }); // prettier-ignore
-
// Initialize Google Custom Search API
const customsearch = google.customsearch('v1');
@@ -107,7 +111,6 @@ export default class AssistantManager extends ApiManager {
console.error('Error retrieving Wikipedia summary:', error);
res.status(500).send({
error: 'Error retrieving article summary from Wikipedia.',
- details: (error as { message: string }).message ?? error, // bcz: don't know what the error type contains...
});
}
},
@@ -140,7 +143,6 @@ export default class AssistantManager extends ApiManager {
console.error('Error performing web search:', error);
res.status(500).send({
error: 'Failed to perform web search',
- details: (error as { message: string }).message ?? error, // bcz: don't know wha tthe error type contains...
});
}
},
@@ -199,7 +201,6 @@ export default class AssistantManager extends ApiManager {
console.error('Error fetching the URL:', error);
res.status(500).send({
error: 'Failed to fetch the URL',
- details: (error as { message: string }).message ?? error, // bcz: don't know wha tthe error type contains...
});
}
},
@@ -241,7 +242,6 @@ export default class AssistantManager extends ApiManager {
console.error('Error scraping website:', error);
res.status(500).send({
error: 'Failed to scrape website',
- details: (error as { message: string }).message ?? error, // bcz: don't know wha tthe error type contains...
});
}
},
@@ -272,7 +272,6 @@ export default class AssistantManager extends ApiManager {
console.error('Error initiating document creation:', error);
res.status(500).send({
error: 'Failed to initiate document creation',
- details: (error as { message: string }).message ?? error, // bcz: don't know wha tthe error type contains...
});
}
},
@@ -430,7 +429,6 @@ export default class AssistantManager extends ApiManager {
console.error('Error creating CSV file:', error);
res.status(500).send({
error: 'Failed to create CSV file.',
- details: (error as { message: string }).message ?? error, // bcz: don't know what the error type contains...
});
}
},