import { ChatOpenAI } from 'langchain/chat_models/openai'
import { HumanMessage, ChatMessage, SystemMessage } from 'langchain/schema'
import { PromptTemplate } from 'langchain/prompts'
import { LLMChain } from 'langchain/chains'
import { PDFLoader } from 'langchain/document_loaders/fs/pdf'
import { UnstructuredLoader } from 'langchain/document_loaders/fs/unstructured'
import { config } from 'dotenv'
import { BufferMemory } from 'langchain/memory'
import { RedisChatMessageHistory } from 'langchain/stores/message/ioredis'
import { ConversationChain } from 'langchain/chains'
import { OpenAIEmbeddings } from 'langchain/embeddings/openai'
import { TypeORMVectorStore } from 'langchain/vectorstores/typeorm'

config()

const loader1 = new UnstructuredLoader('/Users/drew/Downloads/客服的副本.pdf', {
    apiUrl: 'http://192.168.6.19:8000/general/v0/general'
})
const docs1 = await loader1.load()
console.log(docs1.length)
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter'

const text = `Hi.\n\nI'm Harrison.\n\nHow? Are? You?\nOkay then f f f f.
This is a weird text to write, but gotta test the splittingggg some how.\n\n
Bye!\n\n-H.`
const splitter = new RecursiveCharacterTextSplitter({
    chunkSize: 200,
    chunkOverlap: 1
})
const docOutput = await splitter.splitDocuments(docs1)
console.log(docOutput.length)
