in integrations/ai/src/main/kotlin/io/klibs/integration/ai/ProjectTagsGenerator.kt [25:60]
fun generateTagsForProject(
projectName: String,
projectDescription: String,
repoDescription: String,
readmeMdContent: String
): List<String> {
// If there is no README, no description, and no repository description, skip generation
if (projectDescription.isBlank() && repoDescription.isBlank() && readmeMdContent.isBlank()) {
throw IllegalStateException("Skip: no description, no repo description and no README available")
}
val sb = StringBuilder()
sb.appendLine("Project name: $projectName")
if (projectDescription.isNotBlank()) sb.appendLine("Description: $projectDescription")
if (repoDescription.isNotBlank()) sb.appendLine("Repository description: $repoDescription")
if (readmeMdContent.isNotBlank()) sb.appendLine("README: $readmeMdContent")
val userContent = sb.toString().trim()
val messages = buildList<Message> {
add(SystemMessage(systemPrompt))
add(UserMessage(userContent))
}
val prompt = Prompt(messages, options)
val content = aiService.executeOpenAiRequest(
prompt,
"generateProjectTags",
modelName
)
val parsed: TagSelection = objectMapper.readValue(content)
val picked = parsed.indices.mapNotNull { idx -> tagRules.getOrNull(idx)?.name }
return picked
}