Skip to content

[feat] Add method to remove dynamic property #2050

@shoang22

Description

@shoang22

Product

BAML

Problem Statement / Use Case

I have a baml class that only contains dynamic fields:

class ToolCall {
  @@dynamic
}

Im testing the following function:

def test_clear_baml(tb: TypeBuilder, cr: ClientRegistry):
    # actual code
    tb.ToolCall.add_property("tool", tb.ImageRequest.type())
    tool = ToolStep(tool=ImageRequest(step_type="ImageRequest", reasoning="The user asked for an image", output_format="png", prompt="cat with likeness of the number one video game of 2024 with the mood of google's stock price", acknowledgement="generating an image"))
    memory = [
        Message(role="assistant", content="Observation from AskWebRequest: Google's stock price fell in June"),
        Message(role="assistant", content="Observation from AskWebRequest: The number one video game of 2024 is Cyberpunk")
    ]
    resp = b.RunWorker(memory=memory, tool=tool, baml_options={"client_registry": cr, "tb": tb})
    assert "cyberpunk" in resp.tool["prompt"].lower()

  # theoretical code
  tb.remove_property("tool")

As indicated in the code, I'd like to be able to clear the properties of ToolCall, so that when I'm trying to map the parameters of another Tool, ToolCall only has that one tool to choose from, reducing the possibility of generating the parameters of a another tool.

Proposed Solution

Method to remove property:

 tb.remove_property("tool")

Alternative Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions