mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 09:00:52 +03:00
NVIDIA NIM fixes (#4215)
* fix: udpate label to "NVIDIA NIM API Key" * test: update tag from ":latest" to ":1.8.0-rtx" * test: add image URL path "nvcr.io/nim/" * fix/nvidia-nim-2 (#4208) * fix: update nim-container-manager * feat: add "DeepSeek R1 Distill Llama 8B" * fix/nidia-nim-3 (#4209) * chore: add error message NVIDIA NIM is not installed. * chore: standardize NVIDIA NGC API Key * chore: capitalize Nvidia to NVIDIA * chore: generalize error message for chat models * fix/nvidia-nim-4-yau (#4212) * test: nimRelaxMemConstraints and hostPort * test: add logger for hostPort and nimRelaxMemConstraints * test: nim-container-manager version 1.0.9 * test: parseInt nimRelaxMemConstraints * test: update nim-container-manager version to 1.0.10 * chore: update nim-container-manager version to 1.0.11 * Update start container behaviour - show existing containers and give users the choice * Go back to previous step when clicking start new so user can change port number * Update condition for showing existing container dialog * Fix start new in different port not working * Update get container controller * Update again * fix: generalize error message for chat models * Update getContainer controller * Fix incorrect image check in getContainer controller * Update existing container dialog text * Fix styles in container exists dialog for nvidia nim --------- Co-authored-by: chungyau97 <chungyau97@gmail.com> Co-authored-by: Ong Chung Yau <33013947+chungyau97@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import { Request, Response, NextFunction } from 'express'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
|
||||
const { NimContainerManager } = require('nim-container-manager')
|
||||
const { NimContainerManager } = require('flowise-nim-container-manager')
|
||||
|
||||
const getToken = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
@@ -55,7 +55,13 @@ const startContainer = async (req: Request, res: Response, next: NextFunction) =
|
||||
try {
|
||||
const imageTag = req.body.imageTag
|
||||
const apiKey = req.body.apiKey
|
||||
await NimContainerManager.startContainer(imageTag, apiKey)
|
||||
const hostPort = req.body.hostPort
|
||||
const nimRelaxMemConstraints = parseInt(req.body.nimRelaxMemConstraints)
|
||||
// Validate nimRelaxMemConstraints
|
||||
if (isNaN(nimRelaxMemConstraints) || (nimRelaxMemConstraints !== 0 && nimRelaxMemConstraints !== 1)) {
|
||||
return res.status(400).send('nimRelaxMemConstraints must be 0 or 1')
|
||||
}
|
||||
await NimContainerManager.startContainer(imageTag, apiKey, hostPort, nimRelaxMemConstraints)
|
||||
return res.send(`Starting container ${imageTag}`)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
@@ -79,17 +85,51 @@ const getImage = async (req: Request, res: Response, next: NextFunction) => {
|
||||
const getContainer = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const imageTag = req.body.imageTag
|
||||
const port = req.body.port
|
||||
|
||||
// First check if the image exists
|
||||
const images = await NimContainerManager.userImageLibrary()
|
||||
const image = images.find((img: any) => img.tag === imageTag)
|
||||
if (!image) {
|
||||
return res.status(404).send(`Image ${imageTag} not found`)
|
||||
}
|
||||
if (!image.container) {
|
||||
return res.status(404).send(`Container of ${imageTag} not found`)
|
||||
|
||||
const containers = await NimContainerManager.listRunningContainers()
|
||||
const portInUse = containers.find((cont: any) => cont.port === port)
|
||||
if (portInUse) {
|
||||
const isModelContainer = portInUse.image === image.tag
|
||||
if (isModelContainer) {
|
||||
portInUse.image = image.name
|
||||
return res.json(portInUse)
|
||||
} else {
|
||||
return res.status(409).send({
|
||||
message: `Port ${port} is already in use by another container`,
|
||||
container: portInUse
|
||||
})
|
||||
}
|
||||
}
|
||||
const container = image.container
|
||||
container.image = image.name
|
||||
return res.json(container)
|
||||
|
||||
// If no container found with matching port, return 404
|
||||
return res.status(404).send(`Container of ${imageTag} with port ${port} not found`)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
const listRunningContainers = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const containers = await NimContainerManager.listRunningContainers()
|
||||
return res.json(containers)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
const stopContainer = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const containerId = req.body.containerId
|
||||
const containerInfo = await NimContainerManager.stopContainer(containerId)
|
||||
return res.json(containerInfo)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
@@ -102,5 +142,7 @@ export default {
|
||||
pullImage,
|
||||
startContainer,
|
||||
getImage,
|
||||
getContainer
|
||||
getContainer,
|
||||
listRunningContainers,
|
||||
stopContainer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user