DS DevShelfHub Projects · AI tools

Smart Study Assistant: Turn Notes Into a Study Pack

Beginner

By DevShelfHub

Turn pasted notes or textbook text into summaries, key points, and practice questions with Python, Streamlit, and the OpenAI API—beginner-friendly active recall in one step.

Python Streamlit OpenAI API

View on GitHub

Smart Study Assistant — AI study pack generator for notes

Smart Study Assistant is a beginner-friendly project that helps students quickly convert raw study material into structured learning content. Users can paste notes or textbook text, and the system transforms it into concise summaries, key points, and practice questions.

The tool leverages an LLM to understand the input content and extract the most important ideas, making it easier to revise and retain information. It also generates quiz-style questions to reinforce learning and support active recall.

Built using Python and the OpenAI API, this project demonstrates how large language models can be applied to education use cases. It focuses on simplifying study workflows by turning unstructured text into organized, exam-ready material in a single step.

Purpose: help you study faster than rereading long notes from start to finish.

Typical use: before a quiz, paste one dense paragraph and skim the summary and questions the model writes for you.

Key features:

  • One text box for your source notes.
  • One button to ask for a study pack.
  • Answer split into clear parts: summary, key points, quiz.
  • A simple warning if the box is empty, and an error line if the API fails.

Quick example: if you paste two sentences about photosynthesis, you might get a short summary, a few bullet facts, and quiz questions about chloroplasts and light reactions—with suggested answers.

Overall flow

User enters notes
      ↓
Clicks button
      ↓
App sends notes to AI
      ↓
AI generates:
  - Summary
  - Key points
  - Quiz
      ↓
Displayed on screen

Step-by-Step Implementation

  1. Set up the project
    • Install Python
    • Create a new project folder
    • Create and activate a virtual environment
  2. Install dependencies
    • Install required packages:
      • Streamlit
      • OpenAI Python SDK
      • httpx
      • truststore (helps fix SSL issues on some systems, especially macOS)
  3. Build the UI
    • Create a simple Streamlit page with:
      • A title
      • A text area for notes
      • A button to trigger processing
  4. Secure your API key
    • Store your OpenAI API key in .streamlit/secrets.toml
    • Never hardcode the API key in your script
  5. Handle user interaction
    • On button click:
      • Read the input text
      • Send it to the OpenAI model with a clear system prompt
  6. Display results
    • Show the AI-generated response using st.markdown()
    • Ensure the output is structured (Summary, Key Points, Quiz)
  7. Add error handling
    • Show a warning if the input box is empty
    • Use try/except to handle API or network errors gracefully

Code Implementation

python

# Smart Study Assistant — minimal Streamlit + OpenAI example.
# Save as app.py, add OPENAI_API_KEY to .streamlit/secrets.toml, then run: streamlit run app.py

import ssl
import httpx
import streamlit as st
import truststore
from openai import OpenAI

# Browser tab title and layout
st.set_page_config(page_title="Smart Study Assistant", layout="centered")
st.title("Smart Study Assistant")
st.caption("Paste notes below. You will get a summary, key points, and a short quiz.")

# On some macOS/Python setups, default cert verification fails; use the OS trust store.
_ssl_ctx = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
_http = httpx.Client(timeout=120.0, verify=_ssl_ctx)

# Create the OpenAI client using a secret key (never paste keys into this file).
client = OpenAI(
    api_key=st.secrets["OPENAI_API_KEY"],
    http_client=_http
    )
_chat_model = "gpt-4o-mini"

# Large text box where the student pastes notes
notes = st.text_area(
    "Your notes",
    height=220,
    placeholder="Example: paste a paragraph from a textbook or lecture…",
)

# Main action button
if st.button("Generate study pack", type="primary"):
    # Guard: empty notes should not call the API
    if not notes.strip():
        st.warning("Please paste some text first.")
    else:
        # Show a spinner while the network request runs
        with st.spinner("Calling the model…"):
            try:
                response = client.chat.completions.create(
                    model=_chat_model,
                    messages=[
                        {
                            "role": "system",
                            "content": (
                                "You help students study. Reply with exactly three sections. "
                                "Use these headings on their own lines: Summary, Key points, Quiz. "
                                "Under Quiz, write a few questions and then a line starting with Answers:."
                            ),
                        },
                        {"role": "user", "content": notes},
                    ],
                )
                text = (response.choices[0].message.content or "").strip()
                st.markdown(text)
            except Exception as err:
                st.error(f"Something went wrong: {err}")

