Skip to content

Commit

Permalink
chore: update for threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 27, 2023
1 parent f8f8d63 commit 27caa2f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class ThresholdChecker(private val context: WorkerContext) {
val length = encoded.size
if (length > context.qualityThreshold.maxTokenLength) {
logger.info("skip file ${summary.location} for over ${context.qualityThreshold.maxTokenLength} tokens")
println("| filename: ${summary.filename} | tokens: $length | complexity: ${summary.complexity} | code: ${summary.lines} | size: ${summary.bytes} | location: ${summary.location} |")
return false
}

Expand All @@ -77,6 +76,12 @@ class ThresholdChecker(private val context: WorkerContext) {
* @return true if the instruction meets the threshold criteria, false otherwise
*/
fun isMetThreshold(ins: Instruction): Boolean {
// skip empty instruction
if (ins.input.isEmpty() || ins.output.isEmpty()) {
return false
}

// limit by token length
val totalToken = enc.encode(ins.instruction + ins.input + ins.output).size
return totalToken <= context.qualityThreshold.maxTokenLength
}
Expand Down

0 comments on commit 27caa2f

Please sign in to comment.