Back to Case Studies

AI Assistant for a Project-Management SaaS

Text-to-SQL, Hybrid RAG and Session Documents in One Chat

ProductionEnterprise Software & IT ServicesMay 2024NLP, Knowledge Systems & Generative AI
0.93
Accuracy of relevant answers
0.89
Text-to-SQL score on product data
3 sources
Project data, docs and user files
Integrated
Built into the client's product

My Role

Role
Project lead
Independent consulting
Team
Me + 1 developer
Stage reached
Handed over, integrated into product
Key decisions
  • Custom SQL chain: schema sent without sample rows
  • Uploaded files indexed per session, deleted after
  • Hybrid dense plus BM25 retrieval over docs

Approach at a Glance

Details
  1. 1Text-to-SQL over the Product Database
  2. 2Hybrid RAG over Documentation
  3. 3Per-Session Document RAG
  4. 4Synthetic Data for Development
  5. 5Demo and Handover

Executive Summary

An AI assistant for a project-management SaaS, a tool in the same space as Jira, that lets users ask questions in plain language and get answers from three different sources in one chat:

  • Their own project data: epics, stories, sprints, teams, priorities and statuses, queried live from the product's database with text-to-SQL.
  • The product's documentation: answered with hybrid retrieval that combines semantic and keyword search.
  • Files they upload during the chat: indexed for that session only and deleted when it ends.

The assistant answered with 0.93 accuracy of relevant answers overall, and 0.89 on text-to-SQL questions. I led the work as an independent consultant, in a team with one developer. The assistant was handed over and integrated into the client's product.


Client Profile

The client builds a project-management platform. Its data model is rich: workspaces and project spaces, initiatives and epics with phases and health statuses, stories with subtasks, comments and labels, teams, sprints and retrospectives. Users wanted to ask questions like "which epics are at risk this sprint?" without building reports or filters.

That meant combining very different kinds of knowledge:

  • Structured data that changes constantly and has to be queried exactly, through dozens of related tables.
  • Product documentation for "how do I…" questions.
  • Ad-hoc documents a user brings into the conversation, which must not leak into other sessions.

Technical Approach

  1. Text-to-SQL over the Product Database – GPT-4 turns the question and the chat history into SQL, runs it on PostgreSQL and writes the answer from the result. The database is mapped through an SQLAlchemy model of the product schema, and the prompt never exposes internal IDs. The standard SQL chain overflowed the context window on this many tables, so I built a custom chain that sends the schema without sample rows.

  2. Hybrid RAG over Documentation – Product docs are indexed in Pinecone with both dense embeddings and BM25 sparse vectors, using a BM25 encoder fitted on the docs. Before retrieval, a history-aware step rewrites follow-up questions into standalone ones.

  3. Per-Session Document RAG – Users can upload PDF, TXT or CSV files mid-conversation. Chunks are tagged with the session ID, retrieved only within that session and deleted when the session ends. A fetch-then-delete workaround made this possible on the vector database's free tier, which couldn't delete by metadata. Without an uploaded file, the assistant falls back to the general knowledge base.

  4. Synthetic Data for Development – Development and testing used synthetic data covering the product's tables, so no customer data was needed.

  5. Demo and Handover – A Streamlit interface for demos and testing. The components were then handed over for integration into the client's product.


Business Outcome

The client's users can ask about their projects, the product and their own documents in one conversation, without building reports or searching the docs. The assistant reached 0.93 accuracy of relevant answers and 0.89 on text-to-SQL, and was integrated into the client's product.

Technologies

GPT-4Text-to-SQLLangChainHybrid SearchPineconeBM25PostgreSQLSQLAlchemyStreamlit

Planning something similar?

Tell me about it on a short call. New projects can start within 2 weeks