langchaingo icon indicating copy to clipboard operation
langchaingo copied to clipboard

Minor enhancements needed to use this package in additional projects

Open sedletsky-f5 opened this issue 1 year ago • 2 comments

  1. In my current project, there is a strict requirement to have go v1.21 while later versions like v1.22 are not allowed. The only change needed is go 1.22.0 => go 1.21.0 in go.mod file. I tried locally and it works fine.
  2. Also in my project, I need to load Markdown files with extension .mdx (rather than .md) while the content format is the same. To support this extension just need to change condition filepath.Ext(file.Name()) != ".md" to (filepath.Ext(file.Name()) != ".md" && filepath.Ext(file.Name()) != ".mdx") in documentloaders/notion.go

These changes will not impact existing behavior and no regressions are expected. I already prepared these changes locally, so if you are OK with them - please give me permissions to commit/merge and I will send PR for review.

Thanks.

sedletsky-f5 avatar Sep 05 '24 05:09 sedletsky-f5

diff --git a/documentloaders/notion.go b/documentloaders/notion.go
index 0dacbe7..c59b696 100644
--- a/documentloaders/notion.go
+++ b/documentloaders/notion.go
@@ -39,7 +39,7 @@ func (n *NotionDirectoryLoader) Load() ([]schema.Document, error) {
 
        documents := make([]schema.Document, 0, len(files))
        for _, file := range files {
-               if file.IsDir() || filepath.Ext(file.Name()) != ".md" {
+               if file.IsDir() || (filepath.Ext(file.Name()) != ".md" && filepath.Ext(file.Name()) != ".mdx") {
                        continue
                }
 
diff --git a/go.mod b/go.mod
index 6401ef7..214b001 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/tmc/langchaingo
 
-go 1.22.0
+go 1.21.0

sedletsky-f5 avatar Sep 05 '24 05:09 sedletsky-f5

@tmc can you please take a look here? it is a very small change that will allow me to use your package (rather than forking it). thanks.

sedletsky-f5 avatar Sep 30 '24 16:09 sedletsky-f5

our project moved to go 1.22 - so this issue is not relevant anymore (support of .mdx can be worked around)

sedletsky-f5 avatar Nov 24 '24 00:11 sedletsky-f5