Khanmx99 commited on
Commit
785b4e2
·
verified ·
1 Parent(s): 554f37f

Deploy Pak Angels AI Tutor

Browse files
Files changed (3) hide show
  1. README.md +4 -0
  2. app.py +24 -0
  3. requirements.txt +1 -0
README.md CHANGED
@@ -7,6 +7,7 @@ sdk: gradio
7
  sdk_version: 5.50.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  # Pak Angels AI Tutor
@@ -194,6 +195,9 @@ testing, run `python app.py`.
194
  Hugging Face build failures: Review the Space build logs, confirm all required
195
  files are uploaded, and check that only necessary dependencies are listed.
196
 
 
 
 
197
  ## Security
198
 
199
  - API keys must never be committed to Git.
 
7
  sdk_version: 5.50.0
8
  app_file: app.py
9
  pinned: false
10
+ suggested_hardware: zero-a10g
11
  ---
12
 
13
  # Pak Angels AI Tutor
 
195
  Hugging Face build failures: Review the Space build logs, confirm all required
196
  files are uploaded, and check that only necessary dependencies are listed.
197
 
198
+ ZeroGPU or GPU startup error: This app does not need GPU hardware. In the Space
199
+ Settings, set Hardware to a CPU option such as CPU Basic, then restart the Space.
200
+
201
  ## Security
202
 
203
  - API keys must never be committed to Git.
app.py CHANGED
@@ -9,6 +9,29 @@ from openai_service import format_openai_error, stream_tutor_response
9
  from prompts import ABOUT_PAK_ANGELS, MODULES, build_system_instructions
10
 
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  PRIVACY_NOTICE = (
13
  "Privacy notice: Do not enter confidential, proprietary, financial, medical, "
14
  "personal, or otherwise sensitive information into the AI Tutor."
@@ -171,6 +194,7 @@ def generate_response(history: list[dict[str, str]] | None, module_name: str):
171
  yield history
172
 
173
 
 
174
  def submit_message(message: str, history: list[dict[str, str]] | None, module_name: str):
175
  textbox, updated_history = add_user_message(message, history)
176
  yield textbox, updated_history
 
9
  from prompts import ABOUT_PAK_ANGELS, MODULES, build_system_instructions
10
 
11
 
12
+ BUILD_ID = "pak-angels-zerogpu-2026-07-11-v2"
13
+
14
+
15
+ try:
16
+ import spaces
17
+ except ImportError:
18
+ class _SpacesFallback:
19
+ @staticmethod
20
+ def GPU(*args, **kwargs):
21
+ if args and callable(args[0]) and len(args) == 1 and not kwargs:
22
+ return args[0]
23
+
24
+ def decorator(function):
25
+ return function
26
+
27
+ return decorator
28
+
29
+ spaces = _SpacesFallback()
30
+
31
+
32
+ print(f"Starting {APP_NAME} build {BUILD_ID}")
33
+
34
+
35
  PRIVACY_NOTICE = (
36
  "Privacy notice: Do not enter confidential, proprietary, financial, medical, "
37
  "personal, or otherwise sensitive information into the AI Tutor."
 
194
  yield history
195
 
196
 
197
+ @spaces.GPU(duration=120)
198
  def submit_message(message: str, history: list[dict[str, str]] | None, module_name: str):
199
  textbox, updated_history = add_user_message(message, history)
200
  yield textbox, updated_history
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  gradio>=5.50,<6
2
  openai>=1.93,<2
 
 
1
  gradio>=5.50,<6
2
  openai>=1.93,<2
3
+ spaces>=0.35,<1