Skip to content

Commit

Permalink
feat(counit): init basic apis
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 25, 2023
1 parent 51bc5fb commit e78f864
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/counit/PatternMatching.kt
@@ -0,0 +1,5 @@
package cc.unitmesh.devti.counit

class PatternMatching {

}
11 changes: 11 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/counit/PreProcessor.kt
@@ -0,0 +1,11 @@
package cc.unitmesh.devti.counit

import cc.unitmesh.devti.settings.configurable.coUnitSettings
import com.intellij.openapi.project.Project

class PreProcessor(val project: Project) {
fun isCoUnit(input: String): Boolean {
return project.coUnitSettings.enableCoUnit && input.startsWith("/counit")
}
}

19 changes: 19 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/counit/client/CoUnitApi.kt
@@ -0,0 +1,19 @@
package cc.unitmesh.devti.counit.client

import cc.unitmesh.devti.counit.model.PromptResult
import cc.unitmesh.devti.counit.model.Tool
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

interface CoUnitApi {
@GET("/prompt/explain")
fun explainQuery(@Query("q") q: String): Call<PromptResult>

@POST("/prompt/functions/matching")
fun toolPrompter(@Query("q") q: String): Call<PromptResult>

@GET("/prompt/functions/list")
fun functions(): Call<List<Tool>>
}
18 changes: 18 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/counit/model/ExplainQuery.kt
@@ -0,0 +1,18 @@
package cc.unitmesh.devti.counit.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ExplainQuery(
val domain: String,
val query: String,
@SerialName("hypothetical_document")
val hypotheticalDocument: String
)

@Serializable
data class QAExample(
val question: String,
val answer: ExplainQuery
)
@@ -0,0 +1,5 @@
package cc.unitmesh.devti.counit.model

data class PromptResult(
val prompt: String
)
8 changes: 8 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/counit/model/Tool.kt
@@ -0,0 +1,8 @@
package cc.unitmesh.devti.counit.model

data class Tool(
val name: String,
val description: String,
val schema: String,
val examples: String
)

0 comments on commit e78f864

Please sign in to comment.