MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / init_proxy

Function init_proxy

utils/st_content.py:44–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def init_proxy() -> None:
45 st.sidebar.markdown(
46 """
47 ###
48 """
49 )
50 proxy_address = st.sidebar.text_input(
51 'Input proxy address',
52 placeholder='127.0.0.1',
53 # label_visibility='hidden'
54 )
55
56 proxy_port = st.sidebar.number_input(
57 'Input proxy port',
58 # placeholder='7890',
59 step=1,
60 min_value=0,
61 max_value=65535,
62 format="%d",
63 # label_visibility='hidden'
64 )
65 with st.sidebar.status("设置代理...", expanded=True) as status:
66 if is_valid_ip(proxy_address) and is_valid_port(proxy_port):
67 if proxy_address.strip() != "" and proxy_port.strip() != "":
68 os.environ['http_proxy'] = f'http://{proxy_address}:{proxy_port}'
69 os.environ['https_proxy'] = f'http://{proxy_address}:{proxy_port}'
70 status.update(label="代理设置完成", state="complete", expanded=False)
71 else:
72 status.update(label="未设置代理", state="error", expanded=False)
73 else:
74 status.update(label="未设置代理", state="error", expanded=False)
75
76
77def init_openai_limit() -> None:

Callers 1

mainFunction · 0.90

Calls 2

is_valid_ipFunction · 0.85
is_valid_portFunction · 0.85

Tested by

no test coverage detected