From 7d3ad0299027e670499b2ab230d328f3c807c1f5 Mon Sep 17 00:00:00 2001 From: Wes Brown Date: Tue, 18 Jul 2023 12:03:52 -0400 Subject: [PATCH] Change JS to initialize on load. --- js/js.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/js.go b/js/js.go index 209b4a2..990c238 100644 --- a/js/js.go +++ b/js/js.go @@ -8,7 +8,7 @@ import ( "log" ) -var encoder = gpt_bpe.GPT2Encoder +var encoder gpt_bpe.GPTEncoder func Tokenize(text string) gpt_bpe.Tokens { return *encoder.Encode(&text) @@ -20,6 +20,7 @@ func Decode(arr []byte) string { } func init() { + encoder = gpt_bpe.NewGPT2Encoder() js.Module.Get("exports").Set("decode", Decode) js.Module.Get("exports").Set("tokenize", Tokenize) log.Printf("GPT-2 BPE Decoder Loaded")