import sys
from langchain.chains.summarize import load_summarize_chain
from langchain import OpenAI

from langchain.text_splitter import RecursiveCharacterTextSplitter


text_splitter = RecursiveCharacterTextSplitter()

# get transcript file key from args
file_key = sys.argv[1]

# get transcript text
text = open(file_key, "r").read()


llm = OpenAI(temperature=0)

texts = text_splitter.split_text(text)
from langchain.docstore.document import Document

docs = [Document(page_content=t) for t in texts]

chain = load_summarize_chain(llm, chain_type="map_reduce")

output = chain.run(docs)

print(output)




langchain.chains.summarize.load_summarize_chain langchain.docstore.document.Document langchain.OpenAI langchain.text_splitter.RecursiveCharacterTextSplitter
[((186, 218), 'langchain.text_splitter.RecursiveCharacterTextSplitter', 'RecursiveCharacterTextSplitter', ([], {}), '()\n', (216, 218), False, 'from langchain.text_splitter import RecursiveCharacterTextSplitter\n'), ((344, 365), 'langchain.OpenAI', 'OpenAI', ([], {'temperature': '(0)'}), '(temperature=0)\n', (350, 365), False, 'from langchain import OpenAI\n'), ((514, 564), 'langchain.chains.summarize.load_summarize_chain', 'load_summarize_chain', (['llm'], {'chain_type': '"""map_reduce"""'}), "(llm, chain_type='map_reduce')\n", (534, 564), False, 'from langchain.chains.summarize import load_summarize_chain\n'), ((464, 488), 'langchain.docstore.document.Document', 'Document', ([], {'page_content': 't'}), '(page_content=t)\n', (472, 488), False, 'from langchain.docstore.document import Document\n')]