@@ -32,13 +32,15 @@ def __init__(self, opts: GlobalOptions = None):
3232 GPTScript .__gptscript_count += 1
3333
3434 if GPTScript .__server_url == "" :
35- GPTScript .__server_url = os .environ .get ("GPTSCRIPT_URL" , "127.0.0.1:0" )
35+ GPTScript .__server_url = os .environ .get ("GPTSCRIPT_URL" , "http://127.0.0.1:0" )
36+ if not (GPTScript .__server_url .startswith ("http://" ) or GPTScript .__server_url .startswith ("https://" )):
37+ GPTScript .__server_url = f"http://{ GPTScript .__server_url } "
3638
37- if GPTScript .__gptscript_count == 1 and os .environ .get ("GPTSCRIPT_DISABLE_SERVER " , "" ) != "true " :
39+ if GPTScript .__gptscript_count == 1 and os .environ .get ("GPTSCRIPT_URL " , "" ) == " " :
3840 self .opts .toEnv ()
3941
4042 GPTScript .__process = Popen (
41- [_get_command (), "--listen-address" , GPTScript .__server_url , "sdkserver" ],
43+ [_get_command (), "--listen-address" , GPTScript .__server_url . removeprefix ( "http://" ) , "sdkserver" ],
4244 stdin = PIPE ,
4345 stdout = PIPE ,
4446 stderr = PIPE ,
@@ -51,7 +53,10 @@ def __init__(self, opts: GlobalOptions = None):
5153 if "=" in GPTScript .__server_url :
5254 GPTScript .__server_url = GPTScript .__server_url .split ("=" )[1 ]
5355
54- self ._server_url = f"http://{ GPTScript .__server_url } "
56+ self .opts .Env .append ("GPTSCRIPT_URL=" + GPTScript .__server_url )
57+ self ._server_url = GPTScript .__server_url
58+ if not (self ._server_url .startswith ("http://" ) or self ._server_url .startswith ("https://" )):
59+ self ._server_url = f"http://{ self ._server_url } "
5560 self ._wait_for_gptscript ()
5661
5762 def _wait_for_gptscript (self ):
0 commit comments