Skip to content

Commit

Permalink
Merge branch 'canary' into feat/support-curly-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvg authored Dec 16, 2024
2 parents 0513ae7 + c62cef4 commit 67809a8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions engine/baml-schema-wasm/src/runtime_wasm/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pub struct WasmGeneratorOutput {
#[wasm_bindgen(readonly)]
pub output_dir: String,
#[wasm_bindgen(readonly)]
pub output_dir_relative_to_baml_src: String,
#[wasm_bindgen(readonly)]
pub files: Vec<WasmGeneratedFile>,
}

Expand All @@ -22,6 +24,10 @@ impl Into<WasmGeneratorOutput> for GenerateOutput {
fn into(self) -> WasmGeneratorOutput {
WasmGeneratorOutput {
output_dir: self.output_dir_full.to_string_lossy().to_string(),
output_dir_relative_to_baml_src: self
.output_dir_shorthand
.to_string_lossy()
.to_string(),
files: self
.files
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion engine/language_client_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ sugar_path = "1.2.0"
walkdir.workspace = true
semver = "1.0.23"
colored = "2.1.0"
itertools = "0.13.0"
itertools = "0.13.0"
4 changes: 2 additions & 2 deletions fern/01-guide/04-baml-basics/switching-llms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function MakeHaiku(topic: string) -> string {
}
```

Consult the [provider documentation](#fields) for a list of supported providers
and models, the default options, and setting [retry policies](/docs/reference/retry-policy).
Consult the [provider documentation](/ref/llm-client-providers/open-ai) for a list of supported providers
and models, the default options, and setting [retry policies](/ref/llm-client-strategies/retry-policy).

<Tip>
If you want to specify which client to use at runtime, in your Python/TS/Ruby code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ class Project {
// Creating the tmpdir next to the output dir can cause some weird issues with vscode, if we recover
// from an error and delete the tmpdir - vscode's explorer UI will still show baml_client.tmp even
// though it doesn't exist anymore, and vscode has no good way of letting the user purge it from the UI
console.log(`outputdir ${g.output_dir}`)
console.log(`relative output dir ${g.output_dir_relative_to_baml_src}`)

const out_dir = path.join(this.rootPath(), g.output_dir_relative_to_baml_src)

const tmpDir = path.join(path.dirname(g.output_dir), path.basename(g.output_dir) + '.tmp')
const backupDir = path.join(path.dirname(g.output_dir), path.basename(g.output_dir) + '.bak')

Expand All @@ -386,8 +391,8 @@ class Project {
if (existsSync(backupDir)) {
await rm(backupDir, { recursive: true, force: true })
}
if (existsSync(g.output_dir)) {
const contents = await readdir(g.output_dir, { withFileTypes: true })
if (existsSync(out_dir)) {
const contents = await readdir(out_dir, { withFileTypes: true })
const contentsWithSafeToRemove = await Promise.all(
contents.map(async (c) => {
if (c.isDirectory()) {
Expand All @@ -414,15 +419,16 @@ class Project {
`Output dir ${g.output_dir} contains this file(s) not generated by BAML: ${notSafeToRemove.join(', ')}`,
)
}
await rename(g.output_dir, backupDir)
await rename(out_dir, backupDir)
}
await rename(tmpDir, g.output_dir)
await rename(tmpDir, out_dir)

try {
// some filewatchers don't trigger unless the file is touched. Creating the new dir alone doesn't work.
// if we remove this, TS will still have the old types, and nextjs will not hot-reload.
g.files.map((f) => {
const fpath = path.join(g.output_dir, f.path_in_output_dir)
const fpath = path.join(out_dir, f.path_in_output_dir)
console.log(`fpath ${fpath}`)
const currentTime = new Date()
const newTime = new Date(currentTime.getTime() + 100)
utimes(fpath, newTime, newTime, (err) => {
Expand Down

0 comments on commit 67809a8

Please sign in to comment.