Skip to content

Commit 8a7adab

Browse files
committed
fix(agent): resolve issue with custom fields in message
- Update request handling for custom fields - Replace generic content formatting with actual prompt text
1 parent 3fb8c55 commit 8a7adab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/src/main/kotlin/cc/unitmesh/devti/agent/custom/CustomAgentExecutor.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ class CustomAgentExecutor(val project: Project) : CustomSSEProcessor(project) {
3434
this.responseFormat = agent.connector?.responseFormat ?: this.responseFormat
3535

3636
val customRequest = CustomRequest(listOf(Message("user", promptText)))
37-
val request = if (requestFormat.isNotEmpty()) {
37+
var request = if (requestFormat.isNotEmpty()) {
3838
customRequest.updateCustomFormat(requestFormat)
3939
} else {
4040
Json.encodeToString<CustomRequest>(customRequest)
4141
}
4242

43+
// fix for custom fields in message replace \"content\": \"$content\" with \"$content\": promptText
44+
val errorContent = "\"content\":\"\$content\""
45+
if (request.contains(errorContent)) {
46+
request = request.replace(errorContent, "\"content\": \"$promptText\"")
47+
}
48+
4349
val body = request.toRequestBody("application/json".toMediaTypeOrNull())
4450
val builder = Request.Builder()
4551

0 commit comments

Comments
 (0)