Integrate GitCaddy AI service with support for code review, issue triage, documentation generation, code explanation, and chat interface. Add AI client module with HTTP communication, configuration settings, API routes (web and REST), service layer, and UI templates for issue sidebar. Include comprehensive configuration options in app.example.ini for enabling/disabling features and service connection settings.
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
// Copyright 2026 MarketAlly. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"time"
|
|
|
|
"code.gitcaddy.com/server/v3/modules/log"
|
|
)
|
|
|
|
// AI settings for the GitCaddy AI service integration
|
|
var AI = struct {
|
|
Enabled bool
|
|
ServiceURL string
|
|
ServiceToken string
|
|
Timeout time.Duration
|
|
MaxRetries int
|
|
EnableCodeReview bool
|
|
EnableIssueTriage bool
|
|
EnableDocGen bool
|
|
EnableExplainCode bool
|
|
EnableChat bool
|
|
MaxFileSizeKB int64
|
|
MaxDiffLines int
|
|
}{
|
|
Enabled: false,
|
|
ServiceURL: "localhost:50051",
|
|
ServiceToken: "",
|
|
Timeout: 30 * time.Second,
|
|
MaxRetries: 3,
|
|
EnableCodeReview: true,
|
|
EnableIssueTriage: true,
|
|
EnableDocGen: true,
|
|
EnableExplainCode: true,
|
|
EnableChat: true,
|
|
MaxFileSizeKB: 500,
|
|
MaxDiffLines: 5000,
|
|
}
|
|
|
|
func loadAIFrom(rootCfg ConfigProvider) {
|
|
sec := rootCfg.Section("ai")
|
|
AI.Enabled = sec.Key("ENABLED").MustBool(false)
|
|
AI.ServiceURL = sec.Key("SERVICE_URL").MustString("localhost:50051")
|
|
AI.ServiceToken = sec.Key("SERVICE_TOKEN").MustString("")
|
|
AI.Timeout = sec.Key("TIMEOUT").MustDuration(30 * time.Second)
|
|
AI.MaxRetries = sec.Key("MAX_RETRIES").MustInt(3)
|
|
AI.EnableCodeReview = sec.Key("ENABLE_CODE_REVIEW").MustBool(true)
|
|
AI.EnableIssueTriage = sec.Key("ENABLE_ISSUE_TRIAGE").MustBool(true)
|
|
AI.EnableDocGen = sec.Key("ENABLE_DOC_GEN").MustBool(true)
|
|
AI.EnableExplainCode = sec.Key("ENABLE_EXPLAIN_CODE").MustBool(true)
|
|
AI.EnableChat = sec.Key("ENABLE_CHAT").MustBool(true)
|
|
AI.MaxFileSizeKB = sec.Key("MAX_FILE_SIZE_KB").MustInt64(500)
|
|
AI.MaxDiffLines = sec.Key("MAX_DIFF_LINES").MustInt(5000)
|
|
|
|
if AI.Enabled && AI.ServiceURL == "" {
|
|
log.Error("AI is enabled but SERVICE_URL is not configured")
|
|
AI.Enabled = false
|
|
}
|
|
|
|
if AI.Enabled {
|
|
log.Info("AI service integration enabled, connecting to %s", AI.ServiceURL)
|
|
}
|
|
}
|