in google/generativeai/types/retriever_types.py [0:0]
def _to_proto(self):
kwargs = {}
conditions = []
for c in self.conditions:
if isinstance(c.value, str):
kwargs["string_value"] = c.value
elif isinstance(c.value, (int, float)):
kwargs["numeric_value"] = float(c.value)
else:
raise ValueError(
f"Invalid value type: The value for the condition must be either a string or an integer/float. Received: '{c.value}' of type {type(c.value).__name__}."
)
kwargs["operation"] = c.operation
condition = protos.Condition(**kwargs)
conditions.append(condition)
return protos.MetadataFilter(key=self.key, conditions=conditions)