Skip to content

Commit 319f6e0

Browse files
committed
feat: add support for configurable prompt mapping
Signed-off-by: hadi2f244 <[email protected]>
1 parent c823de1 commit 319f6e0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pkg/ai/iai.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ func NewClient(provider string) IAI {
100100
}
101101

102102
type AIConfiguration struct {
103-
Providers []AIProvider `mapstructure:"providers"`
104-
DefaultProvider string `mapstructure:"defaultprovider"`
103+
Providers []AIProvider `mapstructure:"providers"`
104+
DefaultProvider string `mapstructure:"defaultprovider"`
105+
PromptMap map[string]string `mapstructure:"promptmap"`
105106
}
106107

107108
type AIProvider struct {

pkg/analysis/analysis.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Analysis struct {
4141
Client *kubernetes.Client
4242
Language string
4343
AIClient ai.IAI
44+
PromptMap map[string]string
4445
Results []common.Result
4546
Errors []string
4647
Namespace string
@@ -159,6 +160,16 @@ func NewAnalysis(
159160
if err := aiClient.Configure(&aiProvider); err != nil {
160161
return nil, err
161162
}
163+
164+
// Override values from configAI.PromptMap
165+
if len(configAI.PromptMap) > 0 {
166+
for key, value := range configAI.PromptMap {
167+
if key != "raw" {
168+
ai.PromptMap[key] = value
169+
}
170+
}
171+
}
172+
162173
a.AIClient = aiClient
163174
a.AnalysisAIProvider = aiProvider.Name
164175
return a, nil

0 commit comments

Comments
 (0)