Skip to content

Commit

Permalink
Update chapter9.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yogananda-muthaiah authored Dec 1, 2024
1 parent 1324a2a commit 170ccb4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions chapter9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Chapter 9: Text Summarization
LangChain can be used to efficiently summarize long pieces of text.

```
from langchain.chains.summarize import load_summarize_chain
from langchain.llms import OpenAI
from langchain.docstore.document import Document
text = """
LangChain is a framework for developing applications powered by language models. It enables applications that:
Are context-aware: connect a language model to sources of context (prompt instructions, few shot examples, content to ground its response in, etc.)
Reason: rely on a language model to reason (about how to answer based on provided context, what actions to take, etc.)
"""
docs = [Document(page_content=text)]
chain = load_summarize_chain(OpenAI(temperature=0), chain_type="stuff")
print(chain.run(docs))
```

0 comments on commit 170ccb4

Please sign in to comment.