Skip to content

Commit be11083

Browse files
authored
fix cve issue and revamp clickdeploy to enable persistent status (opea-project#72)
* revamp clickdeploy for persistent deployment status Signed-off-by: wwanarif <wan.abdul.hakim.b.wan.arif@intel.com> * fix cve issues and spelling Signed-off-by: wwanarif <wan.abdul.hakim.b.wan.arif@intel.com> --------- Signed-off-by: wwanarif <wan.abdul.hakim.b.wan.arif@intel.com>
1 parent a0ade96 commit be11083

File tree

16 files changed

+880
-452
lines changed

16 files changed

+880
-452
lines changed

app-backend/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ WORKDIR /home/user/
1414
RUN git clone --depth 1 https://github.com/opea-project/GenAIComps.git
1515

1616
WORKDIR /home/user/GenAIComps
17-
RUN pip install --no-cache-dir --upgrade pip==24.3.1 setuptools==75.3.0 && \
18-
pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt
17+
RUN pip install --no-cache-dir --upgrade pip==24.3.1 setuptools==78.1.1 && \
18+
pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt && \
19+
pip install --no-cache-dir --upgrade mcp==1.10.0 pillow==11.3.0
1920

2021
COPY ./templates/microservices/* /home/user/templates/microservices/
2122
COPY ./megaservice.py /home/user/megaservice.py

studio-backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missin
1313
rm -rf /var/lib/apt/lists/*
1414

1515
# Upgrade setuptools to a safe version and install any needed packages specified in requirements.txt
16-
RUN pip install --no-cache-dir --upgrade pip==24.3.1 setuptools==75.3.0 && \
16+
RUN pip install --no-cache-dir --upgrade pip==24.3.1 setuptools==78.1.1 && \
1717
pip install --no-cache-dir -r /usr/src/app/requirements.txt
1818

1919
# Define environment variable

studio-backend/app/routers/clickdeploy_router.py

Lines changed: 53 additions & 249 deletions
Large diffs are not rendered by default.

studio-backend/app/services/clickdeploy_service.py

Lines changed: 357 additions & 35 deletions
Large diffs are not rendered by default.

studio-frontend/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"sqlite3"
5959
],
6060
"overrides": {
61-
"set-value": "^3.0.3"
61+
"set-value": "^3.0.3",
62+
"form-data": "4.0.4"
6263
}
6364
},
6465
"engines": {
@@ -79,7 +80,8 @@
7980
"esbuild": ">=0.25.0",
8081
"cross-spawn": ">=7.0.5",
8182
"solid-js": ">=1.9.4",
82-
"tar-fs": ">=3.0.8"
83+
"tar-fs": ">=3.0.8",
84+
"form-data": "4.0.4"
8385
},
8486
"eslintIgnore": [
8587
"**/dist",

studio-frontend/packages/server/src/controllers/chatflows/index.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,57 @@ const getPublicKey = async (req: Request, res: Response, next: NextFunction) =>
285285
}
286286
}
287287

