diff --git a/refact_known_models/passthrough.py b/refact_known_models/passthrough.py index 10f312a5..0f12849e 100644 --- a/refact_known_models/passthrough.py +++ b/refact_known_models/passthrough.py @@ -122,4 +122,92 @@ "pp1000t_generated": 600, # $0.60 / 1M tokens "filter_caps": ["chat", "tools"], }, + "groq-llama-3.1-8b": { + "backend": "litellm", + "provider": "groq", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "groq/llama-3.1-8b-instant", + "T": 128_000, + "T_out": 8000, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + }, + "groq-llama-3.1-70b": { + "backend": "litellm", + "provider": "groq", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "groq/llama-3.1-70b-versatile", + "T": 128_000, + "T_out": 8000, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + }, + "groq-llama-3.2-1b": { + "backend": "litellm", + "provider": "groq", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "groq/llama-3.2-1b-preview", + "T": 128_000, + "T_out": 8000, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + }, + "groq-llama-3.2-3b": { + "backend": "litellm", + "provider": "groq", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "groq/llama-3.2-3b-preview", + "T": 128_000, + "T_out": 8000, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + }, + "groq-llama-3.2-11b-vision": { + "backend": "litellm", + "provider": "groq", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "groq/llama-3.2-11b-vision-preview", + "T": 128_000, + "T_out": 8000, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + }, + "groq-llama-3.2-90b-vision": { + "backend": "litellm", + "provider": "groq", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "groq/llama-3.2-90b-vision-preview", + "T": 128_000, + "T_out": 8000, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + }, + "cerebras-llama3.1-8b": { + "backend": "litellm", + "provider": "cerebras", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "cerebras/llama3.1-8b", + "T": 8192, + "T_out": 4096, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + }, + "cerebras-llama3.1-70b": { + "backend": "litellm", + "provider": "cerebras", + "tokenizer_path": "Xenova/Meta-Llama-3.1-Tokenizer", + "resolve_as": "cerebras/llama3.1-70b", + "T": 8192, + "T_out": 4096, + "pp1000t_prompt": 150, + "pp1000t_generated": 600, # TODO: don't know the price + "filter_caps": ["chat"], + } } diff --git a/refact_utils/finetune/utils.py b/refact_utils/finetune/utils.py index edec5f26..9dabce0b 100644 --- a/refact_utils/finetune/utils.py +++ b/refact_utils/finetune/utils.py @@ -107,6 +107,12 @@ def _add_results_for_passthrough_provider(provider: str) -> None: if data.get('anthropic_api_enable'): _add_results_for_passthrough_provider('anthropic') + if data.get('cerebras_api_enable'): + _add_results_for_passthrough_provider('cerebras') + + if data.get('groq_api_enable'): + _add_results_for_passthrough_provider('groq') + for k, v in data.get("model_assign", {}).items(): if model_dict := [d for d in data['models'] if d['name'] == k]: model_dict = model_dict[0] diff --git a/refact_webgui/webgui/selfhost_fastapi_completions.py b/refact_webgui/webgui/selfhost_fastapi_completions.py index b3b83508..036e8213 100644 --- a/refact_webgui/webgui/selfhost_fastapi_completions.py +++ b/refact_webgui/webgui/selfhost_fastapi_completions.py @@ -230,6 +230,8 @@ def _integrations_env_setup(env_var_name: str, api_key_name: str, api_enable_nam _integrations_env_setup("OPENAI_API_KEY", "openai_api_key", "openai_api_enable") _integrations_env_setup("ANTHROPIC_API_KEY", "anthropic_api_key", "anthropic_api_enable") + _integrations_env_setup("GROQ_API_KEY", "groq_api_key", "groq_api_enable") + _integrations_env_setup("CEREBRAS_API_KEY", "cerebras_api_key", "cerebras_api_enable") def _models_available_dict_rewrite(self, models_available: List[str]) -> Dict[str, Any]: rewrite_dict = {} @@ -608,7 +610,10 @@ async def chat_completion_streamer(): log(err_msg) yield prefix + json.dumps({"error": err_msg}) + postfix - if model_dict.get('backend') == 'litellm' and (model_name := model_dict.get('resolve_as', post.model)) in litellm.model_list: + if model_dict.get('backend') == 'litellm': + model_name = model_dict.get('resolve_as', post.model) + if model_name not in litellm.model_list: + log(f"warning: requested model {model_name} is not in the litellm.model_list (this might not be the issue for some providers)") log(f"chat/completions: model resolve {post.model} -> {model_name}") prompt_tokens_n = litellm.token_counter(model_name, messages=messages) if post.tools: diff --git a/refact_webgui/webgui/selfhost_model_assigner.py b/refact_webgui/webgui/selfhost_model_assigner.py index 856cecea..7709854e 100644 --- a/refact_webgui/webgui/selfhost_model_assigner.py +++ b/refact_webgui/webgui/selfhost_model_assigner.py @@ -184,6 +184,8 @@ def first_run(self): }, "openai_api_enable": False, "anthropic_api_enable": False, + "groq_api_enable": False, + "cerebras_api_enable": False, } self.models_to_watchdog_configs(default_config) @@ -255,6 +257,8 @@ def models_info(self): def model_assignment(self): if os.path.exists(env.CONFIG_INFERENCE): j = json.load(open(env.CONFIG_INFERENCE, "r")) + j["groq_api_enable"] = j.get("groq_api_enable", False) + j["cerebras_api_enable"] = j.get("cerebras_api_enable", False) else: j = {"model_assign": {}} diff --git a/refact_webgui/webgui/selfhost_queue.py b/refact_webgui/webgui/selfhost_queue.py index fb365c15..02ba82d4 100644 --- a/refact_webgui/webgui/selfhost_queue.py +++ b/refact_webgui/webgui/selfhost_queue.py @@ -64,6 +64,10 @@ def _add_models_for_passthrough_provider(provider): _add_models_for_passthrough_provider('openai') if j.get("anthropic_api_enable"): _add_models_for_passthrough_provider('anthropic') + if j.get("groq_api_enable"): + _add_models_for_passthrough_provider('groq') + if j.get("cerebras_api_enable"): + _add_models_for_passthrough_provider('cerebras') return self._models_available diff --git a/refact_webgui/webgui/static/tab-model-hosting.html b/refact_webgui/webgui/static/tab-model-hosting.html index 48714516..6ecc86d7 100644 --- a/refact_webgui/webgui/static/tab-model-hosting.html +++ b/refact_webgui/webgui/static/tab-model-hosting.html @@ -38,6 +38,14 @@