cnshdd commited on
Commit
ff71ec6
·
verified ·
1 Parent(s): 2bf5ffa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -1,6 +1,15 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
  import minijinja
 
 
 
 
 
 
 
 
 
4
 
5
  """
6
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
@@ -39,7 +48,9 @@ def respond(
39
  response += token
40
  yield response
41
  except Exception as e:
42
- yield f"An error occurred: {e}"
 
 
43
 
44
  demo = gr.ChatInterface(
45
  respond,
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient, HfApi
3
  import minijinja
4
+ import sys
5
+ import traceback
6
+
7
+ # Ensure minijinja is installed
8
+ try:
9
+ import minijinja
10
+ except ImportError:
11
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "minijinja"])
12
+ import minijinja
13
 
14
  """
15
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
 
48
  response += token
49
  yield response
50
  except Exception as e:
51
+ error_message = f"An error occurred: {e}\n"
52
+ error_message += ''.join(traceback.format_exception(None, e, e.__traceback__))
53
+ yield error_message
54
 
55
  demo = gr.ChatInterface(
56
  respond,