char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
d2fcd91cf
char/aliceai-t5-moe
1import pytest 2from utils import * 3 4server = ServerPreset .tinyllama2 () 5 6 7@ pytest . fixture ( autouse = True ) 8def create_server (): 9global server 10server = ServerPreset .tinyllama2 () 11 12 13def test_tokenize_detokenize (): 14global server 15server .start () 16# tokenize 17content = "What is the capital of France ?" 18res_tok = server .make_request ("POST" ,"/tokenize" ,data = { 19"content" :content 20 }) 21assert res_tok .status_code == 200 22assert len (res_tok .body ["tokens" ])> 5 23# detokenize 24res_detok = server .make_request ("POST" ,"/detokenize" ,data = { 25"tokens" :res_tok .body ["tokens" ], 26 }) 27assert res_detok .status_code == 200 28assert res_detok .body ["content" ].strip ()== content 29 30 31def test_tokenize_with_bos (): 32global server 33server .start () 34# tokenize 35content = "What is the capital of France ?" 36bosId = 1 37res_tok = server .make_request ("POST" ,"/tokenize" ,data = { 38"content" :content , 39"add_special" :True , 40 }) 41assert res_tok .status_code == 200 42assert res_tok .body ["tokens" ][0 ]== bosId 43 44 45def test_tokenize_with_pieces (): 46global server 47server .start () 48# tokenize 49content = "This is a test string with unicode 媽 and emoji 🤗" 50res_tok = server .make_request ("POST" ,"/tokenize" ,data = { 51"content" :content , 52"with_pieces" :True , 53 }) 54assert res_tok .status_code == 200 55for token in res_tok .body ["tokens" ]: 56assert "id" in token 57assert token ["id" ]> 0 58assert "piece" in token 59assert len (token ["piece" ])> 0