DEV Community

Cover image for I built SaliBot, my own agentic ChatGPT, with LangGraph, FastAPI and Gemini
Salima Iddrisu
Salima Iddrisu

Posted on

I built SaliBot, my own agentic ChatGPT, with LangGraph, FastAPI and Gemini

I wanted my own ChatGPT, so I built one and named it after myself: SaliBot, after me, Salima.

SaliBot is a ChatGPT-style assistant, but it isn't just a chat box in front of an LLM. It's an agent: it decides by itself when to search the web, when to read a document you uploaded, when to save something about you to memory, and when to just answer.

In this post I'll walk through how it works and the real problems I had to solve along the way.

I wanted my own ChatGPT, so I built one and named it after myself: SaliBot, after me, Salima.

SaliBot is a ChatGPT-style assistant, but it isn't just a chat box in front of an LLM. It's an agent: it decides by itself when to search the web, when to read a document you uploaded, when to save something about you to memory, and when to just answer.

In this post I'll walk through how it works and the real problems I had to solve along the way.

Try it live: https://salibot.onrender.com
Demo video: https://drive.google.com/file/d/1hDkR78ij9mJR7JgawCUqbo1yig924Oyk/view?usp=sharing
Code: https://github.com/Iddrisusalima/SaliBot


What SaliBot can do

  • Search the web for today's news and other time-sensitive questions (Tavily)
  • Chat with your documents (RAG): PDF, Word, TXT, Markdown, CSV, and my additions: Excel, PowerPoint and images
  • Read pictures: Gemini vision describes an image and copies any text in it
  • Long-term memory: "Remember that I teach robotics" is saved and recalled later
  • Calculator: a sandboxed maths tool
  • Research papers from arXiv, YouTube video summaries, today's date, and "forget this"
  • Streaming answers, word by word, with live status chips like "Searching the web"
  • Voice input
  • Accounts with "Continue with Google" or email and password; every user only sees their own chats
  • Automatic model fallback when Gemini is busy
  • Pin, rename and delete chats from a ⋯ menu
  • LangSmith tracing for every run

The architecture

SaliBot architecture

The stack:

Layer Tech
LLM Google Gemini 3.5
Agent LangGraph
Backend FastAPI (Server-Sent Events for streaming)
RAG ChromaDB + Gemini embeddings
Database PostgreSQL on Neon (SQLite when running locally) + SQLAlchemy
Web search Tavily
Observability LangSmith
Sign-in Google Identity Services + email/password
Hosting Docker on Render, CI with GitHub Actions

The heart of it: a LangGraph agent loop

The agent is a small graph with two nodes:

workflow = StateGraph(MessagesState)

workflow.add_node("chatbot", chatbot_node)
workflow.add_node("tools", ToolNode(tools))

workflow.add_edge(START, "chatbot")
workflow.add_conditional_edges("chatbot", tools_condition)
workflow.add_edge("tools", "chatbot")
Enter fullscreen mode Exit fullscreen mode
  1. The chatbot node sends the conversation (plus a system prompt) to Gemini.
  2. tools_condition checks Gemini's reply: did it ask for a tool?
  3. If yes, the tools node runs it and loops back, so Gemini can read the result.
  4. If no, the answer goes to the user.

Here's that loop in a real run. On the second question it called two tools at once, then wrote one answer from both results:

Inside the agent: the tools it calls and what comes back

A checkpointer saves the conversation state after every step, so SaliBot remembers earlier messages in the same chat even after a restart. Locally it's a SqliteSaver; in production it's a PostgresSaver on the same Neon database as the accounts.

What I love about this pattern: the tools are just Python functions with a docstring.

@tool
def search_uploaded_documents(query: str, config: RunnableConfig) -> str:
    """
    Search uploaded documents for relevant information.
    Use this when the user asks about uploaded PDFs, DOCX, TXT, notes, files, or documents.
    Also use it for uploaded Excel sheets, PowerPoint slides, and images.
    """
    return retrieve_from_rag(query=query, thread_id=thread_of(config))
Enter fullscreen mode Exit fullscreen mode

Gemini reads that docstring to decide when to call the tool. I added the last line myself after realising Gemini wouldn't think to search an uploaded PowerPoint, because the original description never mentioned one.


RAG: chatting with your files

