Here's the URL: https://the-writers-lens.streamlit.app/
The Writer's Lens is a single-page web application that allows users to interact with a generative AI chatbot that mimics the writing styles of famous authors. Users can choose an author from a wide selection, enter a topic or prompt, and receive creative and style-aligned text generated by Google's Gemini AI. This project combines elements of generative AI, natural language processing, and style transfer to deliver highly customized content based on the works of literary icons.
- Generative AI: Utilizes Google's Gemini API to generate contextually accurate, stylized responses based on the user's prompt and the chosen author.
- Customizable Experience: Users can select from a wide array of famous authors or opt for a custom writer option to further personalize the experience.
- Style Mimicking: The chatbot crafts responses that align with each author's unique writing style, offering insights into different literary techniques and creating engaging conversations.
The core idea of The Writer's Lens is to allow users to explore different writing styles through AI. By integrating Google's Gemini API, we can generate text that mimics the idiosyncrasies and nuances of some of the most renowned authors in literature. Whether you're looking for humor in Mark Twain's style, philosophical musings from Dostoevsky, or the dark, atmospheric tone of Edgar Allan Poe, the app offers an immersive experience for literature fans and creative writers alike. It’s a playful tool to get inspiration, learn about different literary approaches, or simply engage with fun, creative dialogues crafted by AI.
For each of the authors in our list, a specific prompt engineering technique was used to match the style of that particular writer. By incorporating brief descriptions of the author's style, we prompt Google's Gemini AI model to generate outputs consistent with their unique linguistic features, tone, and themes.
Some common techniques include:
- Contextualized Prompts: The initial input combines both the topic provided by the user and a brief description of the author's style. This ensures the response generated mirrors the expected tone, structure, and vocabulary of the selected author.
- Role-Playing Technique: Each time the model generates content, it is instructed to "speak" or "write" in the style of the chosen author (i.e., "You are a writer crafting in the style of Mark Twain").
- Descriptive Framing: By framing the response within key descriptive keywords (such as “gothic and mysterious” for Edgar Allan Poe or “witty and romantic” for Jane Austen), the chatbot adjusts the generative process to stay true to the author's signature traits.
The main parameters in this project are:
- Temperature
The temperature setting determines the creativity of the responses generated by the AI. Higher temperature values result in more creative and diverse outputs, while lower values make responses more consistent and realistic. Available Temperature Options:
Very Creative (1.0): Highly imaginative and diverse responses, ideal for exploring unique writing styles.
Creative (0.7): Balanced creativity with still a fair amount of diversity, perfect for generating fresh yet coherent outputs.
Balanced (0.5): Delivers consistent responses with a mix of creativity and reliability.
Realistic (0.3): Responses tend to be more straightforward and factual, with less creativity involved.
More Realistic (0.2): The AI focuses on accurate and realistic outputs with minimal creative flair.
For the current application, temperature is set at 0.7 (Creative) to ensure an engaging and interesting writing style while maintaining coherence with the chosen author’s tone. 2. Max Length
The max length setting controls the number of tokens (words or sub-words) in the generated response. Shorter lengths are useful for concise replies, while longer lengths provide more in-depth content. Available Max Length Options:
Very Short (50 tokens): Very concise responses for quick interactions.
Short (100 tokens): Slightly longer, but still brief answers.
Balanced (150 tokens): Moderate length providing sufficient detail without being too verbose.
Long (200 tokens): Lengthier responses suitable for in-depth exploration.
Very Long (300 tokens): The longest responses, allowing for detailed and comprehensive content.
In this application, max length is dynamically set based on user preferences, mapped to simple options like Short, Medium, and Long to make it easier for non-technical users to choose the ideal verbosity for their conversation.
These preset limits help keep the application user-friendly while preventing excessively long outputs.
- Model Used (Gemini-1.5):
- Google's Gemini API was chosen due to its capability to handle nuanced prompts and generate high-quality, human-like text based on specific writing styles.
- It allows flexible text generation while maintaining coherence within the stylistic constraints, an important factor for accurately representing literary figures.
- Author Selection: Choose from an extensive list of authors such as Shakespeare, Hemingway, Orwell, and many more.
- Learning Mode: Toggle to learn about the literary styles of authors and get deeper insights into their works and techniques.
- Custom Writer Option: If the listed authors don't suit your needs, the custom writer option lets you create a description of your preferred writing style.
- Responsive Design: The app functions optimally across a wide range of screen sizes.
- Backend: Python, using Streamlit to build a highly interactive and easy-to-use front-end UI.
- Generative Model: Google's Gemini API to handle AI content generation.
- Web Interface: Built using the Streamlit framework for smooth user interaction.
- Deployment: Deployed as a web application for easy access by users from any platform.
-
Clone the repository:
git clone https://github.com/Saad-Musema/The-Writers-Lens cd The-Writers-Lens
-
Install required Python libraries:
pip install -r requirements.txt
-
Run the app:
streamlit run app.py
- Generative AI: Leveraging Google's Gemini API to generate text mimicking the writing styles of famous authors.
- Easy Parameters: Temperature and response length are simplified for a seamless, user-friendly experience.
- Learning Mode: Users can toggle a learning mode to explore authors’ writing styles.
This provides a concise explanation so users can quickly understand the app’s capabilities and what adjustments they can make to tailor their experience.
This README should provide users with a clear understanding of what The Writer's Lens is, how it works, and the technologies that power it.