Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
dfaa92c
1
Parent(s):
d837e9f
加入检测IP区域的功能
Browse files- ChuanhuChatbot.py +2 -2
- chat_func.py +2 -0
- utils.py +12 -0
ChuanhuChatbot.py
CHANGED
|
@@ -130,7 +130,7 @@ with gr.Blocks(
|
|
| 130 |
|
| 131 |
with gr.Row():
|
| 132 |
gr.HTML(title)
|
| 133 |
-
status_display = gr.Markdown(
|
| 134 |
|
| 135 |
with gr.Row(scale=1).style(equal_height=True):
|
| 136 |
with gr.Column(scale=5):
|
|
@@ -244,7 +244,7 @@ with gr.Blocks(
|
|
| 244 |
value=1.0,
|
| 245 |
step=0.05,
|
| 246 |
interactive=True,
|
| 247 |
-
label="Top-p
|
| 248 |
)
|
| 249 |
temperature = gr.Slider(
|
| 250 |
minimum=-0,
|
|
|
|
| 130 |
|
| 131 |
with gr.Row():
|
| 132 |
gr.HTML(title)
|
| 133 |
+
status_display = gr.Markdown(get_geoip(), elem_id="status_display")
|
| 134 |
|
| 135 |
with gr.Row(scale=1).style(equal_height=True):
|
| 136 |
with gr.Column(scale=5):
|
|
|
|
| 244 |
value=1.0,
|
| 245 |
step=0.05,
|
| 246 |
interactive=True,
|
| 247 |
+
label="Top-p",
|
| 248 |
)
|
| 249 |
temperature = gr.Slider(
|
| 250 |
minimum=-0,
|
chat_func.py
CHANGED
|
@@ -11,6 +11,8 @@ import urllib3
|
|
| 11 |
from tqdm import tqdm
|
| 12 |
import colorama
|
| 13 |
from duckduckgo_search import ddg
|
|
|
|
|
|
|
| 14 |
|
| 15 |
from presets import *
|
| 16 |
from llama_func import *
|
|
|
|
| 11 |
from tqdm import tqdm
|
| 12 |
import colorama
|
| 13 |
from duckduckgo_search import ddg
|
| 14 |
+
import asyncio
|
| 15 |
+
import aiohttp
|
| 16 |
|
| 17 |
from presets import *
|
| 18 |
from llama_func import *
|
utils.py
CHANGED
|
@@ -7,6 +7,7 @@ import os
|
|
| 7 |
import datetime
|
| 8 |
import hashlib
|
| 9 |
import csv
|
|
|
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
from pypinyin import lazy_pinyin
|
|
@@ -282,3 +283,14 @@ def sha1sum(filename):
|
|
| 282 |
def replace_today(prompt):
|
| 283 |
today = datetime.datetime.today().strftime("%Y-%m-%d")
|
| 284 |
return prompt.replace("{current_date}", today)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import datetime
|
| 8 |
import hashlib
|
| 9 |
import csv
|
| 10 |
+
import requests
|
| 11 |
|
| 12 |
import gradio as gr
|
| 13 |
from pypinyin import lazy_pinyin
|
|
|
|
| 283 |
def replace_today(prompt):
|
| 284 |
today = datetime.datetime.today().strftime("%Y-%m-%d")
|
| 285 |
return prompt.replace("{current_date}", today)
|
| 286 |
+
|
| 287 |
+
def get_geoip():
|
| 288 |
+
response = requests.get('https://ipapi.co/json/', timeout=5)
|
| 289 |
+
data = response.json()
|
| 290 |
+
country = data['country_name']
|
| 291 |
+
if country == "China":
|
| 292 |
+
text = "**您的IP区域:中国。请立即检查代理设置,在不受支持的地区使用API可能导致账号被封禁。**"
|
| 293 |
+
else:
|
| 294 |
+
text = f"您的IP区域:{country}。"
|
| 295 |
+
logging.info(text)
|
| 296 |
+
return text
|