in integrations/ai/src/main/kotlin/io/klibs/integration/ai/PackageDescriptionGenerator.kt [19:61]
fun generatePackageDescription(
packageName: String,
groupId: String,
artifactId: String?,
version: String?,
minDescriptionWordCount: Int = 10,
maxDescriptionWordCount: Int = 20
): String {
val systemMessage = SystemPromptTemplate(packageDescriptionPrompt)
.createMessage(
mapOf(
"packageName" to packageName,
"minWords" to minDescriptionWordCount,
"maxWords" to maxDescriptionWordCount
)
)
val userContent = buildString {
append("Group ID: ${groupId}\n")
if (artifactId != null) {
append("Artifact ID: ${artifactId}\n")
}
if (version != null) {
append("Version: ${version}\n")
}
}
val userMessage = UserMessage(userContent)
val options = OpenAiChatOptions.builder()
.model(AiService.WEBSEARCH_GPT)
.build()
val prompt = Prompt(listOf(systemMessage, userMessage), options)
return cleanResponse(
aiService.executeOpenAiRequest(
prompt,
"generatePackageDescription",
AiService.WEBSEARCH_GPT
)
)
}