Skip to content

Commit

Permalink
feat: add max completion in files support
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 18, 2023
1 parent 9e347b5 commit 152648e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class SimpleCodePicker(private val config: PickerOption) : CodePicker {
config.codeQualityTypes,
config.builderConfig,
pureDataFileName = config.pureDataFileName(),
config.completionTypes
config.completionTypes,
config.maxCompletionInOneFile
))
val walkdirChannel = Channel<FileJob>()
val summary = mutableListOf<Instruction>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ data class WorkerContext(
val builderConfig: BuilderConfig,
val pureDataFileName: String,
val completionTypes: List<CompletionBuilderType>,
val maxCompletionInOneFile: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ class JavaWorker(private val context: WorkerContext) : LangWorker() {
val jobContext =
JobContext(job, context.qualityTypes, fileTree, context.builderConfig, context.completionTypes)

context.codeContextStrategies.map { type ->
val instructions = context.codeContextStrategies.map { type ->
val instructionBuilder = type.builder(jobContext)
val list = instructionBuilder.build()
list.map {
file.appendText(it.toString() + "\n")
}
instructionBuilder.unique(list as List<Nothing>)
}.flatten()

Instruction.takeStrategy(instructions, context.maxCompletionInOneFile)
}.flatten()

return@coroutineScope lists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ class TypescriptWorker(private val context: WorkerContext) : LangWorker() {
val lists = jobs.map { job ->
val jobContext = JobContext(job, context.qualityTypes, fileTree, context.builderConfig, context.completionTypes)

context.codeContextStrategies.map { type ->
val instructions = context.codeContextStrategies.map { type ->
val instructionBuilder = type.builder(jobContext)
val list = instructionBuilder.build()
list.map {
file.appendText(it.toString() + "\n")
}
instructionBuilder.unique(list as List<Nothing>)
}.flatten()

Instruction.takeStrategy(instructions, context.maxCompletionInOneFile)
}.flatten()

return@coroutineScope lists
Expand Down

0 comments on commit 152648e

Please sign in to comment.