Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-08-09 17:16:09 -07:00
parent 9cbda88fcc
commit 108e3e2284
11 changed files with 940 additions and 892 deletions

View File

@ -0,0 +1 @@
.venv

File diff suppressed because it is too large Load Diff

View File

@ -15,12 +15,20 @@ def _get_kwargs(
body: TextToCadCreateBody,
*,
client: Client,
kcl: Optional[bool] = None,
) -> Dict[str, Any]:
url = "{}/ai/text-to-cad/{output_format}".format(
client.base_url,
output_format=output_format,
) # noqa: E501
if kcl is not None:
if "?" in url:
url = url + "&kcl=" + str(kcl)
else:
url = url + "?kcl=" + str(kcl)
headers: Dict[str, Any] = client.get_headers()
cookies: Dict[str, Any] = client.get_cookies()
@ -62,9 +70,11 @@ def sync_detailed(
body: TextToCadCreateBody,
*,
client: Client,
kcl: Optional[bool] = None,
) -> Response[Optional[Union[TextToCad, Error]]]:
kwargs = _get_kwargs(
output_format=output_format,
kcl=kcl,
body=body,
client=client,
)
@ -82,6 +92,7 @@ def sync(
body: TextToCadCreateBody,
*,
client: Client,
kcl: Optional[bool] = None,
) -> Optional[Union[TextToCad, Error]]:
"""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.
This 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.
@ -90,6 +101,7 @@ def sync(
return sync_detailed(
output_format=output_format,
kcl=kcl,
body=body,
client=client,
).parsed
@ -100,9 +112,11 @@ async def asyncio_detailed(
body: TextToCadCreateBody,
*,
client: Client,
kcl: Optional[bool] = None,
) -> Response[Optional[Union[TextToCad, Error]]]:
kwargs = _get_kwargs(
output_format=output_format,
kcl=kcl,
body=body,
client=client,
)
@ -118,6 +132,7 @@ async def asyncio(
body: TextToCadCreateBody,
*,
client: Client,
kcl: Optional[bool] = None,
) -> Optional[Union[TextToCad, Error]]:
"""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.
This 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.
@ -127,6 +142,7 @@ async def asyncio(
return (
await asyncio_detailed(
output_format=output_format,
kcl=kcl,
body=body,
client=client,
)

View File

@ -547,6 +547,7 @@ def test_text_to_cad():
body=TextToCadCreateBody(
prompt="a 2x4 lego",
),
kcl=None,
)
if isinstance(result, Error) or result is None:

View File

@ -583,6 +583,7 @@ def test_create_text_to_cad():
result: Optional[Union[TextToCad, Error]] = create_text_to_cad.sync(
client=client,
output_format=FileExportFormat.FBX,
kcl=None, # Optional[bool]
body=TextToCadCreateBody(
prompt="<string>",
),
@ -600,6 +601,7 @@ def test_create_text_to_cad():
create_text_to_cad.sync_detailed(
client=client,
output_format=FileExportFormat.FBX,
kcl=None, # Optional[bool]
body=TextToCadCreateBody(
prompt="<string>",
),
@ -617,6 +619,7 @@ async def test_create_text_to_cad_async():
result: Optional[Union[TextToCad, Error]] = await create_text_to_cad.asyncio(
client=client,
output_format=FileExportFormat.FBX,
kcl=None, # Optional[bool]
body=TextToCadCreateBody(
prompt="<string>",
),
@ -627,6 +630,7 @@ async def test_create_text_to_cad_async():
await create_text_to_cad.asyncio_detailed(
client=client,
output_format=FileExportFormat.FBX,
kcl=None, # Optional[bool]
body=TextToCadCreateBody(
prompt="<string>",
),

View File

@ -226,6 +226,7 @@ from .system import System
from .take_snapshot import TakeSnapshot
from .text_to_cad import TextToCad
from .text_to_cad_create_body import TextToCadCreateBody
from .text_to_cad_model import TextToCadModel
from .text_to_cad_results_page import TextToCadResultsPage
from .unit_angle import UnitAngle
from .unit_angle_conversion import UnitAngleConversion

View File

@ -6,6 +6,8 @@ class AiPromptType(str, Enum):
"""# Text to CAD. """ # noqa: E501
TEXT_TO_CAD = "text_to_cad"
"""# Text to KCL. """ # noqa: E501
TEXT_TO_KCL = "text_to_kcl"
def __str__(self) -> str:
return str(self.value)

View File

@ -11,6 +11,7 @@ from ..models.file_import_format import FileImportFormat
from ..models.input_format import InputFormat
from ..models.output_format import OutputFormat
from ..models.point3d import Point3d
from ..models.text_to_cad_model import TextToCadModel
from ..models.unit_area import UnitArea
from ..models.unit_density import UnitDensity
from ..models.unit_length import UnitLength
@ -215,6 +216,8 @@ class file_surface_area(BaseModel):
class text_to_cad(BaseModel):
"""Text to CAD."""
code: Optional[str] = None
completed_at: Optional[datetime.datetime] = None
created_at: datetime.datetime
@ -225,6 +228,8 @@ class text_to_cad(BaseModel):
id: Uuid
model: TextToCadModel
model_version: str
output_format: FileExportFormat

View File

@ -6,6 +6,7 @@ from pydantic import BaseModel, ConfigDict
from ..models.ai_feedback import AiFeedback
from ..models.api_call_status import ApiCallStatus
from ..models.file_export_format import FileExportFormat
from ..models.text_to_cad_model import TextToCadModel
from ..models.uuid import Uuid
from .base64data import Base64Data
@ -13,6 +14,8 @@ from .base64data import Base64Data
class TextToCad(BaseModel):
"""A response from a text to CAD prompt."""
code: Optional[str] = None
completed_at: Optional[datetime.datetime] = None
created_at: datetime.datetime
@ -23,6 +26,8 @@ class TextToCad(BaseModel):
id: Uuid
model: TextToCadModel
model_version: str
output_format: FileExportFormat

View File

@ -0,0 +1,13 @@
from enum import Enum
class TextToCadModel(str, Enum):
"""A type of Text-to-CAD model.""" # noqa: E501
"""# CAD. """ # noqa: E501
CAD = "cad"
"""# KCL. """ # noqa: E501
KCL = "kcl"
def __str__(self) -> str:
return str(self.value)

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "kittycad"
version = "0.6.17"
version = "0.6.18"
description = "A client library for accessing KittyCAD"
authors = []