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:
2026-04-13 16:08:12 +08:00
parent 6066f43a7d
commit 1b01caac0f
21 changed files with 1630 additions and 392 deletions
@@ -29,6 +29,7 @@ const questionId = computed(() => parsePositiveNumber(route.params.questionId));
const questionHash = computed(() => normalizeQueryValue(route.query.question_hash));
const questionTitleFallback = computed(() => normalizeQueryValue(route.query.question_text));
const keywordId = computed(() => normalizeQueryValue(route.query.keyword_id));
const requestedPlatformId = computed(() => normalizeQueryValue(route.query.ai_platform_id));
const businessDate = computed(() => normalizeTrackingBusinessDate(route.query.business_date) || trackingToday);
const dateFrom = computed(() => {
return normalizeQueryValue(route.query.date_from) || businessDate.value;
@@ -44,6 +45,7 @@ const detailQuery = useQuery({
brandId.value,
questionId.value,
questionHash.value,
requestedPlatformId.value,
dateFrom.value,
dateTo.value,
]),
@@ -53,6 +55,7 @@ const detailQuery = useQuery({
date_from: dateFrom.value,
date_to: dateTo.value,
question_hash: questionHash.value || undefined,
ai_platform_id: requestedPlatformId.value || undefined,
}),
});
@@ -66,9 +69,8 @@ watch(
return;
}
const requestedPlatformId = normalizeQueryValue(route.query.ai_platform_id);
const requestedPlatform = requestedPlatformId
? platforms.find((item) => item.ai_platform_id === requestedPlatformId)
const requestedPlatform = requestedPlatformId.value
? platforms.find((item) => item.ai_platform_id === requestedPlatformId.value)
: null;
const sampledPlatform = platforms.find((item) => item.sample_status === "sampled");
const nextPlatform = requestedPlatform ?? sampledPlatform ?? platforms[0];
@@ -130,6 +132,7 @@ function goBack(): void {
query: {
brand_id: brandId.value ? String(brandId.value) : undefined,
keyword_id: keywordId.value || undefined,
ai_platform_id: requestedPlatformId.value || undefined,
business_date: businessDate.value,
},
});