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)
| 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 |
no test coverage detected