When you upload a file:

  1. Read it (pypdf, docx2txt, openpyxl for Excel, python-pptx for slides, Gemini vision for images)
  2. Chunk it with RecursiveCharacterTextSplitter (900 characters, 150 overlap)
  3. Embed each chunk with gemini-embedding-001 and store it in ChromaDB, tagged with the chat's thread_id

Five file types uploaded to one chat, chunked and searched

When you ask a question, SaliBot searches by meaning, not keywords. In one test, my notes said "microcontroller" and I asked "What board controls the robot?". Different words, same meaning, and it found the right passage.

The thread_id filter matters too: documents uploaded in one chat never leak into another.


Problems I hit (and how I fixed them)

This was the most valuable part of the project.

1. The model I planned to use didn't exist for me

I started with gemini-2.5-flash. My first test returned:

404 NOT_FOUND: This model models/gemini-2.5-flash is no longer available to new users.

Google had closed the 2.5 models to new accounts. I tested which models my key could actually use (the 2.5s were blocked, 3.7 and 3.8 were overloaded, 3.5 worked) and moved SaliBot to gemini-3.5-flash-lite. Later I also hit the free tier's daily limit, so I added friendly error messages instead of showing users a raw 429 RESOURCE_EXHAUSTED dump.

2. Streaming printed garbage

With Gemini 3.5, streamed chunks arrive as a list of "parts", sometimes including an encrypted thought signature, and the raw stream also contains the web-search JSON. Printed directly, the screen filled with base64 and JSON before the actual answer. The fix was to stream only text chunks from the chatbot node and pull the text out of the parts:

if not should_stream_chunk(chunk, metadata):   # skip tool nodes, tool calls, raw outputs
    continue
token = extract_text_from_chunk(chunk)          # keep only the text parts
Enter fullscreen mode Exit fullscreen mode

3. The voice button listened but heard nothing

The browser's built-in speech recognition sends audio to Google's speech servers. On my network that failed silently: "Listening…" forever, no words. So I redesigned it: the browser records the audio, a FastAPI /transcribe endpoint sends it to Gemini, and the text lands in the input box.

4. One shared sidebar for everyone

Without accounts, anyone opening the app would see everyone's chats. I added sign-up and log-in (salted PBKDF2 password hashes, login tokens), and every chat, history, upload and delete request now checks that the chat belongs to the logged-in user. Deleting a chat also cleans up its memories, its document chunks in ChromaDB and its LangGraph checkpoints.

Later I added "Continue with Google": Google's button returns a signed token, the server verifies it with Google's library, then finds or creates the account by email. People sign in in one click, and nobody has a password to forget.

5. A global variable that would mix up users

