File tree 1 file changed +24
-1
lines changed
1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -93,4 +93,27 @@ def test_llama_pickle():
93
93
94
94
text = b"Hello World"
95
95
96
- assert llama .detokenize (llama .tokenize (text )) == text
96
+ assert llama .detokenize (llama .tokenize (text )) == text
97
+
98
+ def test_llama_utf8 (monkeypatch ):
99
+ llama = llama_cpp .Llama (model_path = MODEL , vocab_only = True )
100
+
101
+ ## Set up mock function
102
+ def mock_eval (* args , ** kwargs ):
103
+ return 0
104
+
105
+ monkeypatch .setattr ("llama_cpp.llama_cpp.llama_eval" , mock_eval )
106
+
107
+ output_text = "😀"
108
+ output_tokens = [243 , 162 , 155 , 131 ]
109
+
110
+ def mock_tokenize (* args , ** kwargs ):
111
+ return output_tokens [:- 1 ]
112
+
113
+ llama .tokenize = mock_tokenize
114
+
115
+ ## Test basic completion until eos
116
+ n = 0 # reset
117
+ completion = llama .create_completion ("ignored" , max_tokens = 1 )
118
+ assert completion ["choices" ][0 ]["text" ] == output_text
119
+
You can’t perform that action at this time.
0 commit comments