Spaces:
Running
Running
Update bin_public/utils/shared.py
Browse files- bin_public/utils/shared.py +18 -10
bin_public/utils/shared.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
-
from bin_public.config.presets import
|
2 |
-
|
3 |
class State:
|
4 |
interrupted = False
|
5 |
-
|
|
|
|
|
6 |
|
7 |
def interrupt(self):
|
8 |
self.interrupted = True
|
@@ -10,15 +12,21 @@ class State:
|
|
10 |
def recover(self):
|
11 |
self.interrupted = False
|
12 |
|
13 |
-
def
|
14 |
-
self.
|
|
|
|
|
|
|
15 |
|
16 |
-
def
|
17 |
-
self.
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
def reset_all(self):
|
21 |
self.interrupted = False
|
22 |
-
self.
|
23 |
|
24 |
-
state = State()
|
|
|
1 |
+
from bin_public.config.presets import COMPLETION_URL, BALANCE_API_URL, USAGE_API_URL, API_HOST
|
2 |
+
import os
|
3 |
class State:
|
4 |
interrupted = False
|
5 |
+
completion_url = COMPLETION_URL
|
6 |
+
balance_api_url = BALANCE_API_URL
|
7 |
+
usage_api_url = USAGE_API_URL
|
8 |
|
9 |
def interrupt(self):
|
10 |
self.interrupted = True
|
|
|
12 |
def recover(self):
|
13 |
self.interrupted = False
|
14 |
|
15 |
+
def set_api_host(self, api_host):
|
16 |
+
self.completion_url = f"https://{api_host}/v1/chat/completions"
|
17 |
+
self.balance_api_url = f"https://{api_host}/dashboard/billing/credit_grants"
|
18 |
+
self.usage_api_url = f"https://{api_host}/dashboard/billing/usage"
|
19 |
+
os.environ["OPENAI_API_BASE"] = f"https://{api_host}/v1"
|
20 |
|
21 |
+
def reset_api_host(self):
|
22 |
+
self.completion_url = COMPLETION_URL
|
23 |
+
self.balance_api_url = BALANCE_API_URL
|
24 |
+
self.usage_api_url = USAGE_API_URL
|
25 |
+
os.environ["OPENAI_API_BASE"] = f"https://{API_HOST}/v1"
|
26 |
+
return API_HOST
|
27 |
|
28 |
def reset_all(self):
|
29 |
self.interrupted = False
|
30 |
+
self.completion_url = COMPLETION_URL
|
31 |
|
32 |
+
state = State()
|