FreshP commited on
Commit
7e21fe0
1 Parent(s): d0631f5

Added access key

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -2,10 +2,13 @@ import gradio as gr
2
  import numpy as np
3
  import pandas as pd
4
  from datetime import datetime
 
5
 
6
  from huggingface_hub import hf_hub_url, cached_download
7
  from gensim.models.fasttext import load_facebook_model
8
 
 
 
9
  # download model from huggingface hub
10
  url = hf_hub_url(repo_id="simonschoe/call2vec", filename="model.bin")
11
  cached_download(url)
@@ -21,7 +24,7 @@ def process(_input, topn):
21
 
22
  _input = [s for s in _input if s]
23
 
24
- if _input[0] != "secret_result_key":
25
  with open('log.txt', 'a') as f:
26
  f.write(str(datetime.now()) + '+++' + '___'.join(_input) + '\n')
27
 
@@ -38,7 +41,7 @@ def process(_input, topn):
38
  frequencies = [model.wv.get_vecattr(nn[0], 'count') for nn in nearest_neighbors]
39
 
40
  result = pd.DataFrame([(a[0],a[1],b) for a,b in zip(nearest_neighbors, frequencies)], columns=['Token', 'Cosine Similarity', 'Frequency'])
41
- if _input[0] == "secret_result_key":
42
  with open('log.txt', 'r') as f:
43
  prompts = f.readlines()
44
  prompts = [p.strip().split('+++') for p in prompts]
 
2
  import numpy as np
3
  import pandas as pd
4
  from datetime import datetime
5
+ import os
6
 
7
  from huggingface_hub import hf_hub_url, cached_download
8
  from gensim.models.fasttext import load_facebook_model
9
 
10
+ ACCESS_KEY = os.environ.get('ACCESS_KEY')
11
+
12
  # download model from huggingface hub
13
  url = hf_hub_url(repo_id="simonschoe/call2vec", filename="model.bin")
14
  cached_download(url)
 
24
 
25
  _input = [s for s in _input if s]
26
 
27
+ if _input[0] != ACCESS_KEY:
28
  with open('log.txt', 'a') as f:
29
  f.write(str(datetime.now()) + '+++' + '___'.join(_input) + '\n')
30
 
 
41
  frequencies = [model.wv.get_vecattr(nn[0], 'count') for nn in nearest_neighbors]
42
 
43
  result = pd.DataFrame([(a[0],a[1],b) for a,b in zip(nearest_neighbors, frequencies)], columns=['Token', 'Cosine Similarity', 'Frequency'])
44
+ if _input[0] == ACCESS_KEY:
45
  with open('log.txt', 'r') as f:
46
  prompts = f.readlines()
47
  prompts = [p.strip().split('+++') for p in prompts]