Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak docs #680

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 0 additions & 100 deletions docs/docs/syntax/class.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,106 +59,6 @@ The type of a property can be any [supported type](/docs/syntax/type)

- Not yet supported. For optional properties, the default value is `None` in python.

### Computed properties

Somtimes, you may want a computed property. For example, you may want to return a full name from a first and last name property. You can do this by adding the `@get` attribute to a property.

Some use cases are:

- Format a list of items into a string
- Format a date into a string
- Load data from a database
- Read data from a file

<Warning>
As of now, computed properties are not async! This means you cannot use
`await` in the code block. `@async_get` is planned for the future.
</Warning>

<CodeGroup>

```rust BAML
class Foo {
first_name string
last_name string

full_name string @get(python#"
return f'{self.first_name} {self.last_name}'
"#, typescript#"
return `${this.first_name} ${this.last_name}`
"#)
}
```

```python Python Equivalent
from pydantic import BaseModel

class Foo(BaseModel):
first_name: str
last_name: str

@property
def full_name(self) -> str:
return f'{self.first_name} {self.last_name}'
```

```typescript Typescript Equivalent
import z from "zod";

const IFooZod = z.object({
first_name: z.string(),
last_name: z.string(),
});

type IFoo = z.infer<typeof IFooZod>;

class Foo implements IFoo {
first_name: string;
last_name: string;

get full_name(): string {
return `${this.first_name} ${this.last_name}`;
}

constructor(foo: IFoo) {
this.first_name = foo.first_name;
this.last_name = foo.last_name;
}
}
```

</CodeGroup>

You can also chain computed properties together.

<CodeGroup>

```rust BAML
class Foo {
full_name_upper string @get(python#"
return self.full_name.upper()
"#, typescript#"
return this.full_name.toUpperCase()
"#)
}
```

```python Python Equivalent
@property
def full_name_upper(self) -> str:
return self.full_name.upper()
```

```typescript Typescript Equivalent
...

get full_name_upper(): string {
return this.full_name.toUpperCase();
}
```

</CodeGroup>

## Inheritance

Not supported. Like rust, we take the stance that [composition is better than inheritance](https://www.digitalocean.com/community/tutorials/composition-vs-inheritance).
Expand Down
3 changes: 1 addition & 2 deletions docs/docs/syntax/client/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ A **client** is the mechanism by which a function calls an LLM.
## Syntax

```rust
client<CLIENT_TYPE> Name {
client<llm> Name {
provider ProviderName
options {
// ...
}
}
```

- `CLIENT_TYPE`: What type of AI model will be used. Currently must be `llm`
- `Name`: The name of the client (can be any [a-zA-Z], numbers or `_`). Must start with a letter.

## Properties
Expand Down
1 change: 1 addition & 0 deletions docs/docs/syntax/generator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Here is how you can add a generator block:
```rust
generator MyGenerator{
output_type typescript // or python/pydantic, ruby
output_dir ../
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/syntax/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A BAML project has the following structure:

1. `baml_src/` is the directory where you write your BAML files with the AI
function declarations, prompts, retry policies, etc. It also contains
[generator](/v3/syntax/generator) blocks which configure how and where to
[generator](/syntax/generator) blocks which configure how and where to
transpile your BAML code.

2. `baml_client/` is the directory where BAML will generate code, and where you'll
Expand Down
206 changes: 0 additions & 206 deletions docs/v3/guides/classification/level1.mdx

This file was deleted.

Loading
Loading