Lyzr English Self Learning App: Empowering Autonomous Language Learning
Published: 2024-07-17 08:43:04

In today’s interconnected world, mastering English language skills is crucial for personal and professional growth. The Lyzr English Self Learning app leverages advanced AI technology to facilitate autonomous learning, specifically designed to enhance English proficiency through interactive and personalized exercises.

**Problem Statement**
Traditional methods of language learning often lack personalized feedback and structured learning activities, hindering effective skill development. Learners struggle to find resources that adapt to their individual pace and learning styles, making sustained progress challenging.

**Solution**
The Lyzr English Self Learning app addresses these challenges by integrating cutting-edge AI technology, specifically Lyzr Automata, to create a dynamic and personalized learning experience. Here’s how it works:

Personalized Learning Activities: Users input an article link, and the app generates tailored learning activities based on the content. These activities include vocabulary breakdowns, grammar explanations, comprehension questions, and practice exercises.
Advanced AI Model Integration: Powered by OpenAI’s GPT-4 Turbo, the app analyzes complex articles, identifies language patterns, and provides in-depth explanations to enhance comprehension and language acquisition.
Interactive Learning Journey: Learners engage with an AI-driven English tutor persona, receiving guidance and feedback akin to a one-on-one tutoring session. This interaction fosters deeper understanding and retention of language nuances.

**Setting Up the Environment**
**Imports:**
Imports necessary libraries: streamlit, libraries from lyzr_automata
```
pip install lyzr_automata streamlit
```
```
import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
```

**Sidebar Configuration**
```
api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
```
if api:: Checks if an API key is entered.

openai_model = OpenAIModel(): If a key is entered, creates an OpenAIModel object with the provided API key, model parameters (gpt-4-turbo-preview, temperature, max_tokens).
else: If no key is entered, displays an error message in the sidebar.

**english_learning function:**
```
def english_learning(article):
    english_agent = Agent(
        prompt_persona=f"You are an Expert in English.",
        role="English Tutor",
    )

    english_task = Task(
        name="English learning",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=english_agent,
        log_output=True,
        instructions=f"""
        You are an advanced English language tutor. Your task is to help me improve my English by analyzing difficult articles I provide. Follow these steps for each article I submit:
        Perform an initial analysis of the text.
        Provide a vocabulary breakdown:
        List unfamiliar or advanced words
        For each word, give its definition, etymology, example sentences, synonyms, antonyms, and common collocations
        Analyze phrases and sentences:
        Identify idiomatic expressions, phrasal verbs, and complex sentence structures
        Explain their meanings, usage in different contexts, and provide simpler alternatives or paraphrases
        Offer grammar explanations for complex structures
        Explain any cultural, historical, or subject-specific references in the text.
        Provide 3-5 reading comprehension questions about the main ideas and key points.
        Highlight recurring language patterns, writing styles, or genre-specific vocabulary.
        Create practice exercises based on the text:
        Fill-in-the-blank sentences
        Matching exercises
        Sentence transformation tasks
        A short writing prompt using new vocabulary
        Suggest 2-3 long-term learning strategies to help retain and review the new language.
        Recommend 1-2 similar texts or articles for further reading and reinforcement.
        Always be prepared to engage in follow-up discussions, answer questions about the text, and adapt your explanations based on my needs and progress. Your goal is to systematically expand my vocabulary and improve my comprehension of complex English articles over time.
        
        Article Link: {article}
        """,
    )

    output = LinearSyncPipeline(
        name="Learn English",
        completion_message="Test Generated!",
        tasks=[
            english_task
        ],
        ).run()
    return output[0]['task_output']

```
Defines a function called english_learning that takes an article link as input.
Creates an Agent object with a persona prompt and assigns the role of "English Tutor".
Creates a Task object named "English learning" specifying the output and input types, model to be used (from openai_model), assigned agent, logging output, and detailed instructions for the model to act as an English tutor when processing articles.
Creates a LinearSyncPipeline object named "Learn English" with a completion message and a list containing the created english_task.
Runs the pipeline and retrieves the task output (presumably the analysis of the article).
Returns the retrieved task output.

**User Input and Button:**
```
article = st.text_input("Enter Article Link")
if st.button("Generate"):
    solution = english_learning(article)
    st.markdown(solution)
```
article = st.text_input(): Creates a text input field for users to enter an article link.
if st.button(): Creates a button labeled "Generate". When clicked, it triggers the following code block.
Calls the english_learning function with the entered article link.
Stores the returned output (analysis of the article) in the solution variable.
Uses st.markdown() to display the solution as formatted text on the Streamlit app.
try it now: https://lyzr-english-learning.streamlit.app/

code: https://github.com/harshit-lyzr/English_self_learning

For more information explore the website: [Lyzr](https://www.lyzr.ai/)

Contibute to Our Project: https://github.com/LyzrCore/lyzr-automata