微信扫码
与创始人交个朋友
我要投稿
from langchain.chains.summarize import load_summarize_chainfrom langchain_community.document_loaders import WebBaseLoaderfrom langchain_openai import ChatOpenAI#加载网络文档loader = WebBaseLoader("<您博客文章的URL>")docs = loader.load()#配置LLM,例如使用OpenAI的模型llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-1106")chain = load_summarize_chain(llm, chain_type="stuff")#执行文档总结summary = chain.run(docs)print(summary)
from langchain_core.documents.base import Document as LangchainDocumentdocs = LangchainDocument(page_content=content, metadata={})from langchain_text_splitters import CharacterTextSplitterfrom langchain.chains.summarize import load_summarize_chain# Define LLM chainllm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-16k") chain = load_summarize_chain(llm, chain_type="refine")text_splitter = CharacterTextSplitter.from_tiktoken_encoder(chunk_size=max_token, chunk_overlap=0)split_docs = text_splitter.split_documents([docs])summary = chain.run(split_docs)
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-05-28
2024-04-26
2024-08-21
2024-04-11
2024-07-09
2024-08-13
2024-07-18
2024-10-25
2024-07-01
2024-06-17