char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
29debb3a6
char/aliceai-t5-moe
1import pytest 2from utils import * 3 4server :ServerProcess 5 6 7@ pytest . fixture ( autouse = True ) 8def create_server (): 9global server 10server = ServerPreset .tinyllama2 () 11server .gcp_compat = True 12 13 14def test_gcp_predict_camel_case (): 15global server 16server .start () 17res = server .make_request ("POST" ,"/predict" ,data = { 18"instances" : [ 19 { 20"@requestFormat" :"chatCompletions" , 21"max_tokens" :8 , 22"messages" : [ 23 {"role" :"user" ,"content" :"What is the meaning of life?" }, 24 ], 25 } 26 ], 27 }) 28assert res .status_code == 200 29assert "predictions" in res .body 30assert len (res .body ["predictions" ])== 1 31prediction = res .body ["predictions" ][0 ] 32assert "choices" in prediction 33assert len (prediction ["choices" ])== 1 34assert prediction ["choices" ][0 ]["message" ]["role" ]== "assistant" 35assert len (prediction ["choices" ][0 ]["message" ]["content" ])> 0 36 37 38def test_gcp_predict_multiple_instances (): 39global server 40server .n_slots = 2 41server .start () 42res = server .make_request ("POST" ,"/predict" ,data = { 43"instances" : [ 44 { 45"@requestFormat" :"chatCompletions" , 46"max_tokens" :8 , 47"messages" : [{"role" :"user" ,"content" :"Say hello" }], 48 }, 49 { 50"@requestFormat" :"chatCompletions" , 51"max_tokens" :8 , 52"messages" : [{"role" :"user" ,"content" :"Say world" }], 53 }, 54 ], 55 }) 56assert res .status_code == 200 57assert len (res .body ["predictions" ])== 2 58for prediction in res .body ["predictions" ]: 59assert "choices" in prediction 60assert len (prediction ["choices" ][0 ]["message" ]["content" ])> 0