langchain/tests/unit_tests
felpigeon 2791a753bf
Add start index to metadata in TextSplitter (#5912)
<!--
Thank you for contributing to LangChain! Your PR will appear in our
release under the title you set. Please make sure it highlights your
valuable contribution.

Replace this with a description of the change, the issue it fixes (if
applicable), and relevant context. List any dependencies required for
this change.

After you're done, someone will review your PR. They may suggest
improvements. If no one reviews your PR within a few days, feel free to
@-mention the same people again, as notifications can get lost.

Finally, we'd love to show appreciation for your contribution - if you'd
like us to shout you out on Twitter, please also include your handle!
-->

#### Add start index to metadata in TextSplitter

- Modified method `create_documents` to track start position of each
chunk
- The `start_index` is included in the metadata if the `add_start_index`
parameter in the class constructor is set to `True`

This enables referencing back to the original document, particularly
useful when a specific chunk is retrieved.

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on
network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests,
lint
etc:


https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

#### Who can review?

Tag maintainers/contributors who might be interested:
@eyurtsev @agola11
<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
2023-06-08 23:09:32 -07:00
..
agents Raise an exception in MKRL and Chat Output Parsers if parsing text which contains both an action and a final answer (#5609) 2023-06-04 14:40:49 -07:00
callbacks py tracer fixes (#5377) 2023-05-30 18:47:06 -07:00
chains support returning run info for llms, chat models and chains (#5666) 2023-06-06 10:07:46 -07:00
chat_models Add ChatModel, LLM, and Embeddings for Google's PaLM APIs (#3575) 2023-05-01 15:23:16 -07:00
client Use client from LCP-SDK (#5695) 2023-06-06 06:51:05 -07:00
data Prompt from file proof of concept using plain text (#127) 2022-11-13 13:15:30 -08:00
docstore Add DocstoreFn - lookup doc via arbitrary function (#3760) 2023-04-28 19:50:32 -07:00
document_loaders YoutubeAudioLoader and updates to OpenAIWhisperParser (#5772) 2023-06-06 15:15:08 -07:00
evaluation Adding an in-context QA evaluation chain + chain of thought reasoning chain for improved accuracy (#2444) 2023-04-06 22:32:41 -07:00
examples feat #4479: TextLoader auto detect encoding and improved exceptions (#4927) 2023-05-18 09:55:14 -04:00
llms Add Invocation Params (#4509) 2023-05-11 15:34:06 -07:00
memory Implemented appending arbitrary messages (#5293) 2023-05-29 07:18:59 -07:00
output_parsers convert the parameter 'text' to uppercase in the function 'parse' of the class BooleanOutputParser (#5397) 2023-05-30 16:26:17 -07:00
prompts Harrison/pipeline prompt (#5540) 2023-06-04 14:29:37 -07:00
retrievers Zep Hybrid Search (#5742) 2023-06-05 12:59:28 -07:00
tools Harrison/pubmed integration (#5664) 2023-06-03 16:25:28 -07:00
utilities Fix graphql tool (#4984) 2023-05-19 15:27:50 -07:00
vectorstores Add maximal relevance search to SKLearnVectorStore (#5430) 2023-05-30 16:13:33 -07:00
__init__.py initial commit 2022-10-24 14:51:15 -07:00
conftest.py Add pytest --only-extended and --only-core options (#4494) 2023-05-12 11:35:22 -04:00
test_bash.py Add Mastodon toots loader (#5036) 2023-05-22 16:43:07 -07:00
test_dependencies.py Use client from LCP-SDK (#5695) 2023-06-06 06:51:05 -07:00
test_document_transformers.py Contextual compression retriever (#2915) 2023-04-20 17:01:14 -07:00
test_formatting.py initial commit 2022-10-24 14:51:15 -07:00
test_math_utils.py add get_top_k_cosine_similarity method to get max top k score and index (#5059) 2023-05-22 11:55:48 -07:00
test_pytest_config.py Block sockets for unit-tests (#4803) 2023-05-16 14:41:24 -04:00
test_python.py option for csv agent to not include df in prompt (#4610) 2023-05-12 21:55:22 -07:00
test_schema.py [simple][test] Added test case for schema.py (#3692) 2023-04-28 20:42:24 -07:00
test_sql_database_schema.py Suppress duckdb warning in unit tests explicitly (#3653) 2023-04-27 14:29:41 -04:00
test_sql_database.py Fix SQLAlchemy truncating text when it is too big (#5206) 2023-06-01 21:33:31 -04:00
test_text_splitter.py Add start index to metadata in TextSplitter (#5912) 2023-06-08 23:09:32 -07:00