:zap: [Enhance] Handle if http_proxy is None, and prettify logs
Browse files19 unmodified lines2021222324252611 unmodified lines3839404142434445464748495051521 unmodified line5455565758596061626319 unmodified linesself.api_chat_requirements = f"{self.api_base}/sentinel/chat-requirements"self.uuid = str(uuid.uuid4())self.requests_headers = {"Accept": "*/*","Accept-Encoding": "gzip, deflate, br, zstd","Accept-Language": "en-US,en;q=0.9","Cache-Control": "no-cache",11 unmodified lines}http_proxy = ENVER["http_proxy"]self.requests_proxies = {"http": http_proxy,"https": http_proxy,}def log_request(self, url, method="GET"):if ENVER["http_proxy"]:logger.note(f"> Using Proxy: {ENVER['http_proxy']}")logger.note(f"> {method}: {url}", end=" ")def log_response(self, res: requests.Response):status_code = res.status_code1 unmodified lineif status_code == 200:logger.success(status_code_str)else:logger.warn(f"uuid: {self.uuid}")logger.warn(status_code_str)logger.mesg(res.json())def get_models(self):self.log_request(self.api_models)19 unmodified lines2021222324252611 unmodified lines38394041424344454647484950515253545556571 unmodified line5960616263646566676819 unmodified linesself.api_chat_requirements = f"{self.api_base}/sentinel/chat-requirements"self.uuid = str(uuid.uuid4())self.requests_headers = {# "Accept": "*/*","Accept-Encoding": "gzip, deflate, br, zstd","Accept-Language": "en-US,en;q=0.9","Cache-Control": "no-cache",11 unmodified lines}http_proxy = ENVER["http_proxy"]if http_proxy:self.requests_proxies = {"http": http_proxy,"https": http_proxy,}else:self.requests_proxies = Nonedef log_request(self, url, method="GET"):if ENVER["http_proxy"]:logger.note(f"> Using Proxy:", end=" ")logger.mesg(f"{ENVER['http_proxy']}")logger.note(f"> {method}:", end=" ")logger.mesg(f"{url}", end=" ")def log_response(self, res: requests.Response):status_code = res.status_code1 unmodified lineif status_code == 200:logger.success(status_code_str)else:logger.warn(status_code_str)logger.warn(f"uuid: {self.uuid}")logger.line(res.json())def get_models(self):self.log_request(self.api_models)
tests/openai.py+14-9