39 Commits

Author SHA1 Message Date
Pedram Razavi 7ed5f7f00e textsplitter: add an optional lenFunc to MarkdownTextSplitter
Based on the custom lenFuc supported in RecursiveCharacter splitter in
8734b60555
2025-01-06 15:51:02 -08:00
Travis Cline bf1667feaf lint: fixup lint settings (#1018) 2024-09-13 04:39:28 +00:00
Daniel Bos 84cd854e2d textsplitter: add option to join table rows (#981)
Originally the MarkdownTextSplitter would split tables into chunks
for each row (producing a header + single row) in each chunk. This
change adds an option to join multiple rows into a single chunk.

Fixes: #938
2024-09-12 17:17:04 -07:00
Thorsten Klein 9a27592cf7 textsplitter: add WithHeadingHierarchy option to markdown splitter to retain heading hierarchy in chunks (#898)
add: textsplitter WithHeadingHierarchy option to prepend heading hierarchy to chunks in Markdown documents instead of only current heading
2024-06-20 10:39:46 -04:00
zhangi 09ac6e0531 feat: add WithKeepSeparator option for RecursiveCharacter (#721)
* feat: add WithKeepSeparator option for RecursiveCharacter


---------

Co-authored-by: Ivan Zhang <zhangi@sea.com>
2024-05-07 00:47:20 -04:00
Travis Cline b6ba6693d3 tooling: Update minimum go version to 1.22, update golangci-lint (#722)
* go: Update to go 1.22, update golangci-lint config

* lint: Address various lint issues

* chains: fix lint complaint in TestApplyWithCanceledContext

* lint: Address addtional lint issues

* lint: Address addtional lint issues

* tools: update golangci-lint to 1.57
2024-03-26 20:31:20 +00:00
Travis Cline 3f4ee00ffb textsplitter: remove wrapper 2024-02-20 15:59:38 -08:00
whyiug ba73deaf10 Refactor lenFunc to use utf8.RuneCountInString 2024-02-19 16:45:03 +08:00
whyiug a63d3a9990 add new textspliter option: lenfunc 2024-02-11 23:50:18 +08:00
yangrui1 8734b60555 add new textspliter option: lenfunc 2024-02-08 17:33:05 +08:00
yangrui1 677c14c69b add nolint:funlen 2024-02-08 15:51:28 +08:00
yangrui1 53d6410f18 fix: stackoverflow caused by textspliter 2024-02-08 15:13:13 +08:00
Eli Bendersky e4978f5226 llms: convenience methods to create Parts 2024-01-26 16:43:05 -08:00
Daniel Bos a893441563 textsplitter: refactor splitInline in markdown_splitter
Extracted the logic for handling link closure and image processing into
separate functions. This reduces the complexity of the `splitInline` function,
improving readability and maintainability. Removed unnecessary comments and
linting directives.
2024-01-05 15:10:23 +08:00
Daniel Bos 7f1633c519 textsplitter: enhance markdown splitter tests
Extend the test coverage for the Markdown splitter. The changes include
new tests for code splitting, inline elements, and handling of different
markdown features such as fenced code blocks, hard breaks, emphasis,
strikethrough, images, and links. The changes aim to ensure the robustness
of the Markdown splitter and its ability to handle a variety of markdown
syntaxes.
2024-01-05 14:36:08 +08:00
Daniel Bos c133a0e463 textsplitter: add options for rendering code blocks and reference links
The changes introduce two new options in the MarkdownTextSplitter struct:
CodeBlocks and ReferenceLinks. These options allow users to specify
whether they want to render code blocks and reference links when
splitting a markdown text.

The CodeBlocks option determines whether indented and fenced code
blocks should be rendered. If set to false, these blocks are ignored
during the splitting process.

The ReferenceLinks option determines whether reference links should be
patched with the URL and title from their definition. By default,
reference definitions are dropped from the output.

These changes provide users with more control over how their markdown
text is split, allowing them to include or exclude specific elements
as needed.
2024-01-05 14:23:15 +08:00
Daniel Bos 6cf86c22f4 textsplitter: support reference links in markdown_splitter
The markdown splitter function 'splitInline' has been significantly
enhanced to handle a variety of inline elements as per the CommonMark
specification. Previously, it simply returned the content of the inline
element. Now, it checks for the presence of children in the inline
element and processes them accordingly.

This change was necessary to support reference links, which have the
following format:

```markdown
[foo][bar]

[bar]: /url "title"
```

When this gets parsed, the URL and title from the definition are
added to each reference link and the definition is dropped from the
document. This means when the document is rendered we end up with
incomplete links.

With this change, we render full links instead of references, so the
example above ends up looking like:

```markdown
[foo](/url "title")
```
2024-01-05 14:23:15 +08:00
Daniel Bos 00d75d88b3 textsplitter: render code block, fence, and hr in markdown_splitter
Enhance markdown text splitting functionality by adding handlers for
markdown code blocks, fences, and horizontal rules. This change allows
the markdown splitter to properly process and format these elements,
improving the accuracy of the text splitting process.  However, long
code blocks and fenced blocks will be split as text and won't be
properly wrapped, which is a known limitation that aligns with the
current behavior of the python langchain.
2024-01-05 14:22:46 +08:00
Daniel Bos 536f16c12a textsplitter: handle singular markdown tokens in markdown_splitter (#467)
The markdown splitter was not correctly handling singular markdown tokens
like Hr or Fence. These tokens do not have a corresponding close type,
which was causing issues in the indexOfCloseTag function.

To fix this, a check has been added to return the start index if the
closeType is nil, indicating a singular token. This prevents the function
from incorrectly trying to find a close tag for these tokens and running
past the end of the document.
2023-12-30 03:57:23 -08:00
chyroc 55f772c21a Docs: fix comment typo (#442)
* Docs: fix comment typo

* docs: a llm -> an LLM

---------

Co-authored-by: Travis Cline <travis.cline@gmail.com>
2023-12-20 19:57:37 +00:00
Ismail 80f9027554 fix: golangci-lint v1.55 errors 2023-12-04 22:38:28 -08:00
Edocevol e3b6d21f56 textsplitter: add markdown header text splitter (#274)
* textsplitter: add markdown header text splitter

---------

Co-authored-by: shugenniu <shugenniu@tencent.com>
2023-09-27 12:07:05 -07:00
zivkovicn 2ee9782a24 vertexai-chat | cp 2023-08-22 22:29:06 +02:00
zivkovicn 9e5deb4e3f vertexai-chat | lint 2023-08-22 22:25:12 +02:00
zivkovicn 9e9a8ac002 vertexai-chat | lint 2023-08-22 22:15:00 +02:00
zivkovicn 3612dc5a12 vertexai-chat | lint 2023-08-22 22:10:27 +02:00
Vaayne f61e7ce2a7 fix lint 2023-07-02 22:47:04 +08:00
Vaayne b4ff6fe05a fix lint 2023-07-02 10:23:27 +08:00
Vaayne e503d765fb add new token splitter 2023-07-02 10:06:34 +08:00
Travis Cline 36600e135a Merge pull request #135 from teezzan/feat/add-doc.go-to-all-packages
docs: added package level comments to codebase
2023-06-23 23:46:06 -07:00
Taiwo Hassan Yusuf 02745a9320 Fixed lint issues 2023-06-19 09:57:09 +01:00
Taiwo Hassan Yusuf 4d7a8e246e Added package level comments to codebase 2023-06-19 09:35:48 +01:00
Murilo Santana d3e1424911 document loaders: add csv loader 2023-06-14 15:41:16 -03:00
FluffyKebab 5043cf5f1a textsplitter: fix misspell 2023-04-27 21:26:34 +02:00
FluffyKebab 3718487a7d textsplitter: disable dupword in test 2023-04-26 13:32:49 +02:00
FluffyKebab 9eb6cb6067 textsplitter: add static error 2023-04-26 13:27:52 +02:00
FluffyKebab 6467a7eb77 textsplitter: reduce complexity 2023-04-26 13:13:10 +02:00
FluffyKebab 48509136b6 textsplitter: fix bug 2023-04-26 12:41:12 +02:00
FluffyKebab 5db2ee8181 add textsplitter 2023-04-25 22:00:41 +02:00