joey1101 commited on
Commit
cb7a285
·
verified ·
1 Parent(s): 87a1c98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -1,4 +1,24 @@
1
  # -*- coding: utf-8 -*-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from ipex_llm.transformers import AutoModelForCausalLM
3
  from transformers import LlamaTokenizer
4
 
 
1
  # -*- coding: utf-8 -*-
2
+ import os
3
+ import contextlib
4
+
5
+ @contextlib.contextmanager
6
+ def new_cd(x):
7
+ d = os.getcwd()
8
+
9
+ # This could raise an exception, but it's probably
10
+ # best to let it propagate and let the caller
11
+ # deal with it, since they requested x
12
+ os.chdir(x)
13
+
14
+ try:
15
+ yield
16
+
17
+ finally:
18
+ # This could also raise an exception, but you *really*
19
+ # aren't equipped to figure out what went wrong if the
20
+ # old working directory can't be restored.
21
+ os.chdir(d)
22
  from ipex_llm.transformers import AutoModelForCausalLM
23
  from transformers import LlamaTokenizer
24