From d946a83d85ac7d9bd422f57a36c6db0cb3684dea Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Tue, 11 Mar 2025 10:52:41 -0700 Subject: [PATCH] passthrough provider --- .../inference/passthrough/passthrough.py | 27 ++++++++++++++++++- llama_stack/templates/passthrough/run.yaml | 4 +-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/llama_stack/providers/remote/inference/passthrough/passthrough.py b/llama_stack/providers/remote/inference/passthrough/passthrough.py index aa8a87bf7..f88fb4558 100644 --- a/llama_stack/providers/remote/inference/passthrough/passthrough.py +++ b/llama_stack/providers/remote/inference/passthrough/passthrough.py @@ -137,8 +137,33 @@ class PassthroughInferenceAdapter(Inference): params = {key: value for key, value in params.items() if value is not None} + json_params = {} + from llama_stack.distribution.library_client import ( + convert_pydantic_to_json_value, + ) + + # cast everything to json dict + for key, value in params.items(): + json_input = convert_pydantic_to_json_value(value) + if isinstance(json_input, dict): + json_input = {k: v for k, v in json_input.items() if v is not None} + elif isinstance(json_input, list): + json_input = [x for x in json_input if x is not None] + new_input = [] + for x in json_input: + if isinstance(x, dict): + x = {k: v for k, v in x.items() if v is not None} + new_input.append(x) + json_input = new_input + + if key != "tools": + json_params[key] = json_input + + from rich.pretty import pprint + + pprint(json_params) # only pass through the not None params - return client.inference.chat_completion(**params) + return client.inference.chat_completion(**json_params) async def embeddings( self, diff --git a/llama_stack/templates/passthrough/run.yaml b/llama_stack/templates/passthrough/run.yaml index 2548faa5d..01a38bcab 100644 --- a/llama_stack/templates/passthrough/run.yaml +++ b/llama_stack/templates/passthrough/run.yaml @@ -103,8 +103,8 @@ models: provider_id: passthrough provider_model_id: llama3.2-11b-vision-instruct model_type: llm -shields: -- shield_id: meta-llama/Llama-Guard-3-8B +# shields: +# - shield_id: meta-llama/Llama-Guard-3-8B vector_dbs: [] datasets: [] scoring_fns: []