AI-B commited on
Commit
64d7563
1 Parent(s): aa43295

Update app.py

Browse files

We explicitly create the /tmp/gradio/ directory if it does not exist.
We set the GRADIO_CACHE directory to the newly created directory.
This should help resolve the FileNotFoundError and ensure the Gradio application can create temporary files as needed.

Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -10,7 +10,8 @@ from langchain_chroma import Chroma
10
  from chromadb import Documents, EmbeddingFunction, Embeddings
11
  from chromadb.config import Settings
12
  import chromadb #import HttpClient
13
- import os
 
14
  import re
15
  import uuid
16
  import gradio as gr
@@ -27,6 +28,13 @@ os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
27
  os.environ['CUDA_CACHE_DISABLE'] = '1'
28
 
29
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
 
 
 
 
 
 
30
 
31
  ### Utils
32
  hf_token, yi_token = load_env_variables()
 
10
  from chromadb import Documents, EmbeddingFunction, Embeddings
11
  from chromadb.config import Settings
12
  import chromadb #import HttpClient
13
+ import os
14
+ import tempfile
15
  import re
16
  import uuid
17
  import gradio as gr
 
28
  os.environ['CUDA_CACHE_DISABLE'] = '1'
29
 
30
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
31
+
32
+ # Ensure the temporary directory exists
33
+ temp_dir = '/tmp/gradio/'
34
+ os.makedirs(temp_dir, exist_ok=True)
35
+
36
+ # Set Gradio cache directory
37
+ gr.components.file.GRADIO_CACHE = temp_dir
38
 
39
  ### Utils
40
  hf_token, yi_token = load_env_variables()