feat(prompts): add prompts loader and configuration management
- Implemented a new prompts loader in `loader.go` to manage prompt templates and configurations. - Introduced caching mechanism for prompt configurations to optimize loading. - Added functions to apply platform-specific prompt template overrides. - Created unit tests in `loader_test.go` to validate prompt configuration loading and reloading behavior. - Ensured that the last valid configuration is retained in case of errors during reload.
This commit is contained in:
@@ -2,6 +2,7 @@ package transport
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -43,7 +44,9 @@ func (h *MonitoringHandler) DashboardComposite(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
data, svcErr := h.svc.DashboardComposite(c.Request.Context(), brandID, keywordID, days, c.Query("business_date"))
|
||||
aiPlatformID := parseOptionalStringPointer(c.Query("ai_platform_id"))
|
||||
|
||||
data, svcErr := h.svc.DashboardComposite(c.Request.Context(), brandID, keywordID, days, c.Query("business_date"), aiPlatformID)
|
||||
if svcErr != nil {
|
||||
response.Error(c, svcErr)
|
||||
return
|
||||
@@ -64,11 +67,7 @@ func (h *MonitoringHandler) QuestionDetail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var aiPlatformID *string
|
||||
if value := c.Query("ai_platform_id"); value != "" {
|
||||
trimmed := value
|
||||
aiPlatformID = &trimmed
|
||||
}
|
||||
aiPlatformID := parseOptionalStringPointer(c.Query("ai_platform_id"))
|
||||
|
||||
data, svcErr := h.svc.QuestionDetail(
|
||||
c.Request.Context(),
|
||||
@@ -131,3 +130,12 @@ func parseOptionalInt(raw string) (int, error) {
|
||||
}
|
||||
return strconv.Atoi(raw)
|
||||
}
|
||||
|
||||
func parseOptionalStringPointer(raw string) *string {
|
||||
trimmed := strings.TrimSpace(raw)
|
||||
if trimmed == "" {
|
||||
return nil
|
||||
}
|
||||
value := trimmed
|
||||
return &value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user