288+
const getDeploymentStatus = async (req: Request, res: Response, next: NextFunction) => {
289+
try {
290+
if (typeof req.params === 'undefined' || !req.params.id) {
291+
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: chatflowsRouter.getDeploymentStatus - id not provided!`)
292+
}
293+
const chatflow = await chatflowsService.getChatflowById(req.params.id)
294+
if (!chatflow) {
295+
return res.status(404).json({ error: 'Chatflow not found' })
296+
}
297+
298+
let config = null
299+
let logs = []
300+
301+
try {
302+
config = chatflow.deploymentConfig ? JSON.parse(chatflow.deploymentConfig) : null
303+
} catch (e) {
304+
console.error('Error parsing deploymentConfig:', e)
305+
}
306+
307+
try {
308+
logs = chatflow.deploymentLogs ? JSON.parse(chatflow.deploymentLogs) : []
309+
} catch (e) {
310+
console.error('Error parsing deploymentLogs:', e)
311+
}
312+
313+
const response = {
314+
status: chatflow.deploymentStatus || 'Not Started',
315+
message: '',
316+
config: config,
317+
logs: logs
318+
}
319+
320+
return res.json(response)
321+
} catch (error) {
322+
next(error)
323+
}
324+
}
325+
326+
const updateDeploymentStatus = async (req: Request, res: Response, next: NextFunction) => {
327+
try {
328+
if (typeof req.params === 'undefined' || !req.params.id) {
329+
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: chatflowsRouter.updateDeploymentStatus - id not provided!`)
330+
}
331+
const { status, message, logs, config } = req.body
332+
const result = await chatflowsService.updateDeploymentStatus(req.params.id, status, message, logs, config)
333+
return res.json(result)
334+
} catch (error) {
335+
next(error)
336+
}
337+
}
338+
288339
const oneClickDeployment = async (req: Request, res: Response, next: NextFunction) => {
289340
console.log('Deploying one click')
290341
try {
@@ -316,5 +367,7 @@ export default {
316367
stopChatflowSandbox,
317368
buildDeploymentPackage,
318369
getPublicKey,
370+
getDeploymentStatus,
371+
updateDeploymentStatus,
319372
oneClickDeployment
320373
}

studio-frontend/packages/server/src/database/entities/ChatFlow.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ export class ChatFlow implements IChatFlow {
5858
@Column({nullable: true, type: 'text'})
5959
sandboxDebugLogsUrl?: string
6060

61+
@Column({nullable: true, type: 'text'})
62+
deploymentStatus?: string
63+
64+
@Column({nullable: true, type: 'text'})
65+
deploymentConfig?: string
66+
67+
@Column({nullable: true, type: 'text'})
68+
deploymentLogs?: string
69+
6170
@Column({ type: 'timestamp' })
6271
@CreateDateColumn()
6372
createdDate: Date
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddDeploymentStatusToChatFlow1754700956637 implements MigrationInterface {
4+
public async up(queryRunner: QueryRunner): Promise<void> {
5+
const deploymentStatusExists = await queryRunner.hasColumn('chat_flow', 'deploymentStatus')
6+
if (!deploymentStatusExists) {
7+
await queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`deploymentStatus\` varchar(255) DEFAULT NULL;`)
8+
}
9+
10+
const deploymentConfigExists = await queryRunner.hasColumn('chat_flow', 'deploymentConfig')
11+
if (!deploymentConfigExists) {
12+
await queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`deploymentConfig\` TEXT DEFAULT NULL;`)
13+
}
14+
15+
const deploymentLogsExists = await queryRunner.hasColumn('chat_flow', 'deploymentLogs')
16+
if (!deploymentLogsExists) {
17+
await queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`deploymentLogs\` TEXT DEFAULT NULL;`)
18+
}
19+
}
20+
21+
public async down(queryRunner: QueryRunner): Promise<void> {
22+
await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`deploymentStatus\`;`)
23+
await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`deploymentConfig\`;`)
24+
await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`deploymentLogs\`;`)
25+
}
26+
}

studio-frontend/packages/server/src/database/migrations/mysql/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { AddArtifactsToChatMessage1726156258465 } from './1726156258465-AddArtif
2929
import { AddStudioFieldsToChatFlow1733282099772 } from './1733282099772-AddStudioFieldsToChatFlow'
3030
import { AddSandboxTracerUrlToChatFlow1743740099772 } from './1743740099772-AddSandboxTracerUrlToChatFlow'
3131
import { AddSandboxDebugLogsUrlToChatFlow1749612373191 } from './1749612373191-AddSandboxDebugLogsUrlToChatFlow'
32+
import { AddDeploymentStatusToChatFlow1754700956637 } from './1754700956637-AddDeploymentStatusToChatFlow'
3233

3334

3435
export const mysqlMigrations = [
@@ -62,5 +63,6 @@ export const mysqlMigrations = [
6263
AddArtifactsToChatMessage1726156258465,
6364
AddStudioFieldsToChatFlow1733282099772,
6465
AddSandboxTracerUrlToChatFlow1743740099772,
65-
AddSandboxDebugLogsUrlToChatFlow1749612373191
66+
AddSandboxDebugLogsUrlToChatFlow1749612373191,
67+
AddDeploymentStatusToChatFlow1754700956637
6668
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddDeploymentStatusToChatFlow1754700956637 implements MigrationInterface {
4+
public async up(queryRunner: QueryRunner): Promise<void> {
5+
const deploymentStatusExists = await queryRunner.hasColumn('chat_flow', 'deploymentStatus')
6+
if (!deploymentStatusExists) {
7+
await queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`deploymentStatus\` varchar(255) DEFAULT NULL;`)
8+
}
9+
10+
const deploymentConfigExists = await queryRunner.hasColumn('chat_flow', 'deploymentConfig')
11+
if (!deploymentConfigExists) {
12+
await queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`deploymentConfig\` TEXT DEFAULT NULL;`)
13+
}
14+
15+
const deploymentLogsExists = await queryRunner.hasColumn('chat_flow', 'deploymentLogs')
16+
if (!deploymentLogsExists) {
17+
await queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`deploymentLogs\` TEXT DEFAULT NULL;`)
18+
}
19+
}
20+
21+
public async down(queryRunner: QueryRunner): Promise<void> {
22+
await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`deploymentStatus\`;`)
23+
await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`deploymentConfig\`;`)
24+
await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`deploymentLogs\`;`)
25+
}
26+
}

0 commit comments

Comments
 (0)