aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/ApiManagers')
-rw-r--r--src/server/ApiManagers/AssistantManager.ts4
-rw-r--r--src/server/ApiManagers/FireflyManager.ts23
2 files changed, 15 insertions, 12 deletions
diff --git a/src/server/ApiManagers/AssistantManager.ts b/src/server/ApiManagers/AssistantManager.ts
index e859e5c5f..af25722a4 100644
--- a/src/server/ApiManagers/AssistantManager.ts
+++ b/src/server/ApiManagers/AssistantManager.ts
@@ -539,7 +539,7 @@ export default class AssistantManager extends ApiManager {
// Spawn the Python process and track its progress/output
// eslint-disable-next-line no-use-before-define
- spawnPythonProcess(jobId, file_name, public_path);
+ spawnPythonProcess(jobId, public_path);
// Send the job ID back to the client for tracking
res.send({ jobId });
@@ -696,7 +696,7 @@ export default class AssistantManager extends ApiManager {
* @param file_name The name of the file to process.
* @param file_path The filepath of the file to process.
*/
-function spawnPythonProcess(jobId: string, file_name: string, file_path: string) {
+function spawnPythonProcess(jobId: string, file_path: string) {
const venvPath = path.join(__dirname, '../chunker/venv');
const requirementsPath = path.join(__dirname, '../chunker/requirements.txt');
const pythonScriptPath = path.join(__dirname, '../chunker/pdf_chunker.py');
diff --git a/src/server/ApiManagers/FireflyManager.ts b/src/server/ApiManagers/FireflyManager.ts
index 160a94d40..e75ede9df 100644
--- a/src/server/ApiManagers/FireflyManager.ts
+++ b/src/server/ApiManagers/FireflyManager.ts
@@ -132,7 +132,8 @@ export default class FireflyManager extends ApiManager {
],
body: body,
})
- .then(response2 => response2.json().then(json => ({ seed: json.outputs?.[0]?.seed, url: json.outputs?.[0]?.image?.url })))
+ .then(response2 => response2.json())
+ .then(json => (json.error_code ? json : { seed: json.outputs?.[0]?.seed, url: json.outputs?.[0]?.image?.url }))
.catch(error => {
console.error('Error:', error);
return undefined;
@@ -297,13 +298,13 @@ export default class FireflyManager extends ApiManager {
_invalid(res, styleUrl.message);
throw new Error('Error uploading images to dropbox');
}
- this.uploadImageToDropbox(req.body.structure, req.user as DashUserModel)
- .then(structureUrl => {
- if (structureUrl instanceof Error) {
- _invalid(res, structureUrl.message);
+ this.uploadImageToDropbox(req.body.structureUrl, req.user as DashUserModel)
+ .then(dropboxStructureUrl => {
+ if (dropboxStructureUrl instanceof Error) {
+ _invalid(res, dropboxStructureUrl.message);
throw new Error('Error uploading images to dropbox');
}
- return { styleUrl, structureUrl };
+ return { styleUrl, structureUrl: dropboxStructureUrl };
})
.then(uploads =>
this.generateImageFromStructure(req.body.prompt, req.body.width, req.body.height, uploads.structureUrl, req.body.strength, req.body.presets, uploads.styleUrl)
@@ -332,10 +333,12 @@ export default class FireflyManager extends ApiManager {
subscription: '/queryFireflyImage',
secureHandler: ({ req, res }) =>
this.generateImage(req.body.prompt, req.body.width, req.body.height, req.body.seed).then(img =>
- DashUploadUtils.UploadImage(img?.url ?? '', undefined, img?.seed).then(info => {
- if (info instanceof Error) _invalid(res, info.message);
- else _success(res, info);
- })
+ img.error_code
+ ? _invalid(res, img.message)
+ : DashUploadUtils.UploadImage(img?.url ?? '', undefined, img?.seed).then(info => {
+ if (info instanceof Error) _invalid(res, info.message);
+ else _success(res, info);
+ })
),
});