Skip to content

Commit 562fe70

Browse files
committed
Update README
1 parent 5a1690a commit 562fe70

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ What this library does:
77

88
- Call functions in BAML files.
99
- Make use of the BAML LLM client to call LLM functions.
10-
- Cast the return values from BAML function calls to the correct structs in Elixir.
1110

1211
What this library does not do:
1312

@@ -64,19 +63,27 @@ Now call the BAML function:
6463

6564
```elixir
6665
# from: The path to the baml_src directory.
67-
# struct_name: The module name which will be used for the returned struct.
68-
%BamlElixir.Client{from: "priv/baml_src", struct_name: MyApp.Resume}
66+
%BamlElixir.Client{from: "priv/baml_src"}
6967
|> BamlElixir.Client.call("ExtractResume", %{resume: "John Doe is the CTO of Acme Inc."})
7068
```
7169

70+
### Stream results
71+
72+
```elixir
73+
%BamlElixir.Client{from: "priv/baml_src"}
74+
|> BamlElixir.Client.stream!("ExtractResume", %{resume: "John Doe is the CTO of Acme Inc."})
75+
|> Enum.each(&IO.inspect/1)
76+
```
77+
78+
### Create your own client module
79+
7280
It's a good idea to create your own client module in your project like this:
7381

7482
```elixir
7583
defmodule MyApp.BamlClient do
76-
def call(name, args, struct_name \\ nil) do
84+
def call(name, args) do
7785
client = %BamlElixir.Client{
7886
from: Application.get_env(:my_app, :baml_src_path),
79-
struct_name: struct_name
8087
}
8188

8289
BamlElixir.call(client, name, args)
@@ -87,7 +94,7 @@ end
8794
and call it like this:
8895

8996
```elixir
90-
MyApp.BamlClient.call("ExtractResume", %{resume: "John Doe is the CTO of Acme Inc."}, MyApp.Resume)
97+
MyApp.BamlClient.call("ExtractResume", %{resume: "John Doe is the CTO of Acme Inc."})
9198
```
9299

93100
## Installation

0 commit comments

Comments
 (0)