Skip to content

Commit

Permalink
Get Python code closer to PEP 8 standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Irillit committed Feb 5, 2025
1 parent 542901d commit 4f48694
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions py/packages/genkit/src/genkit/core/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Action:

INPUT_KEY = 'inputSchema'
OUTPUT_KEY = 'outputSchema'
RETURN = 'return'

def __init__(
self,
Expand Down Expand Up @@ -67,7 +68,8 @@ def fn_to_call(*args, **kwargs):
self.metadata = metadata if metadata else {}

input_spec = inspect.getfullargspec(fn)
action_args = [k for k in input_spec.annotations if k != 'return']
action_args = [k for k in input_spec.annotations if k != self.RETURN]

if len(action_args) > 1:
raise Exception('can only have one arg')
if len(action_args) > 0:
Expand All @@ -79,8 +81,9 @@ def fn_to_call(*args, **kwargs):
self.input_schema = TypeAdapter(Any).json_schema()
self.metadata[self.INPUT_KEY] = self.input_schema

if 'return' in input_spec.annotations:
type_adapter = TypeAdapter(input_spec.annotations['return'])

if self.RETURN in input_spec.annotations:
type_adapter = TypeAdapter(input_spec.annotations[self.RETURN])
self.output_schema = type_adapter.json_schema()
self.metadata[self.OUTPUT_KEY] = self.output_schema
else:
Expand Down

0 comments on commit 4f48694

Please sign in to comment.