-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement baml-cli serve (#908)
Implements the following: - new output type `rest/openapi` generates an openapi.yaml - generators now may specify an `on_generate` hooks that run after baml-cli codegen - `baml-cli init` now supports `--client-type rest/openapi` and `--openapi-client-type` - when `--openapi-client-type` is specified, if it's one of go, java, php, ruby, or rust, it will bootstrap a generator that runs `openapi-generator-cli` with recommended args for that generator - introduce `baml-cli dev` which generates the openapi.yaml spec, calls `openapi-generator-cli` on it, starts a BAML-over-HTTP server, and hot reloads all of this if any of the baml files change - `MyBamlFunction` is exposed as `POST /call/MyBamlFunction`, with args as a json object mapping arg name to arg value - streaming responses are exposed via `POST /stream/MyBamlFunction` as well, but are unstable - 4xx and 5xx errors are deliberately distinguished for the user - `/_debug/ping` and `/_debug/status` are present for debugging connectivity and auth state - `baml-cli serve` exposes the BAML-over-HTTP server as well, but without hot reload - provide docs explaining how to use this in `docker-compose` - supports `BAML_PASSWORD` for a basic authz check - if users pass in mismatched args or the wrong args for a given BAML function, or call the wrong BAML function, we return a distinct `UserFailure` error variant of `LLMResponse` To implement or discuss before initial release: - default log level is currently `info`, including `baml_events`, even though the python/ts FFI libraries default log level to `warn` - I think this is reasonable behavior (there's a lot of different things we use `log::info` for) - `rest/openapi` does not support generating code for fields with type of `null` and causes codegen to fail (unions and optionals are handled specially) - we could in theory generate a `{ nullable: true, type: PLACEHOLDER }` type for these, but as a user of this i think i would be very surprised and confused if i ran into this Fast follow work: - streaming is unstable right now - dynamic types, dynamic clients are unsupported - maybe: provide installer scripts for `baml-cli` without going through `npx`
- Loading branch information
Showing
98 changed files
with
16,216 additions
and
7,761 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
[tools] | ||
node = "latest" | ||
ruby = "3.1" | ||
pnpm = "latest" | ||
poetry = "latest" | ||
pnpm = "9.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" version="24.7.7"> | ||
<diagram name="Page-1" id="IBP3ZyO2FRTOo5MFRLAC"> | ||
<mxGraphModel dx="1434" dy="761" grid="1" gridSize="5" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0"> | ||
<root> | ||
<mxCell id="0" /> | ||
<mxCell id="1" parent="0" /> | ||
<mxCell id="iyppU8A8im01KiWM7F2Y-2" value="POST /call/MyBamlFunction" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Helveticaui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;fontColor=#7E55F8;fontStyle=0;fontSize=14;" parent="1" vertex="1"> | ||
<mxGeometry x="420" y="290" width="130" height="30" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="iyppU8A8im01KiWM7F2Y-5" value="<pre><br></pre>" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1"> | ||
<mxGeometry x="585" y="285" width="160" height="90" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="iyppU8A8im01KiWM7F2Y-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeColor=#7E55F8;strokeWidth=1.5;" parent="1" source="iyppU8A8im01KiWM7F2Y-6" target="iyppU8A8im01KiWM7F2Y-5" edge="1"> | ||
<mxGeometry relative="1" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="iyppU8A8im01KiWM7F2Y-6" value="<pre style="font-size: 14px;"><font style="font-size: 14px;" face="Helvetica">OpenAPI<br style="font-size: 14px;">client</font></pre>" style="rounded=1;whiteSpace=wrap;html=1;fontFamily=OpenSans, -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;fontSize=14;" parent="1" vertex="1"> | ||
<mxGeometry x="290" y="290" width="100" height="80" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="Q0mZcIDexRsLYvT9Odtg-4" value="MyApp" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontFamily=OpenSans, -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;" vertex="1" parent="1"> | ||
<mxGeometry x="290" y="260" width="100" height="30" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="Q0mZcIDexRsLYvT9Odtg-5" value="baml-cli serve" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Helveticaui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;fontSize=16;" vertex="1" parent="1"> | ||
<mxGeometry x="585" y="255" width="160" height="30" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="Q0mZcIDexRsLYvT9Odtg-6" value="MyBamlFunction.baml" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontFamily=Helveticaui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;fontColor=#000000;" vertex="1" parent="1"> | ||
<mxGeometry x="585" y="345" width="165" height="30" as="geometry" /> | ||
</mxCell> | ||
<mxCell id="Q0mZcIDexRsLYvT9Odtg-8" value="" style="shape=image;imageAspect=0;aspect=fixed;verticalLabelPosition=bottom;verticalAlign=top;image=data:image/svg+xml,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWZpbGUtY29kZS0yIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS13aWR0aD0iMSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyNCAyNCIgaGVpZ2h0PSIyNCIgd2lkdGg9IjI0Ij48cGF0aCBkPSJNNCAyMmgxNGEyIDIgMCAwIDAgMi0yVjdsLTUtNUg2YTIgMiAwIDAgMC0yIDJ2NCIvPjxwYXRoIGQ9Ik0xNCAydjRhMiAyIDAgMCAwIDIgMmg0Ii8+PHBhdGggZD0ibTUgMTItMyAzIDMgMyIvPjxwYXRoIGQ9Im05IDE4IDMtMy0zLTMiLz48L3N2Zz4=;" vertex="1" parent="1"> | ||
<mxGeometry x="643" y="296" width="49" height="49" as="geometry" /> | ||
</mxCell> | ||
</root> | ||
</mxGraphModel> | ||
</diagram> | ||
</mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,12 @@ it's a bug, feature request, or just general comment. | |
|
||
You can reach us using: | ||
|
||
- [Discord](https://discord.gg/BTNBeXGuaS) (fastest for a "how do i... ?") | ||
- [Discord] (fastest for a "how do i... ?") | ||
- [GitHub](https://github.com/BoundaryML/baml/issues) (for bugs and feature requests) | ||
- LinkedIn: [https://www.linkedin.com/company/boundaryml](https://www.linkedin.com/company/boundaryml) | ||
- Email: [[email protected]](mailto:[email protected]) | ||
- Twitter: [@boundaryml](https://twitter.com/boundaryml) | ||
|
||
We try our best to respond as quickly as possible, so don't hesitate to reach out! | ||
|
||
[Discord]: https://discord.gg/BTNBeXGuaS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.