Skip to content

Commit

Permalink
refactor: update for template code
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Oct 19, 2023
1 parent c8250b2 commit 13064b6
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,29 @@ import com.charleskorn.kaml.PolymorphismStyle
import com.charleskorn.kaml.Yaml
import com.charleskorn.kaml.YamlConfiguration
import kotlinx.serialization.serializer
import org.slf4j.Logger
import java.io.File
import kotlin.io.path.Path
import kotlin.io.path.exists
import kotlin.io.path.readText

/**
* The `CodeReviewCommand` class is a command-line interface for performing code reviews using AIGC (Artificial Intelligence for Code Review).
* It extends the `CliktCommand` class from the `clikt` library and provides options and functionality for reviewing code in a Git repository.
*
* @property repo The path to the Git repository. It can be a local file path or a Git URL. Default value is "." (current directory).
* @property branch The name of the Git branch to review. Default value is "master".
* @property sinceCommit The revision of the first commit to include in the review. Default value is an empty string, which means the earliest commit in the repository.
* @property untilCommit The revision of the last commit to include in the review. Default value is an empty string, which means the latest commit in the repository.
* @property commitMessageOptionFile The path to the commit message option file. Default value is an empty string, which means no commit message options are used.
* @property verbose A flag indicating whether to enable verbose output. Default value is false.
* @property configFile The path to the configuration file. Default value is "devops-genius.yml".
* @property project The `GeniusProject` instance representing the project being reviewed. It is lazily initialized based on the configuration file or the repository path.
*
* @constructor Creates a new instance of `CodeReviewCommand`.
*
* @see CliktCommand
* @see GeniusProject
*/
class CodeReviewCommand : CliktCommand(help = "Code Review with AIGC") {
private val repo by option(help = "Git repository path. Use local file path, or Git Url").default(".")
private val branch by option(help = "Git branch name").default("master")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cc.unitmesh.genius.prompt

import cc.unitmesh.cf.core.llms.LlmMsg
import cc.unitmesh.genius.project.GeniusProject
import cc.unitmesh.prompt.executor.TemplateRoleSplitter
import cc.unitmesh.template.TemplateRoleSplitter
import cc.unitmesh.prompt.template.VelocityCompiler

abstract class PromptFactory(promptsBasePath: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unitmesh.prompt.template
package cc.unitmesh.template

interface PromptCompiler {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unitmesh.prompt.template
package cc.unitmesh.template

enum class TemplateEngineType {
VELOCITY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package cc.unitmesh.prompt.executor

import cc.unitmesh.cf.core.llms.LlmMsg
package cc.unitmesh.template

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import cc.unitmesh.prompt.model.PromptScript
import cc.unitmesh.prompt.model.JobStrategy
import cc.unitmesh.prompt.model.Variable
import cc.unitmesh.prompt.template.TemplateCompilerFactory
import cc.unitmesh.prompt.template.TemplateEngineType
import cc.unitmesh.template.TemplateEngineType
import cc.unitmesh.template.TemplateRoleSplitter
import com.charleskorn.kaml.PolymorphismStyle
import com.charleskorn.kaml.Yaml
import com.charleskorn.kaml.YamlConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cc.unitmesh.prompt.template

import cc.unitmesh.prompt.model.TemplateDatasource
import cc.unitmesh.template.PromptCompiler
import cc.unitmesh.template.TemplateEngineType
import java.nio.file.Path


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.unitmesh.prompt.template

import cc.unitmesh.template.PromptCompiler
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import org.apache.velocity.VelocityContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.unitmesh.prompt.executor;

import cc.unitmesh.template.TemplateRoleSplitter
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
Expand Down

0 comments on commit 13064b6

Please sign in to comment.