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

Method add_source_document

llmware/prompts.py:488–509  ·  view source on GitHub ↗

Attach a document directly to a prompt object by passing the folder path and file name of the source document, and an optional query filter.

(self, input_fp,input_fn, query=None)

Source from the content-addressed store, hash-verified

486 return sources
487
488 def add_source_document(self, input_fp,input_fn, query=None):
489
490 """ Attach a document directly to a prompt object by passing the folder path and file name of the source
491 document, and an optional query filter. """
492
493 # example: intended for use to rapidly parse and add a document (of any type) from local file to a prompt
494
495 output = Parser().parse_one(input_fp,input_fn)
496
497 # run in memory filtering to sub-select from document only items matching query
498 if query:
499 if output:
500 output = Utilities().fast_search_dicts(query, output, remove_stop_words=True)
501
502 if not output: output = []
503
504 sources = Sources(self).package_source(output, aggregate_source=True)
505
506 if not sources["text_batch"]:
507 logger.warning("No source added in .add_source_document.")
508
509 return sources
510
511 def add_source_last_interaction_step(self):
512

Callers 11

prompt_sourceFunction · 0.95
simple_analyzerFunction · 0.95
summarize_document_fcMethod · 0.95
invoice_processingFunction · 0.80
prompt_with_sourcesFunction · 0.80
prompt_with_sourcesFunction · 0.80
__Function · 0.80

Calls 6

ParserClass · 0.90
UtilitiesClass · 0.90
SourcesClass · 0.90
parse_oneMethod · 0.80
fast_search_dictsMethod · 0.80
package_sourceMethod · 0.80

Tested by

no test coverage detected