blob: 3739c27cec070d4c4660b44239c715584399c9c7 [file] [log] [blame]
iomodof1ddefe2025-07-28 09:02:05 +04001package fake
2
3import (
4 "context"
5 "fmt"
6 "time"
7
8 "github.com/iomodo/staff/llm"
9)
10
11// FakeProvider implements a fake LLM provider for testing
12type FakeProvider struct {
13 responses []string
14 index int
15}
16
17// NewFakeProvider creates a new fake provider with predefined responses
18func NewFakeProvider() *FakeProvider {
19 responses := []string{
20 `## Task Solution
21
22I've analyzed the task requirements and here's my proposed solution:
23
24### Implementation Plan
251. Create the necessary data structures
262. Implement the core business logic
273. Add proper error handling
284. Write comprehensive tests
295. Update documentation
30
31### Code Changes
32- Add new functions to handle the requirements
33- Update existing modules for compatibility
34- Implement proper validation
35- Add logging for debugging
36
37### Testing Strategy
38- Unit tests for all new functions
39- Integration tests for the workflow
40- Performance tests for scalability
41- Edge case validation
42
43### Files to Create/Modify
44- src/main.go - Core implementation
45- src/handlers.go - Request handlers
46- src/models.go - Data models
47- tests/ - Test files
48- docs/ - Documentation updates
49
50### Dependencies
51No new external dependencies required.
52
53### Deployment Notes
54- Backward compatible changes
55- No database migrations needed
56- Can be deployed incrementally
57
58This solution addresses all the requirements while maintaining code quality and system stability.`,
59
60 `## Comprehensive Task Analysis
61
62After careful consideration, I recommend the following approach:
63
64### Technical Architecture
65- **Backend**: Implement using existing Go patterns
66- **Database**: Utilize current PostgreSQL setup
67- **API**: RESTful endpoints with proper versioning
68- **Security**: OAuth2 authentication with JWT tokens
69
70### Development Steps
711. **Phase 1**: Core functionality implementation
722. **Phase 2**: User interface development
733. **Phase 3**: Testing and optimization
744. **Phase 4**: Documentation and deployment
75
76### Risk Assessment
77- **Low Risk**: Well-defined requirements
78- **Medium Risk**: Timeline constraints
79- **Mitigation**: Incremental development approach
80
81### Resource Requirements
82- Development time: 2-3 weeks
83- Testing phase: 1 week
84- Documentation: 2-3 days
85
86### Success Metrics
87- Performance benchmarks met
88- All test cases passing
89- User acceptance criteria satisfied
90- Code coverage > 90%
91
92This solution provides a robust foundation for future enhancements while meeting immediate business needs.`,
93
94 `## Strategic Implementation Proposal
95
96### Executive Summary
97This task requires a comprehensive solution that balances technical excellence with business objectives.
98
99### Solution Overview
100- **Approach**: Agile development methodology
101- **Technology Stack**: Current tech stack enhancement
102- **Timeline**: 3-4 week delivery cycle
103- **Team**: Cross-functional collaboration
104
105### Technical Specifications
106- Clean architecture principles
107- Microservices design patterns
108- Event-driven communication
109- Comprehensive monitoring and logging
110
111### Implementation Details
1121. **Requirements Analysis**: Complete stakeholder alignment
1132. **System Design**: Scalable and maintainable architecture
1143. **Development**: Test-driven development approach
1154. **Quality Assurance**: Automated testing pipeline
1165. **Deployment**: Blue-green deployment strategy
117
118### Business Impact
119- Improved user experience
120- Enhanced system reliability
121- Reduced operational overhead
122- Increased development velocity
123
124### Next Steps
1251. Stakeholder review and approval
1262. Resource allocation confirmation
1273. Development sprint planning
1284. Implementation kickoff
129
130This solution ensures long-term success while delivering immediate value to the organization.`,
131 }
132
133 return &FakeProvider{
134 responses: responses,
135 index: 0,
136 }
137}
138
139// ChatCompletion implements the LLM interface
140func (f *FakeProvider) ChatCompletion(ctx context.Context, req llm.ChatCompletionRequest) (*llm.ChatCompletionResponse, error) {
141 // Simulate API delay
142 time.Sleep(500 * time.Millisecond)
143
144 // Get the next response (cycle through responses)
145 response := f.responses[f.index%len(f.responses)]
146 f.index++
147
148 return &llm.ChatCompletionResponse{
149 ID: fmt.Sprintf("fake-response-%d", f.index),
150 Object: "chat.completion",
151 Created: time.Now().Unix(),
152 Model: req.Model,
153 Choices: []llm.ChatCompletionChoice{
154 {
155 Index: 0,
156 Message: llm.Message{
157 Role: llm.RoleAssistant,
158 Content: response,
159 },
160 FinishReason: "stop",
161 },
162 },
163 Usage: llm.Usage{
164 PromptTokens: 100,
165 CompletionTokens: 300,
166 TotalTokens: 400,
167 },
168 }, nil
169}
170
171// CreateEmbeddings implements the LLM interface (not used in current implementation)
172func (f *FakeProvider) CreateEmbeddings(ctx context.Context, req llm.EmbeddingRequest) (*llm.EmbeddingResponse, error) {
173 return &llm.EmbeddingResponse{
174 Object: "list",
175 Data: []llm.Embedding{
176 {
177 Object: "embedding",
178 Index: 0,
179 Embedding: make([]float64, 1536), // OpenAI embedding size
180 },
181 },
182 Model: req.Model,
183 Usage: llm.Usage{
184 PromptTokens: 50,
185 TotalTokens: 50,
186 },
187 }, nil
188}
189
190// Close implements the LLM interface
191func (f *FakeProvider) Close() error {
192 // Nothing to close for fake provider
193 return nil
194}