File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1212from . import _tools
1313from .. import OpenAI , __version__
1414from ._api import register_commands
15- from ._utils import set_client
15+ from ._utils import set_client , can_use_http2
1616from .._types import ProxiesDict
1717from ._errors import CLIError , display_error
1818from .._compat import PYDANTIC_V2 , ConfigDict , model_parse
@@ -149,6 +149,7 @@ def _main() -> None:
149149
150150 http_client = httpx .Client (
151151 proxies = proxies or None ,
152+ http2 = can_use_http2 (),
152153 )
153154
154155 try :
@@ -178,14 +179,12 @@ def _main() -> None:
178179 )
179180 else :
180181 parsed .func ()
181- except Exception :
182+ finally :
182183 try :
183184 http_client .close ()
184185 except Exception :
185186 pass
186187
187- raise
188-
189188
190189if __name__ == "__main__" :
191190 sys .exit (main ())
Original file line number Diff line number Diff line change @@ -46,3 +46,12 @@ def organization_info() -> str:
4646
4747def print_model (model : BaseModel ) -> None :
4848 sys .stdout .write (model_json (model , indent = 2 ) + "\n " )
49+
50+
51+ def can_use_http2 () -> bool :
52+ try :
53+ import h2 # type: ignore # noqa
54+ except ImportError :
55+ return False
56+
57+ return True
You can’t perform that action at this time.
0 commit comments