Skip to content

Commit def59e9

Browse files
author
Abraham Lazaro Martinez
committed
refactor code
1 parent 40e8783 commit def59e9

File tree

1 file changed

+16
-10
lines changed
  • py/plugins/google-genai/src/genkit/plugins/google_genai/models

1 file changed

+16
-10
lines changed

py/plugins/google-genai/src/genkit/plugins/google_genai/models/gemini.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,17 +544,23 @@ def _convert_schema_property(
544544
if defs is None:
545545
defs = input_schema.get('$defs') if '$defs' in input_schema else {}
546546

547+
if '$ref' in input_schema:
548+
ref_path = input_schema['$ref']
549+
ref_tokens = ref_path.split('/')
550+
ref_name = ref_tokens[-1]
551+
552+
if ref_name not in defs:
553+
raise ValueError(f'Failed to resolve schema for {ref_tokens[2]}')
554+
555+
schema = self._convert_schema_property(defs[ref_tokens[2]], defs)
556+
557+
if input_schema.get('description'):
558+
schema.description = input_schema['description']
559+
560+
return schema
561+
547562
if 'type' not in input_schema:
548-
if '$ref' in input_schema:
549-
ref_tokens = input_schema['$ref'].split('/')
550-
if ref_tokens[2] not in defs:
551-
raise ValueError(f'Failed to resolve schema for {ref_tokens[2]}')
552-
schema = self._convert_schema_property(defs[ref_tokens[2]], defs)
553-
if input_schema.get('description'):
554-
schema.description = input_schema['description']
555-
return schema
556-
else:
557-
return None
563+
return None
558564

559565
schema = genai_types.Schema()
560566
if input_schema.get('description'):

0 commit comments

Comments
 (0)