GeekHub Learn
Module
Lesson 6.55 of 7 in this module2 min read Module 6: Building Your First AI Chat App

File uploads and a starter "chat with my notes" feature

The feature that turns a chatbot into a personal assistant: "chat with my notes". This lesson is the smallest possible step toward RAG (Module 7 and 9).

The chatbot is a friend who can read whatever you hand them. Today we hand them a single note. In Module 9, we hand them a whole library.

For a small file, we can just paste its text into the prompt. This is the simplest possible "ask my document" feature. We will replace it with proper retrieval in Module 9.

Add a sidebar uploader:

uploaded = st.sidebar.file_uploader("Upload a .txt or .md note", type=["txt", "md"])
note_text = uploaded.read().decode("utf-8") if uploaded else ""

# Inject note into system context
if note_text:
    system_with_note = SYSTEM + f"\n\nUser's note:\n{note_text[:8000]}"
    st.session_state.messages[0] = {"role": "system", "content": system_with_note}

Now every reply is informed by the note. For PDFs, large files, or many files, jump to Module 9 (RAG).

Visualize it

Before/after screenshots: chatbot answering without and with an uploaded note. Show how grounded the second answer is.

Try it now

Upload your own resume (as .txt). Ask "What roles am I best suited for?" Observe the answer ground itself in your data.

Hands-on lab

Add the uploader to your app. Test with a 1-page note. Note what happens when you upload a 100-page document. (Hint: token limit. We will fix it in Module 9.)

Try it now

Why does this approach fail past a certain file size?

Common mistakes

  • Pasting entire huge files into the prompt (context limits, cost)
  • Forgetting to truncate (note_text[:8000])
  • Not handling non-text file types yet

Debugging tip

If the bot ignores the uploaded note, check that you updated the system message and that the note text actually loaded.

Challenge

Allow uploading multiple notes and let the user pick which one to "chat with" via a dropdown.

Where this shows up

  • Personal note assistants
  • Reading helpers
  • Simple resume reviewers

From the field

Most "chat with X" features start exactly like this and graduate to RAG when files get large or numerous. Knowing the stepping stones helps you scope projects honestly.

Recap

Single small note via system prompt is the starter. Module 9 turns it into a real PDF chatbot.


Quick recall

3 prompts · think before you flip

Prompt 1 of 3

Why is "paste the whole file" only a small-file solution?

Quiz time

1 question · tap an answer to check it

  1. 1. The simplest "chat with my doc" pattern is

Finished lesson 6.5?

Mark complete to update your module progress and unlock the streak.

Loading