This repository has been archived on 2024-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
2023-09-24 13:02:30 -06:00
|
|
|
from llm_server.llm import oobabooga, vllm
|
|
|
|
from llm_server.routes.cache import redis
|
|
|
|
|
|
|
|
|
|
|
|
def get_token_count(prompt):
|
|
|
|
backend_mode = redis.get('backend_mode', str)
|
|
|
|
if backend_mode == 'vllm':
|
|
|
|
return vllm.tokenize(prompt)
|
|
|
|
elif backend_mode == 'ooba':
|
|
|
|
return oobabooga.tokenize(prompt)
|
|
|
|
else:
|
|
|
|
raise Exception(backend_mode)
|