Skip to content

[feat] Add Output_Folder_Name in generate client #3081

@debasisdwivedy

Description

@debasisdwivedy

Product

BAML

Problem Statement / Use Case

Hi,

Currently the generators.baml file does not provide any option to name the folder of the client. It only supports folder name baml_client .
Even though we can have different output directory for multiple clients, it would be convenient if we can name have a field called output_dir_name where we can name it whatever we want instead of sticking to baml_client. The default of output_dir_name can be set to baml_client but the user can change it if the desire to do so

Proposed Solution

generator.baml

// This helps use auto generate libraries you can use in the language of
// your choice. You can have multiple generators if you use multiple languages.
// Just ensure that the output_dir is different for each generator.
generator target {
    // Valid values: "python/pydantic", "typescript", "go", "rust", "ruby/sorbet", "rest/openapi"
    output_type "python/pydantic"

    // Where the generated code will be saved (relative to baml_src/)
    output_dir "../"
    output_dir_name "pydantic_client"

    // The version of the BAML package you have installed (e.g. same version as your baml-py or @boundaryml/baml).
    // The BAML VSCode extension version should also match this version.
    version "0.218.1"

    // Valid values: "sync", "async"
    // This controls what `b.FunctionName()` will be (sync or async).
    default_client_mode sync
}

This should create the generated clients/types in pydantic_client folder instead of `baml_client.

Alternative Solutions

Workaround is creating separate folders for each generated types as below:

  • "python/baml_client"
  • "typescript/baml_client"
  • "ruby/baml_client"

Instead we can make it as below:

  • "pydantic_client"
  • "ts_client"
  • "ruby_client"

Additional Context

The easiest way that i can think of is to keep output_dir/output_dir_name/ in sync with output_dir/baml_client/ whenever new files are generated.

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