Skip to content

Commit

Permalink
Revert "docs!: require Ruby users to go through OpenAPI, instead of t…
Browse files Browse the repository at this point in the history
…hrough the gem (#956)"

This reverts commit 1e911e7.
  • Loading branch information
sxlijin committed Sep 20, 2024
1 parent 847f3a9 commit 97c73e1
Show file tree
Hide file tree
Showing 20 changed files with 531 additions and 248 deletions.
4 changes: 3 additions & 1 deletion docs/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ navigation:
path: docs/get-started/quickstart/python.mdx
- page: TypeScript
path: docs/get-started/quickstart/typescript.mdx
- page: Ruby
path: docs/get-started/quickstart/ruby.mdx
- page: Any Language (OpenAPI)
path: docs/get-started/quickstart/openapi.mdx
- page: VSCode
Expand Down Expand Up @@ -149,7 +151,7 @@ navigation:
path: docs/calling-baml/dynamic-types.mdx
- page: Client Registry
path: docs/calling-baml/client-registry.mdx
- section: BAML with Python/TS/OpenAPI
- section: BAML with Python/TS/Ruby
contents:
- page: Generate the BAML Client
path: docs/calling-baml/generate-baml-client.mdx
Expand Down
22 changes: 22 additions & 0 deletions docs/docs/calling-baml/calling-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ if (require.main === module) {
```
</Tab>

<Tab title="Ruby (beta)">

BAML will generate `Baml.Client.ClassifyMessage()` for you, which you can use like so:

```ruby main.rb
require_relative "baml_client/client"

$b = Baml.Client

def main
category = $b.ClassifyMessage(input: "I want to cancel my order")
puts category
category == Baml::Types::Category::CancelOrder
end

if __FILE__ == $0
puts main
end

```

</Tab>
<Tab title="OpenAPI">

If you're using an OpenAPI-generated client, every BAML function will generate
Expand Down
35 changes: 33 additions & 2 deletions docs/docs/calling-baml/client-registry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Client Registry
slug: docs/calling-baml/client-registry
---
{/* TODO: use fern Group elements instead of CodeBlock elements for Python/TS/OpenAPI */}
{/* TODO: use fern Group elements instead of CodeBlock elements for Python/TS/Ruby */}

If you need to modify the model / parameters for an LLM client at runtime, you can modify the `ClientRegistry` for any specified function.

Expand Down Expand Up @@ -52,8 +52,39 @@ async function run() {
```
</Tab>

<Tab title="Ruby">

```ruby
require_relative "baml_client/client"

def run
cr = Baml::ClientRegistry.new

# Creates a new client
cr.add_llm_client(
name: 'MyAmazingClient',
provider: 'openai',
options: {
model: 'gpt-4o',
temperature: 0.7,
api_key: ENV['OPENAI_API_KEY']
}
)

# Sets MyAmazingClient as the primary client
cr.set_primary('MyAmazingClient')

# ExtractResume will now use MyAmazingClient as the calling client
res = Baml.Client.extract_resume(input: '...', baml_options: { client_registry: cr })
end

# Call the asynchronous function
run
```
</Tab>

<Tab title="OpenAPI">
Client registries are not yet supported when used via OpenAPI.
Dynamic types are not yet supported when used via OpenAPI.

Please let us know if you want this feature, either via [Discord] or [GitHub][openapi-feedback-github-issue].

Expand Down
10 changes: 5 additions & 5 deletions docs/docs/calling-baml/concurrent-calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function ClassifyMessage(input: string) -> Category {
</Accordion>

<Tabs>

<Tab title="Python">

You can make concurrent `b.ClassifyMessage()` calls like so:
Expand Down Expand Up @@ -78,10 +77,11 @@ if (require.main === module) {
```
</Tab>

<Tab title="OpenAPI">
Please reference the concurrency docs for your language of choice.
<Tab title="Ruby (beta)">

We'll add examples for how to do this soon, though!
</Tab>
BAML Ruby (beta) does not currently support async/concurrent calls.

Please [contact us](/contact) if this is something you need.

</Tab>
</Tabs>
Loading

0 comments on commit 97c73e1

Please sign in to comment.