修复:读取环境变量重定向URL格式
This commit is contained in:
		
							parent
							
								
									e5e3e0aa43
								
							
						
					
					
						commit
						8865b232ca
					
				
							
								
								
									
										10
									
								
								toolbox.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								toolbox.py
									
									
									
									
									
								
							@ -546,12 +546,10 @@ def read_single_conf_from_env(arg, default_value):
 | 
				
			|||||||
        for item in os.environ[env_arg].split(";"):
 | 
					        for item in os.environ[env_arg].split(";"):
 | 
				
			||||||
            r.append(tuple(item.split(":")))
 | 
					            r.append(tuple(item.split(":")))
 | 
				
			||||||
    elif arg == "API_URL_REDIRECT": 
 | 
					    elif arg == "API_URL_REDIRECT": 
 | 
				
			||||||
        r = {}
 | 
					        # 对于API_URL_REDIRECT的环境变量,我们允许用户使用json格式配置多个url重定向
 | 
				
			||||||
        # 对于API_URL_REDIRECT的环境变量配置,我们允许用户使用;分隔转发地址
 | 
					        # 格式为一个json字符串,例如:{"https://api.openai.com/v1/chat/completions": "https://ai.open.com/api/conversation"}
 | 
				
			||||||
        # 格式为:url1:redirect1;url2:redirect2
 | 
					        import json
 | 
				
			||||||
        for item in os.environ[env_arg].split(";"):
 | 
					        r = json.loads(os.environ[env_arg])
 | 
				
			||||||
            k, v = item.split(":")
 | 
					 | 
				
			||||||
            r[k] = v
 | 
					 | 
				
			||||||
    elif isinstance(default_value, bool):
 | 
					    elif isinstance(default_value, bool):
 | 
				
			||||||
        r = bool(os.environ[env_arg])
 | 
					        r = bool(os.environ[env_arg])
 | 
				
			||||||
    elif isinstance(default_value, int):
 | 
					    elif isinstance(default_value, int):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user