feat(vertex_httpx.py): return vertex grounding, citation, and safety results

This commit is contained in:
Krrish Dholakia
2024-08-09 08:54:55 -07:00
parent 51ccfa9e77
commit d471f7e840
2 changed files with 17 additions and 9 deletions
+15 -7
View File
@@ -421,12 +421,13 @@ class VertexGeminiConfig:
)
gtool_func_declarations.append(gtool_func_declaration)
except KeyError:
# assume it's a provider-specific param
verbose_logger.warning(
"Got KeyError parsing tool={}. Assuming it's a provider-specific param. Use `litellm.set_verbose` or `litellm --detailed_debug` to see raw request."
)
if tool.get("googleSearchRetrieval", None) is not None:
googleSearchRetrieval = tool["googleSearchRetrieval"]
else:
# assume it's a provider-specific param
verbose_logger.warning(
"Got KeyError parsing tool={}. Assuming it's a provider-specific param. Use `litellm.set_verbose` or `litellm --detailed_debug` to see raw request."
)
_tools = Tools(
function_declarations=gtool_func_declarations,
)
@@ -766,16 +767,23 @@ class VertexLLM(BaseLLM):
setattr(model_response, "usage", usage)
## ADD GROUNDING METADATA ##
model_response._hidden_params["vertex_ai_grounding_metadata"] = (
setattr(model_response, "vertex_ai_grounding_metadata", grounding_metadata)
model_response._hidden_params[
"vertex_ai_grounding_metadata"
] = ( # older approach - maintaining to prevent regressions
grounding_metadata
)
## ADD SAFETY RATINGS ##
model_response._hidden_params["vertex_ai_safety_results"] = safety_ratings
setattr(model_response, "vertex_ai_safety_results", safety_ratings)
model_response._hidden_params["vertex_ai_safety_results"] = (
safety_ratings # older approach - maintaining to prevent regressions
)
## ADD CITATION METADATA ##
setattr(model_response, "vertex_ai_citation_metadata", citation_metadata)
model_response._hidden_params["vertex_ai_citation_metadata"] = (
citation_metadata
citation_metadata # older approach - maintaining to prevent regressions
)
except Exception as e:
+2 -2
View File
@@ -1,7 +1,7 @@
model_list:
- model_name: "claude-3-5-sonnet-20240620"
- model_name: "*"
litellm_params:
model: "claude-3-5-sonnet-20240620"
model: "*"
litellm_settings:
max_internal_user_budget: 0.001