My first version kept the current chat id in one global variable that the tools read. With one person that's fine. With two people chatting at the same moment, one person's memory could be saved into the other's chat. Now every tool receives the chat id through LangGraph's per-request RunnableConfig (that's the config parameter in the tool above), so each run carries its own.

6. Gemini is often busy on the free tier

Free models regularly answer 503 UNAVAILABLE. SaliBot now switches to a backup model by itself and tells you ("Model busy, switched to…"). My first version crashed with "Received no input": it tried to resume a run that had never been saved. The fix was to ask the checkpointer whether there's a saved step to resume, and otherwise send the question again, so the conversation never holds it twice.

7. The calculator could run any code

The first calculator passed the model's text to Python's eval(). On a public site, someone could trick the AI into "calculating" code that reads the secret keys. I replaced it with a tiny parser built on Python's ast module that only allows numbers, operators and maths functions, with limits so 9**9**9 can't freeze the server.


Watching the agent think with LangSmith

With three environment variables, every run shows up in LangSmith: which tool the agent chose, how long Gemini took, how many tokens it used, and any errors. It's the clearest way I've found to see an agent's decisions, and it made debugging much easier.


Deployment (free, no credit card)

I first set up deployment to AWS with GitHub Actions, but I wanted a free route with no credit card:

  • Render runs the same Dockerfile on its free plan and redeploys on every push to main.
  • Render's free disk is wiped on every restart, which deleted all accounts the first time. So accounts, chats, memories and the agent's checkpoints now live in a free Neon PostgreSQL database, set with one DATABASE_URL variable.
  • GitHub Actions builds the Docker image on every push, so a broken Dockerfile fails in CI before it reaches the server.

My first plan was Hugging Face Spaces, but when I created the Space, Docker had become a paid feature. Lesson: free tiers change, so keep the app portable.


What I learned

  • Agents are mostly about good tool descriptions. The LLM only knows what your docstrings tell it.
  • Plans age fast. Models get retired and APIs change, so reading error messages carefully is a real skill.
  • Observability isn't optional. Without tracing, an agent is a black box.
  • "It works when I test it" is a single-user test. Shared state and free-tier limits only show up with real use.
  • The extras teach the most. Accounts, Google sign-in, a real database, deployment, file types and voice taught me more than the basic chatbot did.

What's next

Keeping uploaded documents across restarts (pgvector in the same PostgreSQL database), upload and rate limits, and maybe a Next.js frontend.


If you have questions or ideas, drop them in the comments. And if you try SaliBot, tell me what you asked it!

What SaliBot can do

-Search the web for today's news and other time-sensitive questions (Tavily)
-Chat with your documents (RAG): PDF, Word, TXT, Markdown, CSV, and my additions: Excel, PowerPoint and images
-Read pictures: Gemini vision describes an image and copies any text in it
-Long-term memory: "Remember that I teach robotics" is saved and recalled later

  • Calculator: a sandboxed maths tool
  • Research papers from arXiv, YouTube video summaries, today's date, and "forget this"
  • Streaming answers, word by word, with live status chips like "Searching the web"
  • Voice input
  • Accounts with "Continue with Google" or email and password; every user only sees their own chats
  • Automatic model fallback when Gemini is busy
  • Pin, rename and delete chats from a ⋯ menu
  • LangSmith tracing for every run

The architecture

SaliBot architecture

The stack:

Layer Tech
LLM Google Gemini 3.5
Agent LangGraph
Backend FastAPI (Server-Sent Events for streaming)
RAG ChromaDB + Gemini embeddings
Database PostgreSQL on Neon (SQLite when running locally) + SQLAlchemy
Web search Tavily
Observability LangSmith
Sign-in Google Identity Services + email/password
Hosting Docker on Render, CI with GitHub Actions

The heart of it: a LangGraph agent loop

The agent is a small graph with two nodes:

workflow = StateGraph(MessagesState)

workflow.add_node("chatbot", chatbot_node)
workflow.add_node("tools", ToolNode(tools))

workflow.add_edge(START, "chatbot")
workflow.add_conditional_edges("chatbot", tools_condition)
workflow.add_edge("tools", "chatbot")
Enter fullscreen mode Exit fullscreen mode
  1. The chatbot node sends the conversation (plus a system prompt) to Gemini.
  2. tools_condition checks Gemini's reply: did it ask for a tool?
  3. If yes, the tools node runs it and loops back, so Gemini can read the result.
  4. If no, the answer goes to the user.

Here's that loop in a real run. On the second question it called two tools at once, then wrote one answer from both results:

Inside the agent: the tools it calls and what comes back

A checkpointer saves the conversation state after every step, so SaliBot remembers earlier messages in the same chat even after a restart. Locally it's a SqliteSaver; in production it's a PostgresSaver on the same Neon database as the accounts.

What I love about this pattern: the tools are just Python functions with a docstring.

@tool
def search_uploaded_documents(query: str, config: RunnableConfig) -> str:
    """
    Search uploaded documents for relevant information.
    Use this when the user asks about uploaded PDFs, DOCX, TXT, notes, files, or documents.
    Also use it for uploaded Excel sheets, PowerPoint slides, and images.
    """
    return retrieve_from_rag(query=query, thread_id=thread_of(config))
Enter fullscreen mode Exit fullscreen mode

Gemini reads that docstring to decide when to call the tool. I added the last line myself after realising Gemini wouldn't think to search an uploaded PowerPoint, because the original description never mentioned one.


RAG: chatting with your files

When you upload a file:

  1. Read it (pypdf, docx2txt, openpyxl for Excel, python-pptx for slides, Gemini vision for images)
  2. Chunk it with RecursiveCharacterTextSplitter (900 characters, 150 overlap)
  3. Embed each chunk with gemini-embedding-001 and store it in ChromaDB, tagged with the chat's thread_id

Five file types uploaded to one chat, chunked and searched

When you ask a question, SaliBot searches by meaning, not keywords. In one test, my notes said "microcontroller" and I asked "What board controls the robot?". Different words, same meaning, and it found the right passage.

The thread_id filter matters too: documents uploaded in one chat never leak into another.


Problems I hit (and how I fixed them)

This was the most valuable part of the project.

1. The model I planned to use didn't exist for me

I started with gemini-2.5-flash. My first test returned:

404 NOT_FOUND: This model models/gemini-2.5-flash is no longer available to new users.

Google had closed the 2.5 models to new accounts. I tested which models my key could actually use (the 2.5s were blocked, 3.7 and 3.8 were overloaded, 3.5 worked) and moved SaliBot to gemini-3.5-flash-lite. Later I also hit the free tier's daily limit, so I added friendly error messages instead of showing users a raw 429 RESOURCE_EXHAUSTED dump.

2. Streaming printed garbage

With Gemini 3.5, streamed chunks arrive as a list of "parts", sometimes including an encrypted thought signature, and the raw stream also contains the web-search JSON. Printed directly, the screen filled with base64 and JSON before the actual answer. The fix was to stream only text chunks from the chatbot node and pull the text out of the parts:

if not should_stream_chunk(chunk, metadata):   # skip tool nodes, tool calls, raw outputs
    continue
token = extract_text_from_chunk(chunk)          # keep only the text parts
Enter fullscreen mode Exit fullscreen mode

3. The voice button listened but heard nothing

The browser's built-in speech recognition sends audio to Google's speech servers. On my network that failed silently: "Listening…" forever, no words. So I redesigned it: the browser records the audio, a FastAPI /transcribe endpoint sends it to Gemini, and the text lands in the input box.

4. One shared sidebar for everyone

Without accounts, anyone opening the app would see everyone's chats. I added sign-up and log-in (salted PBKDF2 password hashes, login tokens), and every chat, history, upload and delete request now checks that the chat belongs to the logged-in user. Deleting a chat also cleans up its memories, its document chunks in ChromaDB and its LangGraph checkpoints.

Later I added "Continue with Google": Google's button returns a signed token, the server verifies it with Google's library, then finds or creates the account by email. People sign in in one click, and nobody has a password to forget.

5. A global variable that would mix up users

My first version kept the current chat id in one global variable that the tools read. With one person that's fine. With two people chatting at the same moment, one person's memory could be saved into the other's chat. Now every tool receives the chat id through LangGraph's per-request RunnableConfig (that's the config parameter in the tool above), so each run carries its own.

6. Gemini is often busy on the free tier

Free models regularly answer 503 UNAVAILABLE. SaliBot now switches to a backup model by itself and tells you ("Model busy, switched to…"). My first version crashed with "Received no input": it tried to resume a run that had never been saved. The fix was to ask the checkpointer whether there's a saved step to resume, and otherwise send the question again, so the conversation never holds it twice.

7. The calculator could run any code

The first calculator passed the model's text to Python's eval(). On a public site, someone could trick the AI into "calculating" code that reads the secret keys. I replaced it with a tiny parser built on Python's ast module that only allows numbers, operators and maths functions, with limits so 9**9**9 can't freeze the server.


Watching the agent think with LangSmith

With three environment variables, every run shows up in LangSmith: which tool the agent chose, how long Gemini took, how many tokens it used, and any errors. It's the clearest way I've found to see an agent's decisions, and it made debugging much easier.


Deployment (free, no credit card)

I first set up deployment to AWS with GitHub Actions, but I wanted a free route with no credit card:

  • Render runs the same Dockerfile on its free plan and redeploys on every push to main.
  • Render's free disk is wiped on every restart, which deleted all accounts the first time. So accounts, chats, memories and the agent's checkpoints now live in a free Neon PostgreSQL database, set with one DATABASE_URL variable.
  • GitHub Actions builds the Docker image on every push, so a broken Dockerfile fails in CI before it reaches the server.

My first plan was Hugging Face Spaces, but when I created the Space, Docker had become a paid feature. Lesson: free tiers change, so keep the app portable.


What I learned

  • Agents are mostly about good tool descriptions. The LLM only knows what your docstrings tell it.
  • Plans age fast. Models get retired and APIs change, so reading error messages carefully is a real skill.
  • Observability isn't optional. Without tracing, an agent is a black box.
  • "It works when I test it" is a single-user test. Shared state and free-tier limits only show up with real use.
  • The extras teach the most. Accounts, Google sign-in, a real database, deployment, file types and voice taught me more than the basic chatbot did.

What's next

Keeping uploaded documents across restarts (pgvector in the same PostgreSQL database), upload and rate limits, and maybe a Next.js frontend.


If you have questions or ideas, drop them in the comments. And if you try SaliBot, tell me what you asked it!

Let's connect

I’m Salima Iddrisu, and I build AI tools. Let’s connect:

Top comments (0)