MCPcopy
hub / github.com/llmware-ai/llmware / test_summarize_document

Function test_summarize_document

solutions/models/document_summarizer.py:12–62  ·  view source on GitHub ↗
(example="jd salinger")

Source from the content-addressed store, hash-verified

10
11
12def test_summarize_document(example="jd salinger"):
13
14 # pull a sample document (or substitute a file_path and file_name of your own)
15 sample_files_path = Setup().load_sample_files(over_write=False)
16
17 topic = None
18 query = None
19 fp = None
20 fn = None
21
22 if example not in ["jd salinger", "employment terms", "just the comp", "un resolutions"]:
23 print ("not found example")
24 return []
25
26 if example == "jd salinger":
27 fp = os.path.join(sample_files_path, "SmallLibrary")
28 fn = "Jd-Salinger-Biography.docx"
29 topic = "jd salinger"
30 query = None
31
32 if example == "employment terms":
33 fp = os.path.join(sample_files_path, "Agreements")
34 fn = "Athena EXECUTIVE EMPLOYMENT AGREEMENT.pdf"
35 topic = "executive compensation terms"
36 query = None
37
38 if example == "just the comp":
39 fp = os.path.join(sample_files_path, "Agreements")
40 fn = "Athena EXECUTIVE EMPLOYMENT AGREEMENT.pdf"
41 topic = "executive compensation terms"
42 query = "base salary"
43
44 if example == "un resolutions":
45 fp = os.path.join(sample_files_path, "SmallLibrary")
46 fn = "N2126108.pdf"
47 # fn = "N2137825.pdf"
48 topic = "key points"
49 query = None
50
51 # optional parameters: 'query' - will select among blocks with the query term
52 # 'topic' - will pass a topic/issue as the parameter to the model to 'focus' the summary
53 # 'max_batch_cap' - caps the number of batches sent to the model
54 # 'text_only' - returns just the summary text aggregated
55
56 kp = Prompt().summarize_document_fc(fp, fn, topic=topic, query=query, text_only=True, max_batch_cap=15)
57
58 print(f"\nDocument summary completed - {len(kp)} Points")
59 for i, points in enumerate(kp):
60 print(i, points)
61
62 return 0
63
64
65if __name__ == "__main__":

Callers 1

Calls 4

SetupClass · 0.90
PromptClass · 0.90
load_sample_filesMethod · 0.80
summarize_document_fcMethod · 0.80

Tested by

no test coverage detected