langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
11.79k stars 1.97k forks source link

TypeError: text.split is not a function #141

Closed slavakurilyak closed 1 year ago

slavakurilyak commented 1 year ago

I am creating a Raycast extension to summarize a web page, but I'm running into TypeError: text.split is not a function. Any suggestions?

Here's my stack trace:

(summarizethis-env) ➜  summarizethis npm run build; npm run dev

> build
> ray build -e dist

info  -  entry points [src/summarizethis.tsx]
info  -  checked TypeScript
ready -  built extension successfully

> dev
> ray develop

info  -  entry points [src/summarizethis.tsx]
ready -  built extension successfully
10:26:52.444 { url: 'https://dagster.io/blog/chatgpt-langchain' }
10:26:52.444 ===LOADER===
10:26:52.444 {
  loader: CheerioWebBaseLoader2 {
    webPath: 'https://dagster.io/blog/chatgpt-langchain'
  }
}
10:26:52.839 ===DOCUMENTS===
10:26:52.840 {
  documents: [
    Document {
      pageContent: `Did you miss our Watch the Airflow → Dagster migration event? - Watch it here!PlatformCloudPricingBlogCommunityDocsSign inJoin us on Slack Star usTry Dagster CloudPlatformIntegrationsCloudPricingBlogCommunityImplementation PartnersDocsContact SalesSign inTry Dagster CloudJanuary 9, 2023 • 13 minute readBuild a GitHub support bot with GPT3, LangChain, and Python<img alt="Pete Hunt" srcSet="/_next/image?url=%2Feditors%2Fpetehunt.jpg&amp;w=48&amp;q=75 1x, /_next/image?url=%2Feditors%2Fpetehunt.jpg&amp;w=96&amp;q=75 2x" src="/editors/petehunt.jpg" decoding="async" style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="rounded-full border border-gray-200 w-12 h-12"/>NamePete HuntHandle@floydophoneChatGPT, ever heard of it?ChatGPT came out a few months ago and blew everyones’ minds with its abil<…>
10:26:52.840 ===DOCUMENT===
10:26:52.841 {
  document: Document {
    pageContent: `Did you miss our Watch the Airflow → Dagster migration event? - Watch it here!PlatformCloudPricingBlogCommunityDocsSign inJoin us on Slack Star usTry Dagster CloudPlatformIntegrationsCloudPricingBlogCommunityImplementation PartnersDocsContact SalesSign inTry Dagster CloudJanuary 9, 2023 • 13 minute readBuild a GitHub support bot with GPT3, LangChain, and Python<img alt="Pete Hunt" srcSet="/_next/image?url=%2Feditors%2Fpetehunt.jpg&amp;w=48&amp;q=75 1x, /_next/image?url=%2Feditors%2Fpetehunt.jpg&amp;w=96&amp;q=75 2x" src="/editors/petehunt.jpg" decoding="async" style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" class="rounded-full border border-gray-200 w-12 h-12"/>NamePete HuntHandle@floydophoneChatGPT, ever heard of it?ChatGPT came out a few months ago and blew everyones’ minds with its ability to an<…>
10:26:52.841 ===SPLITTER===
10:26:52.841 {
  splitter: RecursiveCharacterTextSplitter2 {
    chunkSize: 10,
    chunkOverlap: 1,
    separators: [ '\n\n', '\n', ' ', '' ]
  }
}
10:26:52.842 ===DOCS===
10:26:52.842 {
  docs: [
    Document { pageContent: 'Did you', metadata: [Object] },
    Document { pageContent: 'miss our', metadata: [Object] },
    Document { pageContent: 'Watch the', metadata: [Object] },
    Document { pageContent: 'Airflow →', metadata: [Object] },
    Document { pageContent: '→ Dagster', metadata: [Object] },
    Document { pageContent: 'migration', metadata: [Object] },
    Document { pageContent: 'event? -', metadata: [Object] },
    Document { pageContent: '- Watch it', metadata: [Object] },
    Document { pageContent: 'here!Plat', metadata: [Object] },
    Document { pageContent: 'tformClou', metadata: [Object] },
    Document { pageContent: 'udPricing', metadata: [Object] },
    Document { pageContent: 'gBlogComm', metadata: [Object] },
    Document { pageContent: 'munityDoc', metadata: [Object] },
    Document { pageContent: 'csSign', metadata: [Object] },
    Document { pageContent: 'inJoin us', metadata: [Object] },
    Document { pageContent: 'on Slack', metadata: [Object] }<…>
10:26:52.842 ===COMBINEDOCSCHAIN===
10:26:52.843 {
  combineDocsChain: MapReduceDocumentsChain {
    memory: undefined,
    llmChain: LLMChain {
      memory: undefined,
      prompt: [PromptTemplate],
      llm: [OpenAI2],
      outputKey: 'text'
    },
    inputKey: 'input_documents',
    outputKey: 'output_text',
    documentVariableName: 'text',
    maxTokens: 3000,
    maxIterations: 10,
    combineDocumentChain: StuffDocumentsChain {
      memory: undefined,
      llmChain: [LLMChain],
      inputKey: 'input_documents',
      outputKey: 'output_text',
      documentVariableName: 'text'
    }
  }
}
10:26:52.843 ===CHAIN===
10:26:52.843 {
  chain: AnalyzeDocumentChain2 {
    memory: undefined,
    inputKey: 'input_document',
    outputKey: 'output_text',
    combineDocumentsChain: MapReduceDocumentsChain {
      memory: undefined,
      llmChain: [LLMChain],
      inputKey: 'input_documents',
      outputKey: 'output_text',
      documentVariableName: 'text',
      maxTokens: 3000,
      maxIterations: 10,
      combineDocumentChain: [StuffDocumentsChain]
    },
    textSplitter: RecursiveCharacterTextSplitter2 {
      chunkSize: 1000,
      chunkOverlap: 200,
      separators: [Array]
    }
  }
}
10:26:52.843 TypeError: text.split is not a function
    at RecursiveCharacterTextSplitter2.splitText (/Users/skurilyak/.config/raycast/extensions/summarizethis/summarizethis.js:195:25)
    at RecursiveCharacterTextSplitter2.createDocuments (/Users/skurilyak/.config/raycast/extensions/summarizethis/summarizethis.js:95:36)
    at AnalyzeDocumentChain2._call (/Users/skurilyak/.config/raycast/extensions/summarizethis/summarizethis.js:43287:47)
    at AnalyzeDocumentChain2.call (/Users/skurilyak/.config/raycast/extensions/summarizethis/summarizethis.js:16471:35)
    at Object.onSubmit (/Users/skurilyak/.config/raycast/extensions/summarizethis/summarizethis.js:49351:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async onAction (/Applications/Raycast.app/Contents/Resources/RaycastCommands_RaycastCommands.bundle/Contents/Resources/api/node_modules/@raycast/api/index.js:18:5481)
slavakurilyak commented 1 year ago

I followed the documentation here and resolved the issue