Skip to content

Commit

Permalink
file path support
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoukk committed Jun 27, 2023
1 parent 35a2ee5 commit 0227988
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions loader_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tiktoken_loader

import (
"testing"
)

func TestOffline(t *testing.T) {
loader := NewOfflineLoader()
bpeRanks, err := loader.LoadTiktokenBpe("https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken")
if err != nil {
t.Error(err)
}
if len(bpeRanks) == 0 {
t.Error("bpeRanks is empty")
}
}
4 changes: 3 additions & 1 deletion offline_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tiktoken_loader

import (
"encoding/base64"
"path"
"strconv"
"strings"

Expand All @@ -11,7 +12,8 @@ import (
type OfflineLoader struct{}

func (l *OfflineLoader) LoadTiktokenBpe(tiktokenBpeFile string) (map[string]int, error) {
contents, err := assets.Assets.ReadFile(tiktokenBpeFile)
baseFileName := path.Base(tiktokenBpeFile)
contents, err := assets.Assets.ReadFile(baseFileName)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 0227988

Please sign in to comment.