Johan713 commited on
Commit
7c19c67
1 Parent(s): 7b73346

Upload aAzel.py

Browse files
Files changed (1) hide show
  1. aAzel.py +28 -11
aAzel.py CHANGED
@@ -29,19 +29,12 @@ Embrace your persona as a masterful storyteller, capable of crafting captivating
29
  6. **Write with Passion and Purpose:** Infuse your writing with genuine passion and a clear sense of purpose. Let your words resonate with the reader, leaving a lasting impression and sparking further thought or inspiration.
30
  """
31
 
32
- def generate_chapter_part(prompt, previous_output=None, max_tokens=2048):
33
  """Generates a part of a chapter using prompt chaining based on previous output."""
34
  if previous_output:
35
  prompt = prompt + "\n\n" + previous_output
36
-
37
- response = ""
38
- output_length = 0
39
- while output_length < max_tokens:
40
- partial_response = model.generate_content([author_persona, author_guidelines, prompt], max_output_length=max_tokens - output_length)
41
- response += partial_response.text
42
- output_length = len(model.count_tokens(response))
43
-
44
- return response
45
 
46
  def display_text_with_wrapping(text, wrap_length=80):
47
  """Displays text with word wrapping for better readability."""
@@ -156,11 +149,35 @@ def main():
156
  * Interspersed with real-world examples and historical anecdotes to illustrate key points.
157
  """
158
 
159
- chapter_content = generate_chapter_part(prompt, st.session_state.chapter_content, max_tokens=4096)
160
  st.session_state.chapter_content = chapter_content
161
  st.markdown(f"## {chapter_name}")
162
  display_text_with_wrapping(chapter_content)
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  # Download chapter button
165
  st.download_button(
166
  label="Download Chapter",
 
29
  6. **Write with Passion and Purpose:** Infuse your writing with genuine passion and a clear sense of purpose. Let your words resonate with the reader, leaving a lasting impression and sparking further thought or inspiration.
30
  """
31
 
32
+ def generate_chapter_part(prompt, previous_output=None):
33
  """Generates a part of a chapter using prompt chaining based on previous output."""
34
  if previous_output:
35
  prompt = prompt + "\n\n" + previous_output
36
+ response = model.generate_content([author_persona, author_guidelines, prompt])
37
+ return response.text
 
 
 
 
 
 
 
38
 
39
  def display_text_with_wrapping(text, wrap_length=80):
40
  """Displays text with word wrapping for better readability."""
 
149
  * Interspersed with real-world examples and historical anecdotes to illustrate key points.
150
  """
151
 
152
+ chapter_content = generate_chapter_part(prompt, st.session_state.chapter_content)
153
  st.session_state.chapter_content = chapter_content
154
  st.markdown(f"## {chapter_name}")
155
  display_text_with_wrapping(chapter_content)
156
 
157
+ # Continue writing option
158
+ if st.button("Continue Writing"):
159
+ if "chapter_content" in st.session_state:
160
+ prompt = f"""Continue writing the chapter titled '{chapter_name}' for a {genre} book titled '{book_title}'.
161
+ The book is about: {book_description}.
162
+ Here are additional details about the chapter:
163
+
164
+ {chapter_details}
165
+
166
+ Ensure the chapter has a clear format, engaging style, and fits within the overall narrative.
167
+
168
+ **Writing Style:**
169
+ * Direct and assertive, conveying a sense of urgency and importance.
170
+ * Engaging and accessible, avoiding overly technical jargon.
171
+ * Motivational and empowering, inspiring readers to embrace the challenge of cognitive growth.
172
+ * Interspersed with real-world examples and historical anecdotes to illustrate key points.
173
+ """
174
+ chapter_content = generate_chapter_part(prompt, st.session_state.chapter_content)
175
+ st.session_state.chapter_content = chapter_content
176
+ st.markdown(f"## {chapter_name}")
177
+ display_text_with_wrapping(chapter_content)
178
+ else:
179
+ st.warning("Please generate the chapter first.")
180
+
181
  # Download chapter button
182
  st.download_button(
183
  label="Download Chapter",