()
| 42 | |
| 43 | |
| 44 | def 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 | |
| 77 | def init_openai_limit() -> None: |
no test coverage detected