Skip to content

Commit

Permalink
bump things
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Aug 12, 2024
1 parent 311990c commit b68bf07
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 24 deletions.
46 changes: 36 additions & 10 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zoo"
version = "0.2.68"
version = "0.2.69"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -22,7 +22,7 @@ git_rev = "0.1.0"
heck = "0.5.0"
http = "0.2.6"
itertools = "0.12.1"
kcl-lib = "0.2"
kcl-lib = "0.2.4"
kcl-test-server = "0.1.4"
kittycad = { version = "0.3.10", features = ["clap", "tabled", "requests", "retry"] }
log = "0.4.22"
Expand Down
8 changes: 6 additions & 2 deletions src/cmd_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,17 @@ fn get_input_format(
},
};
match format {
kittycad::types::FileImportFormat::Step => Ok(kittycad::types::InputFormat::Step {}),
kittycad::types::FileImportFormat::Step => Ok(kittycad::types::InputFormat::Step {
split_closed_faces: false,
}),
kittycad::types::FileImportFormat::Stl => Ok(kittycad::types::InputFormat::Stl { coords, units: ul }),
kittycad::types::FileImportFormat::Obj => Ok(kittycad::types::InputFormat::Obj { coords, units: ul }),
kittycad::types::FileImportFormat::Gltf => Ok(kittycad::types::InputFormat::Gltf {}),
kittycad::types::FileImportFormat::Ply => Ok(kittycad::types::InputFormat::Ply { coords, units: ul }),
kittycad::types::FileImportFormat::Fbx => Ok(kittycad::types::InputFormat::Fbx {}),
kittycad::types::FileImportFormat::Sldprt => Ok(kittycad::types::InputFormat::Sldprt {}),
kittycad::types::FileImportFormat::Sldprt => Ok(kittycad::types::InputFormat::Sldprt {
split_closed_faces: false,
}),
}
}

Expand Down
25 changes: 15 additions & 10 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ impl Context<'_> {
let client = self.api_client(hostname)?;

// Create the text-to-cad request.
let mut model: kittycad::types::TextToCad = client
.ai()
let mut gen_model: kittycad::types::TextToCad = client
.ml()
.create_text_to_cad(
None,
format,
&kittycad::types::TextToCadCreateBody {
prompt: prompt.to_string(),
Expand All @@ -196,7 +197,7 @@ impl Context<'_> {
.await?;

// Poll until the model is ready.
let mut status = model.status.clone();
let mut status = gen_model.status.clone();
// Get the current time.
let start = std::time::Instant::now();
// Give it 5 minutes to complete. That should be way
Expand All @@ -206,7 +207,7 @@ impl Context<'_> {
&& start.elapsed().as_secs() < 60 * 5
{
// Poll for the status.
let result = client.api_calls().get_async_operation(model.id).await?;
let result = client.api_calls().get_async_operation(gen_model.id).await?;

if let kittycad::types::AsyncApiCallOutput::TextToCad {
completed_at,
Expand All @@ -222,9 +223,11 @@ impl Context<'_> {
status,
updated_at,
user_id,
code,
model,
} = result
{
model = kittycad::types::TextToCad {
gen_model = kittycad::types::TextToCad {
completed_at,
created_at,
error,
Expand All @@ -238,32 +241,34 @@ impl Context<'_> {
status,
updated_at,
user_id,
code,
model,
};
} else {
anyhow::bail!("Unexpected response type: {:?}", result);
}

status = model.status.clone();
status = gen_model.status.clone();

// Wait for a bit before polling again.
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
}

// If the model failed we will want to tell the user.
if model.status == kittycad::types::ApiCallStatus::Failed {
if let Some(error) = model.error {
if gen_model.status == kittycad::types::ApiCallStatus::Failed {
if let Some(error) = gen_model.error {
anyhow::bail!("Your prompt returned an error: ```\n{}\n```", error);
} else {
anyhow::bail!("Your prompt returned an error, but no error message. :(");
}
}

if model.status != kittycad::types::ApiCallStatus::Completed {
if gen_model.status != kittycad::types::ApiCallStatus::Completed {
anyhow::bail!("Your prompt timed out");
}

// Okay, we successfully got a model!
Ok(model)
Ok(gen_model)
}

/// This function opens a browser that is based on the configured
Expand Down

0 comments on commit b68bf07

Please sign in to comment.