Beracles commited on
Commit
6b5f037
·
1 Parent(s): fe124ca

enable file service

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +4 -4
  3. app_util.py +2 -2
.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, game_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-02-a" # reconstruct ai calling
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 = "pgdemo_dev"
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 not res:
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 = "hubei-hunan/games"
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 not games:
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")