Skip to content

[Feature]: Add Gemini-Powered LLM Synthesis Layer to RAG Generator PipelineΒ #459

@Tushar15769

Description

@Tushar15769

πŸ“Œ Description

The current Retrieval-Augmented Generation (RAG) pipeline retrieves relevant documents successfully but lacks an actual LLM synthesis layer to generate contextualized and coherent responses.

At present, retrieved documents are only concatenated and returned directly, which limits answer quality, reasoning capability, and natural-language summarization.

The backend generator.py module should integrate Gemini API-based synthesis so retrieved context and user queries are processed through a large language model before generating the final response.

Additionally, the implementation should gracefully handle missing API keys by falling back to the existing document concatenation mechanism.


🎯 Objective

This feature aims to improve the intelligence and usability of the RAG system by enabling context-aware response generation using LLM synthesis.

This will:

Improve response quality
Enable better contextual reasoning
Produce human-readable summaries
Improve conversational AI experience
Maintain graceful fallback reliability


πŸ› οΈ Proposed Solution

Integrate Gemini API inside generator.py
Pass:
User query
Retrieved documents
Context metadata
Add fallback logic when API key is unavailable
Add google-generativeai dependency to requirements.txt
Improve error handling and API response validation


πŸ“Œ Features to Include

Gemini-powered synthesis pipeline
Context-aware answer generation
API key fallback handling
Error handling and retry logic
Modular prompt construction
Improved backend logging


πŸ”„ Alternatives Considered

Returning raw retrieved documents only
Using static summarization templates
Client-side synthesis generation

These alternatives provide lower-quality responses and weaker contextual reasoning.


πŸ§ͺ Acceptance Criteria

  • Gemini API integration implemented
  • Retrieved context passed correctly to LLM
  • Fallback mode works without API key
  • google-generativeai dependency added
  • API failures handled gracefully
  • Existing RAG retrieval flow remains functional
  • Response quality validated

πŸ“· Screenshots / References (if any)

N/A


πŸ“’ Contribution Guidelines

  • Comment "assign me" to work on this issue
  • Wait for assignment before starting
  • Follow project coding standards
  • Submit a clean PR with description

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions