Ark4u commited on
Commit
523f2d1
·
verified ·
1 Parent(s): a5a9d98

Deploy OmniAssistant smolagent (Hugging Face Agents Course Unit 1)

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +13 -0
Gradio_UI.py CHANGED
@@ -24,6 +24,18 @@ from smolagents.agents import ActionStep, MultiStepAgent
24
  from smolagents.memory import MemoryStep
25
  from smolagents.utils import _is_package_available
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  def pull_messages_from_step(
29
  step_log: MemoryStep,
@@ -189,6 +201,7 @@ class GradioUI:
189
  if not os.path.exists(file_upload_folder):
190
  os.mkdir(file_upload_folder)
191
 
 
192
  def interact_with_agent(self, prompt, messages):
193
  import gradio as gr
194
 
 
24
  from smolagents.memory import MemoryStep
25
  from smolagents.utils import _is_package_available
26
 
27
+ try:
28
+ import spaces
29
+ except Exception:
30
+ class _MockSpaces:
31
+ def GPU(self, *args, **kwargs):
32
+ if args and callable(args[0]):
33
+ return args[0]
34
+ def decorator(f):
35
+ return f
36
+ return decorator
37
+ spaces = _MockSpaces()
38
+
39
 
40
  def pull_messages_from_step(
41
  step_log: MemoryStep,
 
201
  if not os.path.exists(file_upload_folder):
202
  os.mkdir(file_upload_folder)
203
 
204
+ @spaces.GPU(duration=120)
205
  def interact_with_agent(self, prompt, messages):
206
  import gradio as gr
207