Skip to content

Commit

Permalink
Update api spec (#489)
Browse files Browse the repository at this point in the history
* YOYO NEW API SPEC!

* I have generated the library!

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 62df130 commit ab8716f
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 73 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

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

30 changes: 15 additions & 15 deletions kittycad.rs.patch.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions kittycad/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kittycad"
description = "A fully generated & opinionated API client for the KittyCAD API."
version = "0.3.11"
version = "0.3.12"
documentation = "https://docs.rs/kittycad"
readme = "README.md"
repository = "https://github.com/KittyCAD/kittycad.rs/tree/main/kittycad"
Expand Down Expand Up @@ -37,7 +37,7 @@ serde = { version = "1", features = ["derive"] }
serde_bytes = "0.11"
serde_json = "1"
serde_urlencoded = { version = "^0.7", optional = true }
tabled = { version = "0.16.0", features = ["ansi"], optional = true }
tabled = { version = "0.15.0", features = ["ansi"], optional = true }
thiserror = "1"
tracing = { version = "^0.1", optional = true }
url = { version = "2", features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion kittycad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To install the library, add the following to your `Cargo.toml` file.

```toml
[dependencies]
kittycad = "0.3.11"
kittycad = "0.3.12"
```

## Basic example
Expand Down
26 changes: 13 additions & 13 deletions kittycad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//!
//! ```toml
//! [dependencies]
//! kittycad = "0.3.11"
//! kittycad = "0.3.12"
//! ```
//!
//! ## Basic example
Expand Down Expand Up @@ -59,11 +59,6 @@
#![allow(clippy::needless_lifetimes)]
#![cfg_attr(docsrs, feature(doc_cfg))]

/// AI uses machine learning to generate CAD models.
///
/// FROM: <https://zoo.dev/docs/api/ai>
#[cfg(feature = "requests")]
pub mod ai;
/// API calls that have been performed by users can be queried by the API. This is helpful for debugging as well as billing.
///
/// FROM: <https://zoo.dev/docs/api/api-calls>
Expand Down Expand Up @@ -100,6 +95,11 @@ pub mod hidden;
#[cfg(feature = "requests")]
pub mod meta;
mod methods;
/// Machine learning to generate CAD models and other things.
///
/// FROM: <https://zoo.dev/docs/api/ml>
#[cfg(feature = "requests")]
pub mod ml;
/// Modeling API for updating your 3D files using the Zoo engine.
///
/// FROM: <https://zoo.dev/docs/api/modeling>
Expand Down Expand Up @@ -376,13 +376,6 @@ impl Client {
Ok(RequestBuilder(req))
}

/// AI uses machine learning to generate CAD models.
///
/// FROM: <https://zoo.dev/docs/api/ai>
pub fn ai(&self) -> ai::Ai {
ai::Ai::new(self.clone())
}

/// API calls that have been performed by users can be queried by the API. This is helpful for debugging as well as billing.
///
/// FROM: <https://zoo.dev/docs/api/api-calls>
Expand Down Expand Up @@ -432,6 +425,13 @@ impl Client {
meta::Meta::new(self.clone())
}

/// Machine learning to generate CAD models and other things.
///
/// FROM: <https://zoo.dev/docs/api/ml>
pub fn ml(&self) -> ml::Ml {
ml::Ml::new(self.clone())
}

/// Modeling API for updating your 3D files using the Zoo engine.
///
/// FROM: <https://zoo.dev/docs/api/modeling>
Expand Down
36 changes: 18 additions & 18 deletions kittycad/src/ai.rs → kittycad/src/ml.rs

Large diffs are not rendered by default.

38 changes: 37 additions & 1 deletion kittycad/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ pub struct AiPrompt {
pub id: uuid::Uuid,
#[doc = "The metadata for the prompt."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<serde_json::Value>,
pub metadata: Option<AiPromptMetadata>,
#[doc = "The version of the model."]
pub model_version: String,
#[doc = "The output file. In the case of TextToCad this is a link to a file in a GCP bucket."]
Expand Down Expand Up @@ -793,6 +793,42 @@ impl tabled::Tabled for AiPrompt {
}
}

#[doc = "Metadata for an AI prompt."]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
)]
pub struct AiPromptMetadata {
#[doc = "Code for the model."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
}

impl std::fmt::Display for AiPromptMetadata {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(
f,
"{}",
serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)?
)
}
}

#[cfg(feature = "tabled")]
impl tabled::Tabled for AiPromptMetadata {
const LENGTH: usize = 1;
fn fields(&self) -> Vec<std::borrow::Cow<'static, str>> {
vec![if let Some(code) = &self.code {
format!("{:?}", code).into()
} else {
String::new().into()
}]
}

fn headers() -> Vec<std::borrow::Cow<'static, str>> {
vec!["code".into()]
}
}

