Skip to content

Commit

Permalink
Update chapter10.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yogananda-muthaiah authored Dec 1, 2024
1 parent 170ccb4 commit 4f0eec2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions chapter10.md
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
## Chapter 10: Sentiment Analysis
You can use LangChain to do sentiment analysis on text.


```
from langchain.prompts import PromptTemplate
from langchain.llms import OpenAI
from langchain.chains import LLMChain
template = """
Analyze the sentiment of the following text:
Text: {text}
Sentiment (positive/negative/neutral):
"""
prompt = PromptTemplate(
input_variables=["text"],
template=template
)
chain = LLMChain(llm=OpenAI(temperature=0), prompt=prompt)
text = "I love using LangChain for AI development. It's so powerful and easy to use!"
print(chain.run(text))
```

0 comments on commit 4f0eec2

Please sign in to comment.