in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/util/FeatureDevService.kt [137:189]
fun startTaskAssistCodeGeneration(conversationId: String, uploadId: String, message: String, codeGenerationId: String?, currentCodeGenerationId: String?):
StartTaskAssistCodeGenerationResponse {
try {
logger.debug { "Executing startTaskAssistCodeGeneration with conversationId: $conversationId , uploadId: $uploadId" }
val startCodeGenerationResponse = proxyClient.startTaskAssistCodeGeneration(
conversationId,
uploadId,
message,
codeGenerationId,
currentCodeGenerationId ?: "EMPTY_CURRENT_CODE_GENERATION_ID"
)
logger.debug { "$FEATURE_NAME: Started code generation with requestId: ${startCodeGenerationResponse.responseMetadata().requestId()}" }
return startCodeGenerationResponse
} catch (e: Exception) {
logger.warn(e) { "$FEATURE_NAME: Failed to execute startTaskAssistCodeGeneration ${e.message}" }
var errMssg = e.message
if (e is CodeWhispererRuntimeException) {
errMssg = e.awsErrorDetails().errorMessage()
logger.warn(e) { "StartTaskAssistCodeGeneration failed for request: ${e.requestId()}" }
// API Front-end will throw Throttling if conversation limit is reached. API Front-end monitors StartCodeGeneration for throttling
if (e is software.amazon.awssdk.services.codewhispererruntime.model.ThrottlingException &&
e.message?.contains("StartTaskAssistCodeGeneration reached for this month.") == true
) {
throw MonthlyConversationLimitError(errMssg, operation = FeatureDevOperation.StartTaskAssistCodeGeneration.toString(), desc = null, e.cause)
}
// BE service will throw ServiceQuota if code generation iteration limit is reached
else if (e is software.amazon.awssdk.services.codewhispererruntime.model.ServiceQuotaExceededException || (
e is software.amazon.awssdk.services.codewhispererruntime.model.ThrottlingException && (
e.message?.contains(
"limit for number of iterations on a code generation"
) == true
)
)
) {
throw CodeIterationLimitException(operation = FeatureDevOperation.StartTaskAssistCodeGeneration.toString(), desc = null, e.cause)
} else if (e is ValidationException && e.message?.contains("repo size is exceeding the limits") == true) {
throw ContentLengthException(operation = FeatureDevOperation.StartTaskAssistCodeGeneration.toString(), desc = null, cause = e.cause)
} else if (e is ValidationException && e.message?.contains("zipped file is corrupted") == true) {
throw ZipFileCorruptedException(operation = FeatureDevOperation.StartTaskAssistCodeGeneration.toString(), desc = null, e.cause)
}
throw ApiException.of(e.statusCode(), errMssg, operation = FeatureDevOperation.StartTaskAssistCodeGeneration.toString(), desc = null, e.cause)
}
throw ServiceException(
errMssg ?: "StartTaskAssistCodeGeneration failed",
operation = FeatureDevOperation.StartTaskAssistCodeGeneration.toString(),
desc = null,
e.cause
)
}
}