#[doc = "A single page of results"]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
Expand Down
38 changes: 37 additions & 1 deletion openapitor/tests/types/kittycad.rs.gen
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ pub struct AiPrompt {
pub id: uuid::Uuid,
#[doc = "The metadata for the prompt."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metadata: Option<serde_json::Value>,
pub metadata: Option<AiPromptMetadata>,
#[doc = "The version of the model."]
pub model_version: String,
#[doc = "The output file. In the case of TextToCad this is a link to a file in a GCP bucket."]
Expand Down Expand Up @@ -790,6 +790,42 @@ impl tabled::Tabled for AiPrompt {
}
}

#[doc = "Metadata for an AI prompt."]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
)]
pub struct AiPromptMetadata {
#[doc = "Code for the model."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
}

impl std::fmt::Display for AiPromptMetadata {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(
f,
"{}",
serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)?
)
}
}

#[cfg(feature = "tabled")]
impl tabled::Tabled for AiPromptMetadata {
const LENGTH: usize = 1;
fn fields(&self) -> Vec<std::borrow::Cow<'static, str>> {
vec![if let Some(code) = &self.code {
format!("{:?}", code).into()
} else {
String::new().into()
}]
}

fn headers() -> Vec<std::borrow::Cow<'static, str>> {
vec!["code".into()]
}
}

#[doc = "A single page of results"]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
Expand Down
46 changes: 31 additions & 15 deletions spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
"/ai-prompts": {
"get": {
"tags": [
"ai",
"ml",
"hidden"
],
"summary": "List all AI prompts.",
Expand Down Expand Up @@ -292,7 +292,7 @@
"/ai-prompts/{id}": {
"get": {
"tags": [
"ai",
"ml",
"hidden"
],
"summary": "Get an AI prompt.",
Expand Down Expand Up @@ -367,7 +367,7 @@
"/ai/kcl/completions": {
"post": {
"tags": [
"ai",
"ml",
"beta"
],
"summary": "Generate code completions for KCL.",
Expand Down Expand Up @@ -492,7 +492,7 @@
"/ai/text-to-cad/{output_format}": {
"post": {
"tags": [
"ai"
"ml"
],
"summary": "Generate a CAD model from text.",
"description": "Because our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.\nThis operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.\nOne thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.",
Expand Down Expand Up @@ -11326,7 +11326,7 @@
"/user/text-to-cad": {
"get": {
"tags": [
"ai"
"ml"
],
"summary": "List text-to-CAD models you've generated.",
"description": "This will always return the STEP file contents as well as the format the user originally requested.\nThis endpoint requires authentication by any Zoo user. It returns the text-to-CAD models for the authenticated user.\nThe text-to-CAD models are returned in order of creation, with the most recently created text-to-CAD models first.",
Expand Down Expand Up @@ -11429,7 +11429,7 @@
"/user/text-to-cad/{id}": {
"get": {
"tags": [
"ai"
"ml"
],
"summary": "Get a text-to-CAD response.",
"description": "This endpoint requires authentication by any Zoo user. The user must be the owner of the text-to-CAD model.",
Expand Down Expand Up @@ -11501,7 +11501,7 @@
},
"post": {
"tags": [
"ai"
"ml"
],
"summary": "Give feedback to a specific text-to-CAD response.",
"description": "This endpoint requires authentication by any Zoo user. The user must be the owner of the text-to-CAD model, in order to give feedback.",
Expand Down Expand Up @@ -12608,7 +12608,12 @@
},
"metadata": {
"nullable": true,
"description": "The metadata for the prompt."
"description": "The metadata for the prompt.",
"allOf": [
{
"$ref": "#/components/schemas/AiPromptMetadata"
}
]
},
"model_version": {
"description": "The version of the model.",
Expand Down Expand Up @@ -12672,6 +12677,17 @@
"user_id"
]
},
"AiPromptMetadata": {
"description": "Metadata for an AI prompt.",
"type": "object",
"properties": {
"code": {
"nullable": true,
"description": "Code for the model.",
"type": "string"
}
}
},
"AiPromptResultsPage": {
"description": "A single page of results",
"type": "object",
Expand Down Expand Up @@ -28166,13 +28182,6 @@
}
},
"tags": [
{
"name": "ai",
"description": "AI uses machine learning to generate CAD models.",
"externalDocs": {
"url": "https://zoo.dev/docs/api/ai"
}
},
{
"name": "api-calls",
"description": "API calls that have been performed by users can be queried by the API. This is helpful for debugging as well as billing.",
Expand Down Expand Up @@ -28236,6 +28245,13 @@
"url": "https://zoo.dev/docs/api/meta"
}
},
{
"name": "ml",
"description": "Machine learning to generate CAD models and other things.",
"externalDocs": {
"url": "https://zoo.dev/docs/api/ml"
}
},
{
"name": "modeling",
"description": "Modeling API for updating your 3D files using the Zoo engine.",
Expand Down

0 comments on commit ab8716f

Please sign in to comment.