LLM Integration Overview
Splat uses Groq’s LLM API with thellama3-70b-8192 model to transform error context into structured debugging advice.
Process Function
Location:process/process.py:10-39
The core LLM integration function:
traceback_message: Full stderr stack traceoriginal_error_information: Stringified error objectcontext: Concatenated file contents from repopack
Prompt Engineering Strategy
Splat uses a multi-message system prompt to guide LLM behavior through progressive instruction layering.Message 1: Role Definition
Message 2: Step-by-Step Instructions
Message 3: Schema Definition
Message 4: Constraints & Edge Cases
Message 5: User Context
Structured Output Enforcement
Splat uses Groq’s JSON mode to guarantee valid JSON responses:Response Schema
Expected JSON Structure
Schema Breakdown
| Field | Type | Purpose |
|---|---|---|
where.repository_path | string | Absolute path to project root |
where.file_name | string | File containing the error |
where.line_number | string | Line where error occurred |
what.error_type | string | Python exception class name |
what.description | string | Human-readable error explanation |
how.error_origination | string | Line where error originated |
how.suggested_code_solution | string | Code snippet to fix the issue |
Model Configuration
Groq API Settings
Model Choice: llama3-70b-8192
Characteristics:- Size: 70 billion parameters
- Context window: 8,192 tokens
- Strengths: Code understanding, structured output
- Speed: Fast inference via Groq’s LPU architecture
- Large enough for complex code analysis
- Fast enough for real-time debugging
- Strong JSON adherence
Context Window Management
With an 8K token limit, context must be carefully managed:Token Budget Breakdown
| Component | Approx. Tokens | % of Budget |
|---|---|---|
| System prompts | ~500 | 6% |
| Traceback | ~200-500 | 3-6% |
| File context | ~6000-7000 | 75-87% |
| Response | ~300 | 4% |
Context Optimization Strategies
1. Flag-based control:- No flag: Only error files (minimal context)
-rflag: All related files (maximum context)
Agent Architecture (Next Generation)
Location:agents/agents.py
Splat is evolving toward an agent-based architecture using Pydantic AI:
Key Differences from Current Implementation
| Feature | Current (process.py) | Next Gen (agents.py) |
|---|---|---|
| Framework | Raw Groq API | Pydantic AI |
| Schema validation | Manual JSON parsing | Automatic Pydantic validation |
| Type safety | Runtime checks | Compile-time types |
| Dependency injection | Global context | FlagDependencies dataclass |
| Tool support | None | @agent.tool decorators |
Pydantic AI Benefits
1. Automatic validation:Prompt Engineering Best Practices
1. Progressive Instruction Layering
Break complex instructions into multiple messages:- Message 1: Role
- Message 2: Process
- Message 3: Schema
- Message 4: Constraints
2. Explicit Format Enforcement
3. Negative Constraints
4. Contextual Specificity
5. Single-Error Focus
Error Handling & Edge Cases
API Failures
Current implementation: No explicit error handling Recommended addition:Invalid JSON Responses
Mitigation: JSON mode enforces valid JSON Fallback: Parse errors should still be caught:Token Limit Exceeded
Current behavior: API will truncate or error Recommendation: Pre-check token count:Performance Metrics
Typical Response Times
| Context Size | Approx. Time |
|---|---|
| < 2K tokens | ~1-2 seconds |
| 2K-5K tokens | ~2-4 seconds |
| 5K-8K tokens | ~4-6 seconds |
Cost Considerations
Groq pricing (as of 2024):- Input: $0.10 per 1M tokens
- Output: $0.10 per 1M tokens
- Input: ~7K tokens = $0.0007
- Output: ~300 tokens = $0.00003
- Total per debug: ~$0.0007 (less than a penny)
Integration Flow Diagram
Environment Configuration
Required:.env file with API key
process/process.py:5-8.
Next Steps
Error Pipeline
Learn how context is prepared for LLM
Architecture Overview
Return to system overview