Spaces:
Starting
on
A10G
Starting
on
A10G
tricktreat
commited on
Commit
•
f9e538f
1
Parent(s):
cd08eb6
log optional
Browse files- awesome_chat.py +7 -5
awesome_chat.py
CHANGED
@@ -25,7 +25,6 @@ from huggingface_hub.inference_api import ALL_TASKS
|
|
25 |
from models_server import models, status
|
26 |
from functools import partial
|
27 |
from huggingface_hub import Repository
|
28 |
-
import huggingface_hub
|
29 |
|
30 |
parser = argparse.ArgumentParser()
|
31 |
parser.add_argument("--config", type=str, default="config.yaml.dev")
|
@@ -44,9 +43,10 @@ now = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
|
44 |
|
45 |
DATASET_REPO_URL = "https://huggingface.co/datasets/tricktreat/HuggingGPT_logs"
|
46 |
LOG_HF_TOKEN = os.environ.get("LOG_HF_TOKEN")
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
50 |
|
51 |
logger = logging.getLogger(__name__)
|
52 |
logger.setLevel(logging.DEBUG)
|
@@ -204,6 +204,7 @@ def get_id_reason(choose_str):
|
|
204 |
def record_case(success, **args):
|
205 |
# time format
|
206 |
global now
|
|
|
207 |
if success:
|
208 |
f = open(f"logs/log_success_{now}.jsonl", "a")
|
209 |
else:
|
@@ -211,7 +212,8 @@ def record_case(success, **args):
|
|
211 |
log = args
|
212 |
f.write(json.dumps(log) + "\n")
|
213 |
f.close()
|
214 |
-
|
|
|
215 |
|
216 |
def image_to_bytes(img_url):
|
217 |
img_byte = io.BytesIO()
|
|
|
25 |
from models_server import models, status
|
26 |
from functools import partial
|
27 |
from huggingface_hub import Repository
|
|
|
28 |
|
29 |
parser = argparse.ArgumentParser()
|
30 |
parser.add_argument("--config", type=str, default="config.yaml.dev")
|
|
|
43 |
|
44 |
DATASET_REPO_URL = "https://huggingface.co/datasets/tricktreat/HuggingGPT_logs"
|
45 |
LOG_HF_TOKEN = os.environ.get("LOG_HF_TOKEN")
|
46 |
+
if LOG_HF_TOKEN:
|
47 |
+
repo = Repository(
|
48 |
+
local_dir="logs", clone_from=DATASET_REPO_URL, use_auth_token=LOG_HF_TOKEN
|
49 |
+
)
|
50 |
|
51 |
logger = logging.getLogger(__name__)
|
52 |
logger.setLevel(logging.DEBUG)
|
|
|
204 |
def record_case(success, **args):
|
205 |
# time format
|
206 |
global now
|
207 |
+
global LOG_HF_TOKEN
|
208 |
if success:
|
209 |
f = open(f"logs/log_success_{now}.jsonl", "a")
|
210 |
else:
|
|
|
212 |
log = args
|
213 |
f.write(json.dumps(log) + "\n")
|
214 |
f.close()
|
215 |
+
if LOG_HF_TOKEN:
|
216 |
+
commit_url = repo.push_to_hub(blocking=True)
|
217 |
|
218 |
def image_to_bytes(img_url):
|
219 |
img_byte = io.BytesIO()
|