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

Function simple_analyzer

solutions/ui/simple_rag_ui_with_streamlit.py:31–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29
30
31def simple_analyzer ():
32
33 st.title("Simple RAG Analyzer")
34
35 prompter = Prompt()
36
37 sample_files_path = Setup().load_sample_files(over_write=False)
38 doc_path = os.path.join(sample_files_path, "Invoices")
39
40 files = os.listdir(doc_path)
41 file_name = st.selectbox("Choose an Invoice", files)
42
43 prompt_text = st.text_area("Question (hint: 'what is the total amount of the invoice?'")
44
45 model_name = st.selectbox("Choose a model for answering questions", ["bling-phi-3-gguf",
46 "bling-tiny-llama-1b",
47 "bling-stablelm-3b-tool",
48 "llama-3-instruct-bartowski-gguf",
49 "dragon-llama-answer-tool"])
50
51 if st.button("Run Analysis"):
52
53 if file_name and prompt_text and model_name:
54
55 prompter.load_model(model_name, temperature=0.0, sample=False)
56
57 # parse the PDF in memory and attach to the prompt
58 sources = prompter.add_source_document(doc_path,file_name)
59
60 # run the inference with the source
61 response = prompter.prompt_with_source(prompt_text)
62
63 # fact checks
64 fc = prompter.evidence_check_numbers(response)
65 cs = prompter.evidence_check_sources(response)
66
67 if len(response) > 0:
68 if "llm_response" in response[0]:
69 response = response[0]["llm_response"]
70
71 st.write(f"Answer: {response}")
72
73 if len(fc) > 0:
74 if "fact_check" in fc[0]:
75 fc_out = fc[0]["fact_check"]
76 st.write(f"Numbers Check: {fc_out}")
77
78 if len(cs) > 0:
79 if "source_review" in cs[0]:
80 sr_out = cs[0]["source_review"]
81 st.write(f"Source review: {sr_out}")
82
83
84if __name__ == "__main__":

Callers 1

Calls 9

load_modelMethod · 0.95
add_source_documentMethod · 0.95
prompt_with_sourceMethod · 0.95
PromptClass · 0.90
SetupClass · 0.90
load_sample_filesMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected