Update app.py
Browse files
app.py
CHANGED
|
@@ -16,25 +16,21 @@ llm = HuggingFaceEndpoint(
|
|
| 16 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 17 |
huggingfacehub_api_token=HF_TOKEN,
|
| 18 |
temperature=0.7,
|
| 19 |
-
max_new_tokens=
|
| 20 |
)
|
| 21 |
|
| 22 |
# Define a prompt template for generating a blog
|
| 23 |
TEMPLATE = """
|
| 24 |
Write a detailed blog post on the following topic:
|
| 25 |
Topic: {topic}
|
| 26 |
-
Make sure the blog post is informative, engaging,
|
| 27 |
"""
|
| 28 |
|
| 29 |
# Create a prompt template instance
|
| 30 |
blog_prompt_template = PromptTemplate(input_variables=["topic"], template=TEMPLATE)
|
| 31 |
|
| 32 |
-
# Create
|
| 33 |
-
blog_chain = (
|
| 34 |
-
blog_prompt_template
|
| 35 |
-
| llm
|
| 36 |
-
| StrOutputParser()
|
| 37 |
-
)
|
| 38 |
|
| 39 |
def generate_blog_post(topic: str) -> str:
|
| 40 |
if topic:
|
|
|
|
| 16 |
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 17 |
huggingfacehub_api_token=HF_TOKEN,
|
| 18 |
temperature=0.7,
|
| 19 |
+
max_new_tokens=500
|
| 20 |
)
|
| 21 |
|
| 22 |
# Define a prompt template for generating a blog
|
| 23 |
TEMPLATE = """
|
| 24 |
Write a detailed blog post on the following topic:
|
| 25 |
Topic: {topic}
|
| 26 |
+
Make sure the blog post is informative, engaging, well-structured, and complete in 450 words.
|
| 27 |
"""
|
| 28 |
|
| 29 |
# Create a prompt template instance
|
| 30 |
blog_prompt_template = PromptTemplate(input_variables=["topic"], template=TEMPLATE)
|
| 31 |
|
| 32 |
+
# Create a chain
|
| 33 |
+
blog_chain = blog_prompt_template | llm | StrOutputParser()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
def generate_blog_post(topic: str) -> str:
|
| 36 |
if topic:
|