File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,9 @@ def __init__(self, opts: GlobalOptions = None):
3030 GPTScript .__gptscript_count += 1
3131
3232 if GPTScript .__server_url == "" :
33- GPTScript .__server_url = os .environ .get ("GPTSCRIPT_URL" , "" )
33+ GPTScript .__server_url = os .environ .get ("GPTSCRIPT_URL" , "127.0.0.1:0 " )
3434
3535 if GPTScript .__gptscript_count == 1 and os .environ .get ("GPTSCRIPT_DISABLE_SERVER" , "" ) != "true" :
36- if GPTScript .__server_url == "" :
37- with socket () as s :
38- s .bind (("" , 0 ))
39- GPTScript .__server_url = f"127.0.0.1:{ s .getsockname ()[1 ]} "
40-
4136 opts .toEnv ()
4237
4338 GPTScript .__process = Popen (
@@ -50,6 +45,10 @@ def __init__(self, opts: GlobalOptions = None):
5045 encoding = "utf-8" ,
5146 )
5247
48+ GPTScript .__server_url = GPTScript .__process .stderr .readline ().strip ("\n " )
49+ if "=" in GPTScript .__server_url :
50+ GPTScript .__server_url = GPTScript .__server_url .split ("=" )[1 ]
51+
5352 self ._server_url = f"http://{ GPTScript .__server_url } "
5453 self ._wait_for_gptscript ()
5554
You can’t perform that action at this time.
0 commit comments