Skip to content

[bug] argument name is shadowing types module. #2003

Closed
@poonai

Description

@poonai

Product

BAML

Describe the bug

Baml client doesn't work if I define function with argument name types. It's because types module is shadowed by the argument name

Reproduction Steps

baml

function QueryPlanner(types: string[], relations: string[], question: string) -> PlannerResult {
  client "openai/gpt-4o-mini"
  prompt #"
    Blah Blah Blah
    Entity types: {{ types }}
    relations: {{ relations }}
    Question: {{ question }}
    {{ctx.output_format }}
  "#
}

generated client code for above baml

    def QueryPlanner(
        self,
        types: List[str],relations: List[str],question: str,
        baml_options: BamlCallOptions = {},
    ) -> baml_py.BamlSyncStream[partial_types.PlannerResult, types.PlannerResult]:
      options: BamlCallOptions = {**self.__baml_options, **(baml_options or {})}
      __tb__ = options.get("tb", None)
      if __tb__ is not None:
        tb = __tb__._tb # type: ignore (we know how to use this private attribute)
      else:
        tb = None
      __cr__ = options.get("client_registry", None)
      collector = options.get("collector", None)
      collectors = collector if isinstance(collector, list) else [collector] if collector is not None else []

      raw = self.__runtime.stream_function_sync(
        "QueryPlanner",
        {
          "types": types,
          "relations": relations,
          "question": question,
        },
        None,
        self.__ctx_manager.get(),
        tb,
        __cr__,
        collectors,
      )

      return baml_py.BamlSyncStream[partial_types.PlannerResult, types.PlannerResult](
        raw,
        lambda x: cast(partial_types.PlannerResult, x.cast_to(types, types, partial_types, True)),
        lambda x: cast(types.PlannerResult, x.cast_to(types, types, partial_types, False)),
        self.__ctx_manager.get(),
      )
    

casting lambda x: cast(types.PlannerResult, x.cast_to(types, types, partial_types, False)), is shadowed by argument name types

BAML Version

No response

Language/Framework

Python

LLM Provider

None

LLM Model

No response

Operating System

None

Browser

None

Code Editor

None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions