Проанализируй класс. Используя магию котлина, сделай его красивее и лучше.

```kotlin
private class DataGenerator(private val client: OkHttpClient, private val url: String, private val plugin: QuestIntelligence) {

        fun generateData(prompt: String, onSuccess: (String) -> Unit) {
            val jsonInputString = createJsonRequest(prompt)
            val body = jsonInputString.toRequestBody("application/json".toMediaTypeOrNull())
            val request = createRequest(body)

            client.newCall(request).enqueue(object : Callback {
                override fun onFailure(call: Call, e: IOException) {
                    e.printStackTrace()  // Здесь также можно добавить обработку ошибки
                }

                override fun onResponse(call: Call, response: Response) {
                    if (response.isSuccessful) {
                        handleSuccessfulResponse(response, onSuccess)
                    } else {
                        handleFailedResponse(response, request)
                    }
                }
            })
        }

        private fun createJsonRequest(prompt: String): String {
            return """
        {
            "contents": [
                {
                    "parts": [
                        {
                            "text": "$prompt"
                        }
                    ]
                }
            ],
            "safetySettings": [
                {
                    "category": "7",
                    "threshold": "4"
                }
            ]
        }
        """.trimIndent()
        }

        private fun createRequest(body: RequestBody): Request {
            return Request.Builder()
                .url(url)
                .post(body)
                .build()
        }

        private fun handleSuccessfulResponse(response: Response, onSuccess: (String) -> Unit) {
            try {
                val responseData = plugin.gson.fromJson(response.body!!.string(), ResponseData::class.java)
                val responseText = responseData?.candidates?.firstOrNull()?.content?.parts?.firstOrNull()?.text ?: return
                val jsonData = findJson(responseText) ?: return
                val cleanedData = cleanQuestJson(jsonData)
                onSuccess(cleanedData)
            } catch (ignored: Exception) {
                // Можно добавить логирование ошибки
            }
        }

        private fun handleFailedResponse(response: Response, request: Request) {
            plugin.logger.info("Request failed: ${response.code}, ${response.message}")
            plugin.logger.info("Request: $request")
        }

        private fun cleanQuestJson(questJson: String): String {
            return questJson
                .replace("```json\n", "")
                .replace("```", "")
                .replace("\\n", "\n")
                .replace("\\\"", "")
                .replace("  ", " ")
                .replace("*", "")
        }

        private fun findJson(response: String): String? {
            val regex = """\{[^{}]*}""".toRegex()

            val matchResult = regex.find(response)
            val jsonString = matchResult?.value

            return jsonString
        }
    }
```