Upload aAzel.py
Browse files28 unmodified lines29303132333435363738394041424344454647108 unmodified lines15615715815916016116216316416516628 unmodified lines6. **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."""def generate_chapter_part(prompt, previous_output=None, max_tokens=2048):"""Generates a part of a chapter using prompt chaining based on previous output."""if previous_output:prompt = prompt + "\n\n" + previous_outputresponse = ""output_length = 0while output_length < max_tokens:partial_response = model.generate_content([author_persona, author_guidelines, prompt], max_output_length=max_tokens - output_length)response += partial_response.textoutput_length = len(model.count_tokens(response))return responsedef display_text_with_wrapping(text, wrap_length=80):"""Displays text with word wrapping for better readability."""108 unmodified lines* Interspersed with real-world examples and historical anecdotes to illustrate key points."""chapter_content = generate_chapter_part(prompt, st.session_state.chapter_content, max_tokens=4096)st.session_state.chapter_content = chapter_contentst.markdown(f"## {chapter_name}")display_text_with_wrapping(chapter_content)# Download chapter buttonst.download_button(label="Download Chapter",28 unmodified lines293031323334353637383940108 unmodified lines14915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218328 unmodified lines6. **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."""def generate_chapter_part(prompt, previous_output=None):"""Generates a part of a chapter using prompt chaining based on previous output."""if previous_output:prompt = prompt + "\n\n" + previous_outputresponse = model.generate_content([author_persona, author_guidelines, prompt])return response.textdef display_text_with_wrapping(text, wrap_length=80):"""Displays text with word wrapping for better readability."""108 unmodified lines* Interspersed with real-world examples and historical anecdotes to illustrate key points."""chapter_content = generate_chapter_part(prompt, st.session_state.chapter_content)st.session_state.chapter_content = chapter_contentst.markdown(f"## {chapter_name}")display_text_with_wrapping(chapter_content)# Continue writing optionif st.button("Continue Writing"):if "chapter_content" in st.session_state:prompt = f"""Continue writing the chapter titled '{chapter_name}' for a {genre} book titled '{book_title}'.The book is about: {book_description}.Here are additional details about the chapter:{chapter_details}Ensure the chapter has a clear format, engaging style, and fits within the overall narrative.**Writing Style:*** Direct and assertive, conveying a sense of urgency and importance.* Engaging and accessible, avoiding overly technical jargon.* Motivational and empowering, inspiring readers to embrace the challenge of cognitive growth.* Interspersed with real-world examples and historical anecdotes to illustrate key points."""chapter_content = generate_chapter_part(prompt, st.session_state.chapter_content)st.session_state.chapter_content = chapter_contentst.markdown(f"## {chapter_name}")display_text_with_wrapping(chapter_content)else:st.warning("Please generate the chapter first.")# Download chapter buttonst.download_button(label="Download Chapter",
aAzel.py+28-11