File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/main/kotlin/cc/unitmesh/devti/connector/custom Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package cc.unitmesh.devti.connector.custom
2
2
3
3
import cc.unitmesh.devti.connector.CodeCopilot
4
4
import cc.unitmesh.devti.settings.DevtiSettingsState
5
+ import com.intellij.openapi.diagnostic.Logger
6
+ import com.intellij.openapi.diagnostic.logger
5
7
import kotlinx.serialization.decodeFromString
6
8
import kotlinx.serialization.json.Json
7
9
import okhttp3.OkHttpClient
@@ -35,6 +37,8 @@ class CustomConnector : CodeCopilot {
35
37
}
36
38
}
37
39
40
+ private val logger = Logger .getInstance(CustomConnector ::class .java)
41
+
38
42
fun prompt (instruction : String , input : String ): String {
39
43
val body = okhttp3.RequestBody .create(
40
44
okhttp3.MediaType .parse(" application/json; charset=utf-8" ),
@@ -58,6 +62,11 @@ class CustomConnector : CodeCopilot {
58
62
59
63
val response = client.newCall(request).execute()
60
64
65
+ if (! response.isSuccessful) {
66
+ logger.error(" $response " )
67
+ return " "
68
+ }
69
+
61
70
return response.body()?.string() ? : " "
62
71
}
63
72
You can’t perform that action at this time.
0 commit comments