Skip to content

Commit

Permalink
feat(CustomAgentExecutor): add support for custom format in CustomAge…
Browse files Browse the repository at this point in the history
…ntExecutor #51

Add `updateCustomFormat` function to `CustomAgentExecutor` class to handle custom format in requests sent to custom agents. This allows agents to receive and process requests in a format specified by the agent.
  • Loading branch information
phodal committed Mar 7, 2024
1 parent f754256 commit 583ee94
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import cc.unitmesh.devti.counit.model.CustomAgentResponseAction
import cc.unitmesh.devti.llms.custom.CustomRequest
import cc.unitmesh.devti.llms.custom.CustomSSEProcessor
import cc.unitmesh.devti.llms.custom.Message
import cc.unitmesh.devti.llms.custom.updateCustomFormat
import com.intellij.openapi.components.Service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import kotlinx.coroutines.flow.Flow
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody
Expand All @@ -29,7 +28,7 @@ class CustomAgentExecutor(val project: Project) : CustomSSEProcessor() {
this.requestFormat = agent.connector?.requestFormat ?: this.requestFormat

val customRequest = CustomRequest(listOf(Message("user", input)))
val request = Json.encodeToString<CustomRequest>(customRequest)
val request = customRequest.updateCustomFormat(requestFormat)

val body = request.toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())
val builder = Request.Builder()
Expand Down

0 comments on commit 583ee94

Please sign in to comment.