update requirements and /status
				
					
				
			This commit is contained in:
		
							parent
							
								
									524d9e78e6
								
							
						
					
					
						commit
						1d08719645
					
				
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@ -6,6 +6,7 @@ from langchain.llms import RWKV
 | 
			
		||||
from utils.rwkv import *
 | 
			
		||||
from utils.torch import *
 | 
			
		||||
import global_var
 | 
			
		||||
import GPUtil
 | 
			
		||||
 | 
			
		||||
router = APIRouter()
 | 
			
		||||
 | 
			
		||||
@ -25,8 +26,8 @@ def switch_model(body: SwitchModelBody, response: Response):
 | 
			
		||||
    global_var.set(global_var.Model_Status, global_var.ModelStatus.Offline)
 | 
			
		||||
    global_var.set(global_var.Model, None)
 | 
			
		||||
    torch_gc()
 | 
			
		||||
    
 | 
			
		||||
    os.environ["RWKV_CUDA_ON"] = '1' if body.customCuda else '0'
 | 
			
		||||
 | 
			
		||||
    os.environ["RWKV_CUDA_ON"] = "1" if body.customCuda else "0"
 | 
			
		||||
 | 
			
		||||
    global_var.set(global_var.Model_Status, global_var.ModelStatus.Loading)
 | 
			
		||||
    try:
 | 
			
		||||
@ -66,4 +67,13 @@ def update_config(body: ModelConfigBody):
 | 
			
		||||
 | 
			
		||||
@router.get("/status")
 | 
			
		||||
def status():
 | 
			
		||||
    return {"status": global_var.get(global_var.Model_Status)}
 | 
			
		||||
    gpus = GPUtil.getGPUs()
 | 
			
		||||
    if len(gpus) == 0:
 | 
			
		||||
        device_name = "CPU"
 | 
			
		||||
    else:
 | 
			
		||||
        device_name = gpus[0].name
 | 
			
		||||
    return {
 | 
			
		||||
        "status": global_var.get(global_var.Model_Status),
 | 
			
		||||
        "pid": os.getpid(),
 | 
			
		||||
        "device_name": device_name,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -189,9 +189,9 @@ export function forceDownloadProgramFiles() {
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function deletePythonProgramFiles() {
 | 
			
		||||
export function deleteDynamicProgramFiles() {
 | 
			
		||||
  manifest.programFiles.forEach(({ path }) => {
 | 
			
		||||
    if (path.endsWith('.py') && !path.includes('get-pip.py'))
 | 
			
		||||
    if ((path.endsWith('.py') && !path.includes('get-pip.py')) || path.includes('requirements'))
 | 
			
		||||
      DeleteFile(path);
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
@ -223,7 +223,7 @@ export async function checkUpdate(notifyEvenLatest: boolean = false) {
 | 
			
		||||
                `https://github.com/josStorer/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe` :
 | 
			
		||||
                `https://gitee.com/josc146/RWKV-Runner/releases/download/${versionTag}/RWKV-Runner_windows_x64.exe`;
 | 
			
		||||
              toastWithButton(t('New Version Available') + ': ' + versionTag, t('Update'), () => {
 | 
			
		||||
                deletePythonProgramFiles();
 | 
			
		||||
                deleteDynamicProgramFiles();
 | 
			
		||||
                setTimeout(() => {
 | 
			
		||||
                  UpdateApp(updateUrl).catch((e) => {
 | 
			
		||||
                    toast(t('Update Error, Please restart this program') + ' - ' + e.message || e, {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user