2
0

refactor(ai): consolidate ai operation types and reduce duplication
All checks were successful
Build and Release / Create Release (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 7m11s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 7m21s
Build and Release / Lint (push) Successful in 7m32s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been skipped
Build and Release / Build Binary (linux/arm64) (push) Has been skipped

Refactor AI service layer to reduce code duplication and improve consistency.

Changes:
- Rename AIOperationRequest to OperationRequest for consistency
- Extract shared logic for issue-targeted operations (respond, triage) into triggerIssueAIOp helper
- Standardize field alignment in struct definitions
- Remove redundant error handling patterns

This reduces the API operations file by ~40 lines while maintaining identical functionality.
This commit is contained in:
2026-02-12 00:55:52 -05:00
parent c9f6c4e7d2
commit 14338d8fd4
9 changed files with 74 additions and 100 deletions

View File

@@ -207,11 +207,11 @@ type GenerateIssueResponseRequest struct {
// GenerateIssueResponseResponse is the response from generating an issue response
type GenerateIssueResponseResponse struct {
Response string `json:"response"`
FollowUpQuestions []string `json:"follow_up_questions,omitempty"`
Confidence float64 `json:"confidence"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
Response string `json:"response"`
FollowUpQuestions []string `json:"follow_up_questions,omitempty"`
Confidence float64 `json:"confidence"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
// HealthCheckResponse is the response from a health check

View File

@@ -172,11 +172,11 @@ const (
// AI errors (AI_)
const (
AIDisabled ErrorCode = "AI_DISABLED"
AIUnitNotEnabled ErrorCode = "AI_UNIT_NOT_ENABLED"
AIDisabled ErrorCode = "AI_DISABLED"
AIUnitNotEnabled ErrorCode = "AI_UNIT_NOT_ENABLED"
AIOperationNotFound ErrorCode = "AI_OPERATION_NOT_FOUND"
AIRateLimitExceeded ErrorCode = "AI_RATE_LIMIT_EXCEEDED"
AIServiceError ErrorCode = "AI_SERVICE_ERROR"
AIServiceError ErrorCode = "AI_SERVICE_ERROR"
AIOperationDisabled ErrorCode = "AI_OPERATION_DISABLED"
)