yyyycc commited on
Commit
949cfbd
·
verified ·
1 Parent(s): 965c78e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -11
app.py CHANGED
@@ -3,7 +3,7 @@ import os
3
  from llama_index.core import VectorStoreIndex, Settings
4
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
5
  from llama_index.llms.huggingface import HuggingFaceLLM
6
- from llama_index.readers import SimpleDirectoryReader # Corrected import
7
 
8
  st.set_page_config(page_title="llama_index_demo", page_icon="🦜🔗")
9
  st.title("llama_index_demo")
@@ -24,16 +24,7 @@ def init_models():
24
  )
25
  Settings.llm = llm
26
 
27
- # 获取 data 文件夹的绝对路径
28
- data_dir_path = os.path.abspath("./data")
29
-
30
- # 加载目录中的所有文件
31
- try:
32
- documents = SimpleDirectoryReader(data_dir_path).load_data()
33
- except Exception as e:
34
- st.error(f"Error loading data from directory {data_dir_path}: {e}")
35
- return None
36
-
37
  index = VectorStoreIndex.from_documents(documents)
38
  query_engine = index.as_query_engine()
39
 
 
3
  from llama_index.core import VectorStoreIndex, Settings
4
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
5
  from llama_index.llms.huggingface import HuggingFaceLLM
6
+ from llama_index import SimpleDirectoryReader # Corrected import
7
 
8
  st.set_page_config(page_title="llama_index_demo", page_icon="🦜🔗")
9
  st.title("llama_index_demo")
 
24
  )
25
  Settings.llm = llm
26
 
27
+ documents = SimpleDirectoryReader("./").load_data()
 
 
 
 
 
 
 
 
 
28
  index = VectorStoreIndex.from_documents(documents)
29
  query_engine = index.as_query_engine()
30