Skip to content

Commit

Permalink
Add completion model
Browse files Browse the repository at this point in the history
  • Loading branch information
pplam committed Jun 15, 2024
1 parent 64b19f7 commit 82cbe74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/main/kotlin/ai/devchat/plugin/completion/agent/Agent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Agent(val scope: CoroutineScope) {

data class CompletionResponse(
val id: String,
val model: String?,
val choices: List<Choice>,
val promptBuildingElapse: Long,
val llmRequestElapse: Long
Expand All @@ -71,6 +72,7 @@ class Agent(val scope: CoroutineScope) {
@SerializedName("language") val language: String,
@SerializedName("prompt_time") val promptBuildingElapse: Long,
@SerializedName("llm_time") val llmRequestElapse: Long,
@SerializedName("model") val model: String? = null,
@SerializedName("cache_hit") val cacheHit: Boolean = false
) {
enum class EventType {
Expand Down Expand Up @@ -269,12 +271,13 @@ class Agent(val scope: CoroutineScope) {
completionRequest: CompletionRequest
): CompletionResponse? = suspendCancellableCoroutine { continuation ->
currentRequest = RequestInfo.fromCompletionRequest(completionRequest)
val model = CONFIG["complete_model"] as? String
var startTime = System.currentTimeMillis()
val prompt = ContextBuilder(
completionRequest.filepath,
completionRequest.text,
completionRequest.position
).createPrompt(CONFIG["complete_model"] as? String)
).createPrompt(model)
val promptBuildingElapse = System.currentTimeMillis() - startTime

scope.launch {
Expand All @@ -289,7 +292,7 @@ class Agent(val scope: CoroutineScope) {
val offset = completionRequest.position
val replaceRange = CompletionResponse.Choice.Range(start = offset, end = offset)
val choice = CompletionResponse.Choice(index = 0, text = completion.text, replaceRange = replaceRange)
val response = CompletionResponse(completion.id, listOf(choice), promptBuildingElapse, llmRequestElapse)
val response = CompletionResponse(completion.id, model, listOf(choice), promptBuildingElapse, llmRequestElapse)
continuation.resumeWith(Result.success(response))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ class InlineCompletionService {
ide = "intellij",
language = virtualFile?.extension ?: "",
promptBuildingElapse = completion.promptBuildingElapse,
llmRequestElapse = completion.llmRequestElapse
llmRequestElapse = completion.llmRequestElapse,
model = completion.model,
)
)
}
Expand Down Expand Up @@ -234,7 +235,8 @@ class InlineCompletionService {
ide = "intellij",
language = virtualFile?.extension ?: "",
promptBuildingElapse = currentCompletion.completion.promptBuildingElapse,
llmRequestElapse = currentCompletion.completion.llmRequestElapse
llmRequestElapse = currentCompletion.completion.llmRequestElapse,
model = currentCompletion.completion.model,
)
)
}
Expand All @@ -253,6 +255,7 @@ class InlineCompletionService {
)),
promptBuildingElapse = 0,
llmRequestElapse = 0,
model = currentCompletion.completion.model,
)
)
}
Expand Down

0 comments on commit 82cbe74

Please sign in to comment.