Spaces:
Sleeping
Sleeping
Merge pull request #2 from east-and-west-magic/feature-file-service
Browse files- .gitignore +1 -0
- app.py +4 -4
- app_util.py +2 -2
- call_pgai.py +2 -0
.gitignore
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
.venv
|
|
|
|
| 2 |
__pycache__
|
| 3 |
*.json
|
|
|
|
| 1 |
.venv
|
| 2 |
+
.env
|
| 3 |
__pycache__
|
| 4 |
*.json
|
app.py
CHANGED
|
@@ -6,7 +6,7 @@ from zoneinfo import ZoneInfo
|
|
| 6 |
import gradio as gr
|
| 7 |
from extract import extract
|
| 8 |
import app_util
|
| 9 |
-
from pgsoft.pgconst.const import service_list, functionality_list
|
| 10 |
from pgsoft.pghost import ais
|
| 11 |
from pgsoft.pgdate.date_utils import beijing
|
| 12 |
import call_pgai
|
|
@@ -15,7 +15,7 @@ from str_util import normalize_text
|
|
| 15 |
#######################
|
| 16 |
# proxy version
|
| 17 |
#######################
|
| 18 |
-
proxy_version = "1.0.0-2024-01-
|
| 19 |
|
| 20 |
t = datetime.now()
|
| 21 |
t = t.astimezone(ZoneInfo("Asia/Shanghai"))
|
|
@@ -27,7 +27,7 @@ print(f"[Seattle]: {t.replace(microsecond=0)}")
|
|
| 27 |
identity = os.environ.get("identity")
|
| 28 |
print(f"identity: {identity}")
|
| 29 |
if not identity:
|
| 30 |
-
identity = "
|
| 31 |
ai = "stevez-ai-dev"
|
| 32 |
if identity in ais:
|
| 33 |
ai = ais[identity]
|
|
@@ -67,7 +67,7 @@ def run(hf_token, service, game, functionality, nlp_command):
|
|
| 67 |
print(f"<<<<<<<<<<<<<< service starts at {service_start} <<<<<<<<<<<<<<")
|
| 68 |
if service in ["download game", "upload game", "list games"]:
|
| 69 |
res = app_util.file_service(service, nlp_command, db_token)
|
| 70 |
-
if
|
| 71 |
outp = {"status": "Failure"}
|
| 72 |
else:
|
| 73 |
outp = {"status": "OK", "result": res}
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
from extract import extract
|
| 8 |
import app_util
|
| 9 |
+
from pgsoft.pgconst.const import service_list, functionality_list
|
| 10 |
from pgsoft.pghost import ais
|
| 11 |
from pgsoft.pgdate.date_utils import beijing
|
| 12 |
import call_pgai
|
|
|
|
| 15 |
#######################
|
| 16 |
# proxy version
|
| 17 |
#######################
|
| 18 |
+
proxy_version = "1.0.0-2024-01-18-a" # reconstruct ai calling
|
| 19 |
|
| 20 |
t = datetime.now()
|
| 21 |
t = t.astimezone(ZoneInfo("Asia/Shanghai"))
|
|
|
|
| 27 |
identity = os.environ.get("identity")
|
| 28 |
print(f"identity: {identity}")
|
| 29 |
if not identity:
|
| 30 |
+
identity = "watermelon"
|
| 31 |
ai = "stevez-ai-dev"
|
| 32 |
if identity in ais:
|
| 33 |
ai = ais[identity]
|
|
|
|
| 67 |
print(f"<<<<<<<<<<<<<< service starts at {service_start} <<<<<<<<<<<<<<")
|
| 68 |
if service in ["download game", "upload game", "list games"]:
|
| 69 |
res = app_util.file_service(service, nlp_command, db_token)
|
| 70 |
+
if res is None:
|
| 71 |
outp = {"status": "Failure"}
|
| 72 |
else:
|
| 73 |
outp = {"status": "OK", "result": res}
|
app_util.py
CHANGED
|
@@ -37,7 +37,7 @@ def call_logger(log_info, caller, hf_token) -> None:
|
|
| 37 |
print(f"calling logger ends at {calling_end}, costs {timecost:.2f}s")
|
| 38 |
|
| 39 |
|
| 40 |
-
dataset_id = "
|
| 41 |
local_dir = "game"
|
| 42 |
if not os.path.exists(local_dir):
|
| 43 |
os.mkdir(local_dir)
|
|
@@ -134,7 +134,7 @@ def file_service(service, arg: str, token: str):
|
|
| 134 |
repo_type="dataset",
|
| 135 |
token=token,
|
| 136 |
)
|
| 137 |
-
if
|
| 138 |
return None
|
| 139 |
games = {item.split(".")[0]: item for item in games if len(item) >= 32}
|
| 140 |
print(f"[{service}] OK")
|
|
|
|
| 37 |
print(f"calling logger ends at {calling_end}, costs {timecost:.2f}s")
|
| 38 |
|
| 39 |
|
| 40 |
+
dataset_id = "pgsoft/watermelon"
|
| 41 |
local_dir = "game"
|
| 42 |
if not os.path.exists(local_dir):
|
| 43 |
os.mkdir(local_dir)
|
|
|
|
| 134 |
repo_type="dataset",
|
| 135 |
token=token,
|
| 136 |
)
|
| 137 |
+
if games is None:
|
| 138 |
return None
|
| 139 |
games = {item.split(".")[0]: item for item in games if len(item) >= 32}
|
| 140 |
print(f"[{service}] OK")
|
call_pgai.py
CHANGED
|
@@ -29,6 +29,8 @@ def post_to_pgai_helper(command: str) -> Any:
|
|
| 29 |
return None
|
| 30 |
|
| 31 |
|
|
|
|
|
|
|
| 32 |
def call_pgai(service, game, functionality, nlp_command, url, hf_token):
|
| 33 |
calling_start = beijing()
|
| 34 |
print(f"calling ai starts at {calling_start}")
|
|
|
|
| 29 |
return None
|
| 30 |
|
| 31 |
|
| 32 |
+
from_cache = True
|
| 33 |
+
# @cache
|
| 34 |
def call_pgai(service, game, functionality, nlp_command, url, hf_token):
|
| 35 |
calling_start = beijing()
|
| 36 |
print(f"calling ai starts at {calling_start}")
|