Files

59 lines
1.3 KiB
Markdown

# Graph Answer Generation with Retry Logic
This repository contains a minimal example of how to replace a
special "reflect" node in a graph-based answer generation system
with a simple `try/except` retry mechanism.
## Features
- **Retry Logic**: Attempts to generate an answer up to a configurable
number of times (`max_retries`). If all attempts fail, a
`GenerationError` is raised.
- **Backoff**: Optional exponential backoff between retries.
- **Simulation**: The example uses a simulated generator that
randomly fails to demonstrate the retry behavior.
## Usage
```bash
# Run the example
python -m src.index
```
You should see output similar to:
```
Answer generated successfully:
Generated answer content
```
If the generation fails after all retries, you will see:
```
Error: Answer generation failed after 3 attempts
```
## Customization
- **Changing the number of retries**:
```python
answer = get_answer_with_retry(max_retries=5)
```
- **Using a real generator**:
Replace `_simulate_answer_generation` with your own function
that performs the actual answer generation logic.
## Project Structure
```
src/
├── index.py # Main implementation
README.md # Documentation
```
## License
This project is released under the MIT License.