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
|
2023-09-28 18:40:24 -06:00
|
|
|
from llm_server.custom_redis import redis
|
2023-09-24 13:02:30 -06:00
|
|
|
|
|
|
|
|
2023-09-30 19:41:50 -06:00
|
|
|
def get_token_count(prompt: str, backend_url: str):
|
2023-09-29 00:09:44 -06:00
|
|
|
backend_mode = redis.get('backend_mode', dtype=str)
|
2023-09-24 13:02:30 -06:00
|
|
|
if backend_mode == 'vllm':
|
2023-09-30 19:41:50 -06:00
|
|
|
return vllm.tokenize(prompt, backend_url)
|
2023-09-24 13:02:30 -06:00
|
|
|
elif backend_mode == 'ooba':
|
|
|
|
return oobabooga.tokenize(prompt)
|
|
|
|
else:
|
|
|
|
raise Exception(backend_mode)
|