Complete code Project link (GitHub)


Demo


📖 How the Code Works (Step-by-Step)


1. Page Setup (UI Basics)

  • st.set_page_config() sets the browser tab title and layout
  • st.title() displays the main heading
  • st.caption() adds a short subtitle below the title

2. Secure HTTP Client (Fix SSL Issues)

  • truststore is used to ensure SSL certificates match your operating system
  • httpx.Client(..., verify=_ssl_ctx) creates a secure HTTP client
  • This helps avoid TLS/SSL errors, especially on macOS
  • The OpenAI client is initialized using:
    • API key from st.secrets["OPENAI_API_KEY"] (kept secure)
    • Custom HTTP client for reliable requests
  • _chat_model is stored in a variable so you can easily change the model later

3. User Input Handling

  • st.text_area() creates a large input box for notes
  • The entered text is stored in the notes variable
  • st.button() ensures:
    • The API call runs only when clicked
    • Prevents unnecessary API usage on page reload

4. Calling the OpenAI API

  • chat.completions.create() sends:
    • A system message → defines output format (Summary, Key Points, Quiz)
    • A user message → contains the pasted notes
  • The response is extracted using: response.choices[0].message.content

5. Displaying Output

  • The generated response is shown using: st.markdown()
  • This allows formatted output (headings, bullets, etc.)

6. Error Handling & Validation

  • If the input box is empty:
    • st.warning() prompts the user to enter text
  • The API call is wrapped in try/except:
    • Prevents the app from crashing
    • Displays errors using st.error() (e.g., invalid key, network issues)

Tips & Production Considerations

Keep API costs predictable

Each study-pack request is a single chat completion. With gpt-4o-mini the cost is fractions of a cent per call, but if you let users paste very long documents the token count climbs fast. Set a character limit on the text area (Streamlit's max_chars parameter) or truncate server-side before sending to the API to avoid surprise bills.

Tune the system prompt for different subjects

The default system prompt works well for humanities and science notes. For math-heavy or code-heavy material, add an instruction like "use LaTeX notation for equations" or "wrap code in fenced blocks." Small prompt tweaks dramatically improve the quality of the generated quiz questions for technical subjects.

Handle long input gracefully

Most models have a context window measured in tokens, not characters. If a user pastes an entire chapter, the request may exceed the context limit and fail. A production version should count tokens with tiktoken before calling the API and either split the input into chunks or warn the user to paste a shorter excerpt.

Extend the output format

The default output is Summary + Key Points + Quiz. You can add flashcard pairs (term on one side, definition on the other) by adjusting the system prompt. Some students export the Markdown to Anki or Quizlet-compatible CSV by adding a small post-processing step after the API response.

Deploy to Streamlit Community Cloud

Streamlit apps deploy for free on Streamlit Community Cloud. Push the repo to GitHub, connect it from the dashboard, and add your OPENAI_API_KEY in the Secrets panel. The app goes live in under a minute with no infrastructure to manage.


Smart Study Assistant FAQ

What is Smart Study Assistant?

Smart Study Assistant is a beginner-friendly Streamlit app that uses the OpenAI API to turn pasted study notes or textbook text into a concise summary, key points, and quiz questions in a single click.

Is Smart Study Assistant free to use?

The project's source code is free and open on GitHub. You only pay for OpenAI API usage — typical study sessions consume a few cents at most because each request is short and one-shot.

What tech stack does Smart Study Assistant use?

Python for the app logic, Streamlit for the UI, the OpenAI Python SDK for chat completions, and httpx with truststore to avoid TLS/SSL errors on macOS. No database or vector store is required.

How does it generate quiz questions from notes?

The system prompt instructs the model to return three labeled sections — Summary, Key Points, and Quiz. The model reads the pasted notes once and writes structured output. You then read it back in Markdown.

Can I run Smart Study Assistant offline?

Not as written — it depends on calls to the OpenAI API. To go offline you would swap the OpenAI client for a local model such as Ollama or llama.cpp and adjust the chat completion call accordingly.

What are alternatives to Smart Study Assistant?

For richer note retrieval over many documents, see the Smart Q&A Bot for Your Notes (LangChain + Chroma + Groq RAG) or the Personal Study Tutor for a tutor-style chat experience.

Browse all →