lex-rfp
Generative AI-powered RFP and proposal automation for LegionIO. Ingests past proposals and product documentation into Apollo, generates draft RFP responses via the LLM pipeline with RAG retrieval, provides human-in-the-loop review workflows, and tracks win rates with quality analytics.
Architecture
Monolith-style extension with four sub-modules:
| Sub-Module | Purpose |
|---|---|
| Ingest | Document parsing (PDF, DOCX, Markdown, Excel, HTML), text chunking, corpus management, Apollo ingestion |
| Generate | Draft response generation via LLM + RAG, section-by-section and full-document modes, template system |
| Review | Human-in-the-loop workflows, section-level status tracking, comments, approvals |
| Analytics | Win rate tracking, proposal metrics, response time stats, quality scoring |
Installation
gem install lex-rfp
Or add to your Gemfile:
gem 'lex-rfp'
Usage
Standalone Clients
Each sub-module provides a standalone Client class:
# Ingest documents
ingest = Legion::Extensions::Rfp::Ingest::Client.new
result = ingest.ingest_document(file_path: 'past_proposal.pdf', tags: ['healthcare'])
chunks = result[:result]
# Generate RFP responses
gen = Legion::Extensions::Rfp::Generate::Client.new
draft = gen.generate_response(question: 'Describe your network coverage')
# Review workflow
review = Legion::Extensions::Rfp::Review::Client.new
wf = review.create_workflow(proposal_id: 'prop-123', sections: %w[summary approach pricing])
review.submit_for_review(workflow_id: wf[:result][:id], reviewers: ['reviewer-1'])
# Analytics
analytics = Legion::Extensions::Rfp::Analytics::Client.new
rate = analytics.overall_win_rate(proposals: proposal_data)
Ingest Functions
supported?(file_path:)- Check if a file format is supportedextract_text(file_path:)- Extract text from a documentchunk_text(text:, chunk_size:, overlap:)- Split text into overlapping chunksingest_document(file_path:, tags:, metadata:)- Full document ingest pipelineingest_directory(directory:, tags:, recursive:)- Batch ingest all supported filesingest_to_apollo(chunks:, scope:)- Push chunks to Apollo knowledge storeparse_rfp_questions(text:)- Extract numbered questions from RFP textextract_requirements(text:)- Identify mandatory and preferred requirementsextract_sections(text:)- Split RFP into logical sections
Generate Functions
generate_full_draft(rfp_text:, context:, model:)- Generate complete RFP responsegenerate_response(question:, context:, model:, scope:)- Generate single question response with RAGregenerate(question:, previous_answer:, feedback:)- Revise response based on feedbackgenerate_section_response(question:, section:, context:)- Section-specific responsegenerate_executive_summary(rfp_text:, company_context:)- Executive summary generationgenerate_compliance_matrix(requirements:, capabilities:)- Compliance matrixlist_templates/get_template(name:)/apply_template(name:, rfp_data:)- Template managementsuggest_template(rfp_text:)- Auto-suggest appropriate template
Review Functions
create_workflow(proposal_id:, sections:, reviewers:)- Create review workflowupdate_status(workflow_id:, status:)/update_section_status(...)- Status managementsubmit_for_review(workflow_id:, reviewers:)- Submit for reviewfinalize(workflow_id:)- Finalize proposaladd_comment(...)/resolve_comment(...)/request_revision(...)- Comment systemapprove_section(...)/reject_section(...)/approve_proposal(...)- Approvalscheck_readiness(sections:)- Check if all sections are approved
Analytics Functions
record_proposal(proposal_id:, rfp_source:, ...)- Record proposal metadatarecord_outcome(proposal_id:, outcome:, revenue:)- Record win/loss outcomesummary(proposals:)- Aggregate statisticsresponse_time_stats(proposals:)- Response time analysisoverall_win_rate(proposals:)- Overall win ratewin_rate_by_source(proposals:)/win_rate_by_template(proposals:)- Segmented ratestrend(proposals:, period:)- Win rate trends over timescore_response(response_text:, question:, requirements:)- Quality scoringscore_proposal(sections:)- Full proposal quality scorequality_report(proposals:)- Aggregate quality report
Supported Document Formats
- PDF (via legion-data Extract)
- DOCX (via legion-data Extract)
- Markdown (.md, .markdown)
- Excel (.xlsx, via legion-data Extract)
- HTML (.html, .htm)
Requirements
- Ruby >= 3.4
- LegionIO framework
faraday(>= 2.0)- Optional:
legion-llmfor LLM-powered generation - Optional:
legion-apollofor RAG retrieval - Optional:
legion-datafor PDF/DOCX/Excel extraction
License
MIT