Krzysztof Krystian Jankowski commited on
Commit
c567944
1 Parent(s): baf34de
Files changed (1) hide show
  1. app.py +9 -20
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
  from ctransformers import AutoModelForCausalLM
3
- # import torch
4
- llm = AutoModelForCausalLM.from_pretrained("TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF")
5
 
6
  # Streamlit UI
7
  st.set_page_config(page_title="GenBlog Demo",
@@ -10,34 +10,23 @@ st.set_page_config(page_title="GenBlog Demo",
10
  initial_sidebar_state='collapsed')
11
  st.header("GenBlog Demo 📚")
12
  st.subheader('This is a demo of the GenBlog assistant', divider='rainbow')
13
- st.write("Enter a blog topic, the number of words and the blog style to generate a blog post.")
14
-
15
- # device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
16
- st.write(f"Based on the TinyLlama 🦙 model by TheBloke.")
17
-
18
  st.divider()
19
-
20
  input_text=st.text_input("Enter the Blog Topic")
21
- col1, col2 = st.columns([5, 5])
22
- with col1:
23
- no_words=st.text_input("Enter the number of words", value=200)
24
- with col2:
25
- blog_style=st.selectbox("Select the Blog Style", ["Personal", "Casual", "Proffesional"])
26
-
27
-
28
- submit=st.button("Generate Blog")
29
  st.divider()
30
  response_field = st.empty()
31
 
32
-
33
-
34
  if submit:
35
  prompt = f"""
36
  As a professional writer skilled in {blog_style.lower()} style, your task is to create an engaging and informative blog post about '{input_text}'. Begin with a captivating title that reflects the essence of the topic. Follow with an introduction that sets the stage for the discussion.
37
 
38
  Please ensure the main body delves into the details of the topic, providing insight, analysis, and relevant examples that illuminate the subject for the readers. Conclude with a summary that reinforces the main points and offers a call to action or a thought-provoking question to engage the readers further.
39
 
40
- The post should be well-structured, clearly written, and approximately {no_words} words in total, reflecting a professional tone suitable for an audience interested in {blog_style.lower()} topics.
41
  """
42
 
43
- st.write_stream(llm(prompt, stream=True, max_new_tokens=256, temperature=0.3))
 
1
  import streamlit as st
2
  from ctransformers import AutoModelForCausalLM
3
+ import torch
4
+ llm = AutoModelForCausalLM.from_pretrained("TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF", gpu_layers=24)
5
 
6
  # Streamlit UI
7
  st.set_page_config(page_title="GenBlog Demo",
 
10
  initial_sidebar_state='collapsed')
11
  st.header("GenBlog Demo 📚")
12
  st.subheader('This is a demo of the GenBlog assistant', divider='rainbow')
13
+ st.write("Enter a blog topic and the blog style to generate a blog post.")
14
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
+ st.write(f"Based on the TinyLlama 🦙 model by TheBloke. Device: {device} 🚀")
 
 
16
  st.divider()
 
17
  input_text=st.text_input("Enter the Blog Topic")
18
+ blog_style=st.selectbox("Select the Blog Style", ["Personal", "Casual", "Proffesional"])
19
+ submit=st.button("Generate Blog Post")
 
 
 
 
 
 
20
  st.divider()
21
  response_field = st.empty()
22
 
 
 
23
  if submit:
24
  prompt = f"""
25
  As a professional writer skilled in {blog_style.lower()} style, your task is to create an engaging and informative blog post about '{input_text}'. Begin with a captivating title that reflects the essence of the topic. Follow with an introduction that sets the stage for the discussion.
26
 
27
  Please ensure the main body delves into the details of the topic, providing insight, analysis, and relevant examples that illuminate the subject for the readers. Conclude with a summary that reinforces the main points and offers a call to action or a thought-provoking question to engage the readers further.
28
 
29
+ The post should be well-structured, clearly written, and reflecting a professional tone suitable for an audience interested in {blog_style.lower()} topics.
30
  """
31
 
32
+ st.write_stream(llm(prompt, stream=True, max_new_tokens=400, temperature=0.5))