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):
30
30
GPTScript .__gptscript_count += 1
31
31
32
32
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 " )
34
34
35
35
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
-
41
36
opts .toEnv ()
42
37
43
38
GPTScript .__process = Popen (
@@ -50,6 +45,10 @@ def __init__(self, opts: GlobalOptions = None):
50
45
encoding = "utf-8" ,
51
46
)
52
47
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
+
53
52
self ._server_url = f"http://{ GPTScript .__server_url } "
54
53
self ._wait_for_gptscript ()
55
54
You can’t perform that action at this time.
0 commit comments