Update api spec (#375)
* YOYO NEW API SPEC! * I have generated the latest API! --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3ff3519d68
commit
4aa6b69d5c
@ -12,6 +12,7 @@ from ...models.file_surface_area import FileSurfaceArea
|
||||
from ...models.file_volume import FileVolume
|
||||
from ...models.text_to_cad import TextToCad
|
||||
from ...models.text_to_cad_iteration import TextToCadIteration
|
||||
from ...models.text_to_cad_multi_file_iteration import TextToCadMultiFileIteration
|
||||
from ...types import Response
|
||||
|
||||
|
||||
@ -48,6 +49,7 @@ def _parse_response(
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]:
|
||||
@ -121,6 +123,17 @@ def _parse_response(
|
||||
raise TypeError()
|
||||
option_text_to_cad_iteration = TextToCadIteration(**data)
|
||||
return option_text_to_cad_iteration
|
||||
except ValueError:
|
||||
pass
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
if not isinstance(data, dict):
|
||||
raise TypeError()
|
||||
option_text_to_cad_multi_file_iteration = TextToCadMultiFileIteration(
|
||||
**data
|
||||
)
|
||||
return option_text_to_cad_multi_file_iteration
|
||||
except ValueError:
|
||||
raise
|
||||
except TypeError:
|
||||
@ -147,6 +160,7 @@ def _build_response(
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -174,6 +188,7 @@ def sync_detailed(
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -205,6 +220,7 @@ def sync(
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]:
|
||||
@ -237,6 +253,7 @@ async def asyncio_detailed(
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -266,6 +283,7 @@ async def asyncio(
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]:
|
||||
|
||||
@ -83,7 +83,9 @@ def sync(
|
||||
|
||||
You always get the whole code back, even if you only changed a small part of it.
|
||||
|
||||
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.""" # noqa: E501
|
||||
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.
|
||||
|
||||
This endpoint will soon be deprecated in favor of the `/ml/text-to-cad/multi-file/iteration` endpoint. In that the endpoint path will remain but it will have the same behavior as `ml/text-to-cad/multi-file/iteration`.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
body=body,
|
||||
@ -116,7 +118,9 @@ async def asyncio(
|
||||
|
||||
You always get the whole code back, even if you only changed a small part of it.
|
||||
|
||||
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.""" # noqa: E501
|
||||
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.
|
||||
|
||||
This endpoint will soon be deprecated in favor of the `/ml/text-to-cad/multi-file/iteration` endpoint. In that the endpoint path will remain but it will have the same behavior as `ml/text-to-cad/multi-file/iteration`.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
|
||||
132
kittycad/api/ml/create_text_to_cad_multi_file_iteration.py
Normal file
132
kittycad/api/ml/create_text_to_cad_multi_file_iteration.py
Normal file
@ -0,0 +1,132 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.error import Error
|
||||
from ...models.text_to_cad_multi_file_iteration import TextToCadMultiFileIteration
|
||||
from ...models.text_to_cad_multi_file_iteration_body import (
|
||||
TextToCadMultiFileIterationBody,
|
||||
)
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
body: TextToCadMultiFileIterationBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Dict[str, Any]:
|
||||
url = "{}/ml/text-to-cad/multi-file/iteration".format(
|
||||
client.base_url,
|
||||
) # noqa: E501
|
||||
|
||||
headers: Dict[str, Any] = client.get_headers()
|
||||
cookies: Dict[str, Any] = client.get_cookies()
|
||||
|
||||
return {
|
||||
"url": url,
|
||||
"headers": headers,
|
||||
"cookies": cookies,
|
||||
"timeout": client.get_timeout(),
|
||||
"content": body.model_dump_json(),
|
||||
}
|
||||
|
||||
|
||||
def _parse_response(
|
||||
*, response: httpx.Response
|
||||
) -> Optional[Union[TextToCadMultiFileIteration, Error]]:
|
||||
if response.status_code == 201:
|
||||
response_201 = TextToCadMultiFileIteration(**response.json())
|
||||
return response_201
|
||||
if response.status_code == 400:
|
||||
response_4XX = Error(**response.json())
|
||||
return response_4XX
|
||||
if response.status_code == 500:
|
||||
response_5XX = Error(**response.json())
|
||||
return response_5XX
|
||||
return Error(**response.json())
|
||||
|
||||
|
||||
def _build_response(
|
||||
*, response: httpx.Response
|
||||
) -> Response[Optional[Union[TextToCadMultiFileIteration, Error]]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
body: TextToCadMultiFileIterationBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[TextToCadMultiFileIteration, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
response = httpx.post(
|
||||
verify=client.verify_ssl,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
body: TextToCadMultiFileIterationBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[TextToCadMultiFileIteration, Error]]:
|
||||
"""This endpoint can iterate on multi-file models.
|
||||
|
||||
Even if you give specific ranges to edit, the model might change more than just those in order to make the changes you requested without breaking the code.
|
||||
|
||||
You always get the whole code back, even if you only changed a small part of it. This endpoint will always return all the code back, including files that were not changed. If your original source code imported a stl/gltf/step/etc file, the output will not include that file since the model will never change non-kcl files. The endpoint will only return the kcl files that were changed.
|
||||
|
||||
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.""" # noqa: E501
|
||||
|
||||
return sync_detailed(
|
||||
body=body,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
body: TextToCadMultiFileIterationBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Optional[Union[TextToCadMultiFileIteration, Error]]]:
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
||||
response = await _client.post(**kwargs)
|
||||
|
||||
return _build_response(response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
body: TextToCadMultiFileIterationBody,
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[TextToCadMultiFileIteration, Error]]:
|
||||
"""This endpoint can iterate on multi-file models.
|
||||
|
||||
Even if you give specific ranges to edit, the model might change more than just those in order to make the changes you requested without breaking the code.
|
||||
|
||||
You always get the whole code back, even if you only changed a small part of it. This endpoint will always return all the code back, including files that were not changed. If your original source code imported a stl/gltf/step/etc file, the output will not include that file since the model will never change non-kcl files. The endpoint will only return the kcl files that were changed.
|
||||
|
||||
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.""" # noqa: E501
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
body=body,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
@ -59,6 +59,7 @@ from kittycad.api.ml import (
|
||||
create_text_to_cad,
|
||||
create_text_to_cad_iteration,
|
||||
create_text_to_cad_model_feedback,
|
||||
create_text_to_cad_multi_file_iteration,
|
||||
get_ml_prompt,
|
||||
get_text_to_cad_model_for_user,
|
||||
list_ml_prompts,
|
||||
@ -205,6 +206,7 @@ from kittycad.models import (
|
||||
ShortlinkResultsPage,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
TextToCadResultsPage,
|
||||
UnitAngleConversion,
|
||||
UnitAreaConversion,
|
||||
@ -272,6 +274,9 @@ from kittycad.models.source_range_prompt import SourceRangePrompt
|
||||
from kittycad.models.store_coupon_params import StoreCouponParams
|
||||
from kittycad.models.text_to_cad_create_body import TextToCadCreateBody
|
||||
from kittycad.models.text_to_cad_iteration_body import TextToCadIterationBody
|
||||
from kittycad.models.text_to_cad_multi_file_iteration_body import (
|
||||
TextToCadMultiFileIterationBody,
|
||||
)
|
||||
from kittycad.models.unit_angle import UnitAngle
|
||||
from kittycad.models.unit_area import UnitArea
|
||||
from kittycad.models.unit_current import UnitCurrent
|
||||
@ -836,6 +841,7 @@ def test_get_async_operation():
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
] = get_async_operation.sync(
|
||||
@ -856,6 +862,7 @@ def test_get_async_operation():
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
] = result
|
||||
print(body)
|
||||
|
||||
@ -871,6 +878,7 @@ def test_get_async_operation():
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -897,6 +905,7 @@ async def test_get_async_operation_async():
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
] = await get_async_operation.asyncio(
|
||||
@ -916,6 +925,7 @@ async def test_get_async_operation_async():
|
||||
FileSurfaceArea,
|
||||
TextToCad,
|
||||
TextToCadIteration,
|
||||
TextToCadMultiFileIteration,
|
||||
Error,
|
||||
]
|
||||
]
|
||||
@ -2095,6 +2105,121 @@ async def test_create_text_to_cad_iteration_async():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
def test_create_text_to_cad_multi_file_iteration():
|
||||
# Create our client.
|
||||
client = ClientFromEnv()
|
||||
|
||||
result: Optional[Union[TextToCadMultiFileIteration, Error]] = (
|
||||
create_text_to_cad_multi_file_iteration.sync(
|
||||
client=client,
|
||||
body=TextToCadMultiFileIterationBody(
|
||||
source_ranges=[
|
||||
SourceRangePrompt(
|
||||
prompt="<string>",
|
||||
range=SourceRange(
|
||||
end=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
start=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
if isinstance(result, Error) or result is None:
|
||||
print(result)
|
||||
raise Exception("Error in response")
|
||||
|
||||
body: TextToCadMultiFileIteration = result
|
||||
print(body)
|
||||
|
||||
# OR if you need more info (e.g. status_code)
|
||||
response: Response[Optional[Union[TextToCadMultiFileIteration, Error]]] = (
|
||||
create_text_to_cad_multi_file_iteration.sync_detailed(
|
||||
client=client,
|
||||
body=TextToCadMultiFileIterationBody(
|
||||
source_ranges=[
|
||||
SourceRangePrompt(
|
||||
prompt="<string>",
|
||||
range=SourceRange(
|
||||
end=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
start=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# OR run async
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.skip
|
||||
async def test_create_text_to_cad_multi_file_iteration_async():
|
||||
# Create our client.
|
||||
client = ClientFromEnv()
|
||||
|
||||
result: Optional[
|
||||
Union[TextToCadMultiFileIteration, Error]
|
||||
] = await create_text_to_cad_multi_file_iteration.asyncio(
|
||||
client=client,
|
||||
body=TextToCadMultiFileIterationBody(
|
||||
source_ranges=[
|
||||
SourceRangePrompt(
|
||||
prompt="<string>",
|
||||
range=SourceRange(
|
||||
end=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
start=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
# OR run async with more info
|
||||
response: Response[
|
||||
Optional[Union[TextToCadMultiFileIteration, Error]]
|
||||
] = await create_text_to_cad_multi_file_iteration.asyncio_detailed(
|
||||
client=client,
|
||||
body=TextToCadMultiFileIterationBody(
|
||||
source_ranges=[
|
||||
SourceRangePrompt(
|
||||
prompt="<string>",
|
||||
range=SourceRange(
|
||||
end=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
start=SourcePosition(
|
||||
column=10,
|
||||
line=10,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
def test_get_org():
|
||||
# Create our client.
|
||||
|
||||
@ -312,6 +312,8 @@ from .text_to_cad_create_body import TextToCadCreateBody
|
||||
from .text_to_cad_iteration import TextToCadIteration
|
||||
from .text_to_cad_iteration_body import TextToCadIterationBody
|
||||
from .text_to_cad_model import TextToCadModel
|
||||
from .text_to_cad_multi_file_iteration import TextToCadMultiFileIteration
|
||||
from .text_to_cad_multi_file_iteration_body import TextToCadMultiFileIterationBody
|
||||
from .text_to_cad_results_page import TextToCadResultsPage
|
||||
from .token_revoke_request_form import TokenRevokeRequestForm
|
||||
from .transform import Transform
|
||||
|
||||
@ -290,6 +290,42 @@ class OptionTextToCadIteration(BaseModel):
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
class OptionTextToCadMultiFileIteration(BaseModel):
|
||||
"""Text to CAD multi-file iteration."""
|
||||
|
||||
completed_at: Optional[datetime.datetime] = None
|
||||
|
||||
created_at: datetime.datetime
|
||||
|
||||
error: Optional[str] = None
|
||||
|
||||
feedback: Optional[MlFeedback] = None
|
||||
|
||||
id: Uuid
|
||||
|
||||
model: TextToCadModel
|
||||
|
||||
model_version: str
|
||||
|
||||
outputs: Optional[Dict[str, str]] = None
|
||||
|
||||
source_ranges: List[SourceRangePrompt]
|
||||
|
||||
started_at: Optional[datetime.datetime] = None
|
||||
|
||||
status: ApiCallStatus
|
||||
|
||||
type: Literal["text_to_cad_multi_file_iteration"] = (
|
||||
"text_to_cad_multi_file_iteration"
|
||||
)
|
||||
|
||||
updated_at: datetime.datetime
|
||||
|
||||
user_id: Uuid
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
AsyncApiCallOutput = RootModel[
|
||||
Annotated[
|
||||
Union[
|
||||
@ -301,6 +337,7 @@ AsyncApiCallOutput = RootModel[
|
||||
OptionFileSurfaceArea,
|
||||
OptionTextToCad,
|
||||
OptionTextToCadIteration,
|
||||
OptionTextToCadMultiFileIteration,
|
||||
],
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
@ -20,6 +20,8 @@ class AsyncApiCallType(str, Enum):
|
||||
TEXT_TO_CAD = "text_to_cad"
|
||||
"""# Text to CAD iteration. """ # noqa: E501
|
||||
TEXT_TO_CAD_ITERATION = "text_to_cad_iteration"
|
||||
"""# Text to CAD multi-file iteration. """ # noqa: E501
|
||||
TEXT_TO_CAD_MULTI_FILE_ITERATION = "text_to_cad_multi_file_iteration"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
|
||||
@ -8,8 +8,10 @@ class MlPromptType(str, Enum):
|
||||
TEXT_TO_CAD = "text_to_cad"
|
||||
"""# Text to KCL. """ # noqa: E501
|
||||
TEXT_TO_KCL = "text_to_kcl"
|
||||
"""# Text to Kcl iteration, """ # noqa: E501
|
||||
"""# Text to KCL iteration. """ # noqa: E501
|
||||
TEXT_TO_KCL_ITERATION = "text_to_kcl_iteration"
|
||||
"""# Text to KCL iteration with multiple files. """ # noqa: E501
|
||||
TEXT_TO_KCL_MULTI_FILE_ITERATION = "text_to_kcl_multi_file_iteration"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from ..models.source_range import SourceRange
|
||||
@ -6,6 +8,8 @@ from ..models.source_range import SourceRange
|
||||
class SourceRangePrompt(BaseModel):
|
||||
"""A source range and prompt for a text to CAD iteration."""
|
||||
|
||||
file: Optional[str] = None
|
||||
|
||||
prompt: str
|
||||
|
||||
range: SourceRange
|
||||
|
||||
42
kittycad/models/text_to_cad_multi_file_iteration.py
Normal file
42
kittycad/models/text_to_cad_multi_file_iteration.py
Normal file
@ -0,0 +1,42 @@
|
||||
import datetime
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from ..models.api_call_status import ApiCallStatus
|
||||
from ..models.ml_feedback import MlFeedback
|
||||
from ..models.source_range_prompt import SourceRangePrompt
|
||||
from ..models.text_to_cad_model import TextToCadModel
|
||||
from ..models.uuid import Uuid
|
||||
|
||||
|
||||
class TextToCadMultiFileIteration(BaseModel):
|
||||
"""A response from a text to CAD multi-file iteration."""
|
||||
|
||||
completed_at: Optional[datetime.datetime] = None
|
||||
|
||||
created_at: datetime.datetime
|
||||
|
||||
error: Optional[str] = None
|
||||
|
||||
feedback: Optional[MlFeedback] = None
|
||||
|
||||
id: Uuid
|
||||
|
||||
model: TextToCadModel
|
||||
|
||||
model_version: str
|
||||
|
||||
outputs: Optional[Dict[str, str]] = None
|
||||
|
||||
source_ranges: List[SourceRangePrompt]
|
||||
|
||||
started_at: Optional[datetime.datetime] = None
|
||||
|
||||
status: ApiCallStatus
|
||||
|
||||
updated_at: datetime.datetime
|
||||
|
||||
user_id: Uuid
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
13
kittycad/models/text_to_cad_multi_file_iteration_body.py
Normal file
13
kittycad/models/text_to_cad_multi_file_iteration_body.py
Normal file
@ -0,0 +1,13 @@
|
||||
from typing import List
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from ..models.source_range_prompt import SourceRangePrompt
|
||||
|
||||
|
||||
class TextToCadMultiFileIterationBody(BaseModel):
|
||||
"""Body for generating models from text."""
|
||||
|
||||
source_ranges: List[SourceRangePrompt]
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
Reference in New Issue
Block a user