Gregor Betz commited on
Commit
3b07048
1 Parent(s): 8bd8cd0
Files changed (3) hide show
  1. .gitignore +140 -0
  2. app.py +10 -2
  3. requirements.txt +1 -2
.gitignore ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ pip-wheel-metadata/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+ db.sqlite3
61
+ db.sqlite3-journal
62
+
63
+ # Flask stuff:
64
+ instance/
65
+ .webassets-cache
66
+
67
+ # Scrapy stuff:
68
+ .scrapy
69
+
70
+ # Sphinx documentation
71
+ docs/_build/
72
+
73
+ # PyBuilder
74
+ target/
75
+
76
+ # Jupyter Notebook
77
+ .ipynb_checkpoints
78
+
79
+ # IPython
80
+ profile_default/
81
+ ipython_config.py
82
+
83
+ # pyenv
84
+ .python-version
85
+
86
+ # pipenv
87
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
89
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
90
+ # install all needed dependencies.
91
+ #Pipfile.lock
92
+
93
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
94
+ __pypackages__/
95
+
96
+ # Celery stuff
97
+ celerybeat-schedule
98
+ celerybeat.pid
99
+
100
+ # SageMath parsed files
101
+ *.sage.py
102
+
103
+ # Environments
104
+ .env
105
+ .venv
106
+ .venv*
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+ .venv*
113
+
114
+ # Spyder project settings
115
+ .spyderproject
116
+ .spyproject
117
+
118
+ # Rope project settings
119
+ .ropeproject
120
+
121
+ # mkdocs documentation
122
+ /site
123
+
124
+ # mypy
125
+ .mypy_cache/
126
+ .dmypy.json
127
+ dmypy.json
128
+
129
+ # Pyre type checker
130
+ .pyre/
131
+ .vscode/
132
+ .idea/
133
+
134
+ .DS_Store
135
+
136
+ # Ruff
137
+ .ruff_cache
138
+
139
+ # Spell checker config
140
+ cspell.json
app.py CHANGED
@@ -126,6 +126,8 @@ def new_conversation_id():
126
  return conversation_id
127
 
128
  def access_granted(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> bool:
 
 
129
  if RESTRICT_ACCESS:
130
  known = profile.username in df_users.hf_account.unique()
131
  access = df_users[df_users.hf_account.eq(profile.username)].status.eq("access").iloc[0] if known else False
@@ -196,10 +198,16 @@ async def bot(
196
  raise gr.Error("Please sign in to use the chatbot.")
197
 
198
  if not access_granted(profile, oauth_token):
199
- raise gr.Error("You've not been granted access to use the chatbot. Please reach out to Logikon AI team.")
 
 
 
200
 
201
  if not await gr_server_health():
202
- raise gr.Error("The backend server is not healthy. Please try again later.")
 
 
 
203
 
204
 
205
  print(f"Token (type={type(oauth_token.token)}): ||{oauth_token.token}||")
 
126
  return conversation_id
127
 
128
  def access_granted(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> bool:
129
+ if profile is None or oauth_token is None:
130
+ return False
131
  if RESTRICT_ACCESS:
132
  known = profile.username in df_users.hf_account.unique()
133
  access = df_users[df_users.hf_account.eq(profile.username)].status.eq("access").iloc[0] if known else False
 
198
  raise gr.Error("Please sign in to use the chatbot.")
199
 
200
  if not access_granted(profile, oauth_token):
201
+ raise gr.Error(
202
+ "You've not been granted access to use the chatbot. Please reach out to Logikon AI team.",
203
+ duration=0
204
+ )
205
 
206
  if not await gr_server_health():
207
+ raise gr.Error(
208
+ "The backend server is not healthy, possibly due to ❄️ cold start. Please try again later.",
209
+ duration=0
210
+ )
211
 
212
 
213
  print(f"Token (type={type(oauth_token.token)}): ||{oauth_token.token}||")
requirements.txt CHANGED
@@ -1,5 +1,4 @@
1
- # https://github.com/gradio-app/gradio/pull/7887
2
- gradio@https://gradio-builds.s3.amazonaws.com/9560433a8b9b71e088f233b73a030a9b198c500c/gradio-4.26.0-py3-none-any.whl
3
  aiohttp
4
  datasets
5
  huggingface_hub
 
1
+ gradio==4.37.2
 
2
  aiohttp
3
  datasets
4
  huggingface_hub