Description
Add OpenAIGenerator and/or AnthropicGenerator that format retrieved chunks as context and call the respective chat completion API to produce a grounded answer.
Motivation
EchoGenerator is a placeholder that just returns the retrieved text. Real applications need an LLM to synthesise a coherent answer from the retrieved context. This is the final piece needed for a fully functional RAG pipeline.
Acceptance criteria
Files to touch
ragframework/generator/openai.py and/or ragframework/generator/anthropic.py
ragframework/generator/__init__.py — export
tests/test_generator/ — new test files
examples/ — add example script
Resources
Description
Add
OpenAIGeneratorand/orAnthropicGeneratorthat format retrieved chunks as context and call the respective chat completion API to produce a grounded answer.Motivation
EchoGeneratoris a placeholder that just returns the retrieved text. Real applications need an LLM to synthesise a coherent answer from the retrieved context. This is the final piece needed for a fully functional RAG pipeline.Acceptance criteria
OpenAIGeneratorinragframework/generator/openai.pyand/orAnthropicGeneratorinragframework/generator/anthropic.pyGeneratorfromragframework/base.pymodel,api_key(env var fallback),system_prompt,max_tokensopenai/anthropicSDK (already in optional extras inpyproject.toml)GeneratorErroron failureunittest.mock— no real API calls in CIragframework/generator/__init__.pyexamples/CHANGELOG.mdupdated under[Unreleased]Files to touch
ragframework/generator/openai.pyand/orragframework/generator/anthropic.pyragframework/generator/__init__.py— exporttests/test_generator/— new test filesexamples/— add example scriptResources
EchoGeneratorinragframework/generator/echo_generator.pyas reference