-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path24_groq_llama_parser.py
More file actions
36 lines (31 loc) · 1.18 KB
/
24_groq_llama_parser.py
File metadata and controls
36 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from llama_parse import LlamaParse
from llama_index.llms.groq import Groq
from llama_parse.base import ResultType, Language
from llama_index.core.node_parser import MarkdownElementNodeParser
parser = LlamaParse(
api_key="xxx",
result_type=ResultType.MD,
language=Language.ENGLISH,
parsing_instructions="""\
The document is an exam documents. \
It contains many tables and images. \
Do not parse neither the definition, nor requirements, nor explanation sections.\
""",
)
llm = Groq(
model="llama3-8b-8192",
api_key="xxx",
)
documents = parser.load_data("path/to/file.pdf")
node_parser = MarkdownElementNodeParser(
llm=llm,
summary_query_str="""
The document is a property valuation documents. \
It shows the key metrics for a property sale. \
The paper includes detailed figures like the price, the size of the property, \
the year of construction, the number of bedrooms and bathrooms. \
Answer questions using the information in this document and be precise. \
Skip lines for each bullet point. \
Answer with only one number if asked for it.""",
)
nodes = node_parser.get_nodes_from_documents(documents)