Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,11 @@
|
|
1 |
import os
|
|
|
2 |
import torch
|
|
|
3 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, TextIteratorStreamer
|
4 |
from transformers.generation import LogitsProcessor
|
|
|
|
|
5 |
from threading import Thread
|
6 |
import gradio as gr
|
7 |
|
@@ -44,6 +48,9 @@ LANGUAGE_IDS = {
|
|
44 |
STATS_REPO = "https://huggingface.co/datasets/ltg/usage_statistics"
|
45 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
46 |
|
|
|
|
|
|
|
47 |
|
48 |
# log the timestamp of the query
|
49 |
def add_anonymous_usage_log(path):
|
@@ -57,7 +64,7 @@ def add_anonymous_usage_log(path):
|
|
57 |
except:
|
58 |
shutil.rmtree("data")
|
59 |
dataset = Repository(
|
60 |
-
local_dir="data", clone_from=
|
61 |
)
|
62 |
with open(path, "a") as f:
|
63 |
line = json.dumps(str(datetime.now()), ensure_ascii=False)
|
|
|
1 |
import os
|
2 |
+
import json
|
3 |
import torch
|
4 |
+
import shutil
|
5 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, TextIteratorStreamer
|
6 |
from transformers.generation import LogitsProcessor
|
7 |
+
import huggingface_hub
|
8 |
+
from huggingface_hub import Repository
|
9 |
from threading import Thread
|
10 |
import gradio as gr
|
11 |
|
|
|
48 |
STATS_REPO = "https://huggingface.co/datasets/ltg/usage_statistics"
|
49 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
50 |
|
51 |
+
dataset = Repository(
|
52 |
+
local_dir="data", clone_from=STATS_REPO, use_auth_token=HF_TOKEN
|
53 |
+
)
|
54 |
|
55 |
# log the timestamp of the query
|
56 |
def add_anonymous_usage_log(path):
|
|
|
64 |
except:
|
65 |
shutil.rmtree("data")
|
66 |
dataset = Repository(
|
67 |
+
local_dir="data", clone_from=STATS_REPO, use_auth_token=HF_TOKEN
|
68 |
)
|
69 |
with open(path, "a") as f:
|
70 |
line = json.dumps(str(datetime.now()), ensure_ascii=False)
|