Docfile commited on
Commit
40562b6
·
verified ·
1 Parent(s): 36ee523

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -7,7 +7,11 @@ logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
7
 
8
  GOOGLE_API_KEY = "AIzaSyDYhyRoOWBJWOb4bqY5wmFLrBo4HTwQDko" # add your GOOGLE API key here
9
  os.environ["GOOGLE_API_KEY"] = GOOGLE_API_KEY
 
 
10
 
 
 
11
  from g4f import Provider, models
12
  from langchain.llms.base import LLM
13
 
@@ -44,13 +48,28 @@ embed_model = GeminiEmbedding(
44
  )
45
  Settings.embed_model = embed_model
46
  # Reads pdfs at "./" path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  documents = (
48
  SimpleDirectoryReader(
49
  input_dir = 'data',
50
  required_exts = [".pdf"])
51
  .load_data()
52
  )
53
-
54
  # ServiceContext is a bundle of commonly used
55
  # resources used during the indexing and
56
  # querying stage
 
7
 
8
  GOOGLE_API_KEY = "AIzaSyDYhyRoOWBJWOb4bqY5wmFLrBo4HTwQDko" # add your GOOGLE API key here
9
  os.environ["GOOGLE_API_KEY"] = GOOGLE_API_KEY
10
+ import nest_asyncio
11
+ nest_asyncio.apply()
12
 
13
+ from llama_parse import LlamaParse
14
+ from llama_index.core import SimpleDirectoryReader
15
  from g4f import Provider, models
16
  from langchain.llms.base import LLM
17
 
 
48
  )
49
  Settings.embed_model = embed_model
50
  # Reads pdfs at "./" path
51
+
52
+
53
+
54
+ parser = LlamaParse(
55
+ api_key="llx-KMCDGpt3Yn89wwOYJXaFDfJLHTbUQbnTKVccaGVHJLfAN96w", # can also be set in your env as LLAMA_CLOUD_API_KEY
56
+ result_type="markdown", # "markdown" and "text" are available
57
+ verbose=True
58
+ )
59
+
60
+ file_extractor = {".pdf": parser}
61
+ documents = SimpleDirectoryReader("./data", file_extractor=file_extractor).load_data()
62
+
63
+
64
+ """
65
+
66
  documents = (
67
  SimpleDirectoryReader(
68
  input_dir = 'data',
69
  required_exts = [".pdf"])
70
  .load_data()
71
  )
72
+ """
73
  # ServiceContext is a bundle of commonly used
74
  # resources used during the indexing and
75
  # querying stage