Skip to content

Commit 8a8fcc5

Browse files
authored
Merge pull request #19 from ZeroZ-lab/fix-log
chore(logging): unify the logging method
2 parents ed6cd8a + a33dbe4 commit 8a8fcc5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

candle-binding/semantic-router.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package candle_binding
55

66
import (
77
"fmt"
8+
"log"
89
"runtime"
910
"sync"
1011
"unsafe"
@@ -158,7 +159,7 @@ func InitModel(modelID string, useCPU bool) error {
158159
modelID = "sentence-transformers/all-MiniLM-L6-v2"
159160
}
160161

161-
fmt.Println("Initializing BERT similarity model:", modelID)
162+
log.Printf("Initializing BERT similarity model: %s", modelID)
162163

163164
// Initialize BERT directly using CGO
164165
cModelID := C.CString(modelID)
@@ -284,7 +285,7 @@ func GetEmbeddingDefault(text string) ([]float32, error) {
284285
// CalculateSimilarity calculates the similarity between two texts with maxLength parameter
285286
func CalculateSimilarity(text1, text2 string, maxLength int) float32 {
286287
if !modelInitialized {
287-
fmt.Println("BERT model not initialized")
288+
log.Printf("BERT model not initialized")
288289
return -1.0
289290
}
290291

@@ -306,7 +307,7 @@ func CalculateSimilarityDefault(text1, text2 string) float32 {
306307
// FindMostSimilar finds the most similar text from a list of candidates with maxLength parameter
307308
func FindMostSimilar(query string, candidates []string, maxLength int) SimResult {
308309
if !modelInitialized {
309-
fmt.Println("BERT model not initialized")
310+
log.Printf("BERT model not initialized")
310311
return SimResult{Index: -1, Score: -1.0}
311312
}
312313

@@ -364,7 +365,7 @@ func InitClassifier(modelPath string, numClasses int, useCPU bool) error {
364365
return
365366
}
366367

367-
fmt.Println("Initializing classifier model:", modelPath)
368+
log.Printf("Initializing classifier model: %s", modelPath)
368369

369370
// Initialize classifier directly using CGO
370371
cModelID := C.CString(modelPath)
@@ -392,7 +393,7 @@ func InitPIIClassifier(modelPath string, numClasses int, useCPU bool) error {
392393
return
393394
}
394395

395-
fmt.Println("Initializing PII classifier model:", modelPath)
396+
log.Printf("Initializing PII classifier model: %s", modelPath)
396397

397398
// Initialize PII classifier directly using CGO
398399
cModelID := C.CString(modelPath)
@@ -420,7 +421,7 @@ func InitJailbreakClassifier(modelPath string, numClasses int, useCPU bool) erro
420421
return
421422
}
422423

423-
fmt.Println("Initializing jailbreak classifier model:", modelPath)
424+
log.Printf("Initializing jailbreak classifier model: %s", modelPath)
424425

425426
// Initialize jailbreak classifier directly using CGO
426427
cModelID := C.CString(modelPath)
@@ -495,7 +496,7 @@ func InitModernBertClassifier(modelPath string, useCPU bool) error {
495496
modelPath = "answerdotai/ModernBERT-base"
496497
}
497498

498-
fmt.Println("Initializing ModernBERT classifier model:", modelPath)
499+
log.Printf("Initializing ModernBERT classifier model: %s", modelPath)
499500

500501
// Initialize ModernBERT classifier directly using CGO
501502
cModelID := C.CString(modelPath)
@@ -519,7 +520,7 @@ func InitModernBertPIIClassifier(modelPath string, useCPU bool) error {
519520
modelPath = "./pii_classifier_modernbert_model"
520521
}
521522

522-
fmt.Println("Initializing ModernBERT PII classifier model:", modelPath)
523+
log.Printf("Initializing ModernBERT PII classifier model: %s", modelPath)
523524

524525
// Initialize ModernBERT PII classifier directly using CGO
525526
cModelID := C.CString(modelPath)
@@ -543,7 +544,7 @@ func InitModernBertJailbreakClassifier(modelPath string, useCPU bool) error {
543544
modelPath = "./jailbreak_classifier_modernbert_model"
544545
}
545546

546-
fmt.Println("Initializing ModernBERT jailbreak classifier model:", modelPath)
547+
log.Printf("Initializing ModernBERT jailbreak classifier model: %s", modelPath)
547548

548549
// Initialize ModernBERT jailbreak classifier directly using CGO
549550
cModelID := C.CString(modelPath)
@@ -567,7 +568,7 @@ func InitModernBertPIITokenClassifier(modelPath string, useCPU bool) error {
567568
modelPath = "./pii_classifier_modernbert_ai4privacy_token_model"
568569
}
569570

570-
fmt.Println("Initializing ModernBERT PII token classifier model:", modelPath)
571+
log.Printf("Initializing ModernBERT PII token classifier model: %s", modelPath)
571572

572573
// Initialize ModernBERT PII token classifier directly using CGO
573574
cModelID := C.CString(modelPath)

0 commit comments

Comments
 (0)