LLM ProviderPython integration
LLMSlim + Google Gemini
Compress retrieved Python context before a Gemini SDK request.
Use compress_documents() for retrieved text and preserve accurate provenance.
1. Package installation
Install LLMSlim and the official Google Gemini SDK using your package manager.
pip install llmslim2. Architecture & execution flow
3. Production code pattern
from llmslim import compress_documents
compressed = compress_documents(documents, query=query, target_ratio=0.4)4. Deployment best practices
5. Key optimization tips
6. Performance metrics
Frequently asked questions
Troubleshooting
Unexpected compression result
Check target_ratio, role labels, and whether the input is long enough to benefit from compression.