pratikshahp commited on
Commit
c929f05
·
verified ·
1 Parent(s): 1fb01d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -3,7 +3,8 @@ from dotenv import load_dotenv
3
  import gradio as gr
4
  from langchain_core.prompts import PromptTemplate
5
  from langchain_huggingface import HuggingFaceEndpoint
6
- from langchain_core.chains import LLMChain
 
7
 
8
  # Load environment variables
9
  load_dotenv()
@@ -29,12 +30,12 @@ Make sure the blog post is informative, engaging, and well-structured.
29
  blog_prompt_template = PromptTemplate(input_variables=["topic"], template=TEMPLATE)
30
 
31
  # Initialize the LLMChain with the HuggingFace model and prompt template
32
- blog_chain = LLMChain(llm=llm, prompt=blog_prompt_template)
33
 
34
  def generate_blog_post(topic: str, author_name: str) -> str:
35
  if topic:
36
  # Generate the blog post
37
- blog_post = blog_chain.run({"topic": topic})
38
 
39
  # Add author name if provided
40
  if author_name:
 
3
  import gradio as gr
4
  from langchain_core.prompts import PromptTemplate
5
  from langchain_huggingface import HuggingFaceEndpoint
6
+ from langchain_core.output_parsers import StrOutputParser
7
+
8
 
9
  # Load environment variables
10
  load_dotenv()
 
30
  blog_prompt_template = PromptTemplate(input_variables=["topic"], template=TEMPLATE)
31
 
32
  # Initialize the LLMChain with the HuggingFace model and prompt template
33
+ blog_chain = blog_prompt_template | model | StrOutputParser()
34
 
35
  def generate_blog_post(topic: str, author_name: str) -> str:
36
  if topic:
37
  # Generate the blog post
38
+ blog_post = blog_chain.invoke({"topic": topic})
39
 
40
  # Add author name if provided
41
  if author_name: