A document processing pipeline built with LangGraph that generates professional proposal responses using RAG (Retrieval Augmented Generation) with Supabase vector storage. Supports both OpenAI and Google Vertex AI as LLM providers.
This tool helps you automatically generate proposal responses by leveraging your existing company documentation. It uses RAG to pull relevant information from your document store and generates customized sections for your proposal.
- RAG-powered document generation using Supabase vector store
- Choice of LLM providers (OpenAI GPT-4 or Google Vertex AI Gemini)
- Automated section generation:
- Corporate Overview
- Staff Profiles
- Capabilities Relevant to Opportunity
- Corporate Experiences
- Responses to Opportunity Questions
- PDF generation
- Optional email delivery
- Python 3.8+
- Supabase account
- Either OpenAI API key or Google Cloud Project with Vertex AI enabled
- (Optional) SMTP server access for email delivery
pip install langchain langgraph supabase reportlab google-cloud-aiplatform openai python-dotenv-
Create a new Supabase project
-
Enable Vector Store by running these SQL commands in the Supabase SQL editor:
-- Enable the vector extension
create extension if not exists vector;
-- Create the documents table with vector storage
create table documents (
id uuid primary key,
content text,
metadata jsonb,
embedding vector(768)
);
-- Create a function to handle vector similarity search
-- Create a function to handle vector similarity search
create or replace function public.match_documents (
query_embedding vector(768),
match_count int default 10
) returns table (id uuid, content text, metadata jsonb, similarity float)
language plpgsql
as $$
begin
return query
select
documents.id,
documents.content,
documents.metadata,
1 - (documents.embedding <=> query_embedding) as similarity
from documents
order by documents.embedding <=> query_embedding
limit match_count;
end;
$$;python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
Create a .env file:
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key
# OpenAI (if using)
OPENAI_API_KEY=your_openai_key
# Vertex AI (if using)
GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
GCP_PROJECT_ID=your_project_id
GCP_LOCATION=us-central1
# Email (optional)
SMTP_FROM=sender@example.com
SMTP_TO=recipient@example.com
SMTP_SERVER=smtp.gmail.com
SMTP_USERNAME=your_email
SMTP_PASSWORD=your_app_passwordFirst, upload your company documents to the vector store:
from proposal_processor import upload_documents
upload_documents(
docs_dir="path/to/your/docs",
supabase_url="your_supabase_url",
supabase_key="your_supabase_key",
embedding_provider="openai", # or "vertex"
api_key="your_api_key"
)from proposal_processor import ProposalProcessor
processor = ProposalProcessor(
supabase_url="your_supabase_url",
supabase_key="your_supabase_key",
llm_provider="openai",
openai_api_key="your_openai_key"
)
# Configure email (optional)
processor.email_config = {
"from": "sender@example.com",
"to": "recipient@example.com",
"smtp_server": "smtp.gmail.com",
"username": "your_email",
"password": "your_app_password"
}
# Run the processor
graph = processor.build_graph()
state = {"send_email": True} # Set to False to skip email
graph.run(state)processor = ProposalProcessor(
supabase_url="your_supabase_url",
supabase_key="your_supabase_key",
llm_provider="vertex",
project_id="your_gcp_project_id",
location="us-central1",
credentials_path="/path/to/credentials.json"
)
# Rest of the setup is the same as OpenAI exampleThe processor generates a PDF with the following sections:
- Corporate Overview: Company history, mission, and values
- Staff Profiles: Key team members and their qualifications
- Capabilities: Relevant competencies for the opportunity
- Corporate Experiences: Past projects and success stories
- Opportunity Responses: Direct answers to RFP questions
Each section is generated using RAG with relevant documents from your Supabase vector store.
The processor works best with the following types of documents:
- Company overview documents
- Employee resumes and bios
- Past project summaries
- Technical capability statements
- Previous proposal responses
- Marketing materials
- Case studies
- Document Organization: Keep your documents well-organized in your repository
- Regular Updates: Keep your vector store updated with latest company information
- Document Quality: Ensure uploaded documents are clean and well-formatted
- Metadata: Use descriptive filenames and maintain good metadata
- Testing: Test the output with smaller document sets before scaling up
Common issues and solutions:
- Vector Store Connection: Ensure your Supabase credentials are correct
- Document Upload: Check file permissions and formats
- LLM Errors: Verify API keys and credentials
- PDF Generation: Ensure sufficient disk space and permissions
- Email Errors: Check SMTP settings and credentials
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.