@ -51,7 +51,7 @@ def _get_kwargs(
|
|||||||
"headers": headers,
|
"headers": headers,
|
||||||
"cookies": cookies,
|
"cookies": cookies,
|
||||||
"timeout": client.get_timeout(),
|
"timeout": client.get_timeout(),
|
||||||
{% if has_request_body %}"content": body,{% endif %}
|
{% if has_request_body %}{% if request_body_type != "bytes" %}"content": body.model_dump_json(),{% else %}"content": body,{% endif %}{% endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -705,6 +705,7 @@ async def test_"""
|
|||||||
"docs": str,
|
"docs": str,
|
||||||
"parse_response": str,
|
"parse_response": str,
|
||||||
"has_request_body": bool,
|
"has_request_body": bool,
|
||||||
|
"request_body_type": str,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
template_info: TemplateType = {
|
template_info: TemplateType = {
|
||||||
@ -716,6 +717,7 @@ async def test_"""
|
|||||||
"docs": "",
|
"docs": "",
|
||||||
"parse_response": "",
|
"parse_response": "",
|
||||||
"has_request_body": False,
|
"has_request_body": False,
|
||||||
|
"request_body_type": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(endpoint_refs) == 0:
|
if len(endpoint_refs) == 0:
|
||||||
@ -954,6 +956,7 @@ async def test_"""
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
template_info["has_request_body"] = True
|
template_info["has_request_body"] = True
|
||||||
|
template_info["request_body_type"] = request_body_type
|
||||||
|
|
||||||
# Generate the template for the functions.
|
# Generate the template for the functions.
|
||||||
environment = jinja2.Environment(loader=jinja2.FileSystemLoader("generate/"))
|
environment = jinja2.Environment(loader=jinja2.FileSystemLoader("generate/"))
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ def _get_kwargs(
|
|||||||
"headers": headers,
|
"headers": headers,
|
||||||
"cookies": cookies,
|
"cookies": cookies,
|
||||||
"timeout": client.get_timeout(),
|
"timeout": client.get_timeout(),
|
||||||
"content": body,
|
"content": body.model_dump_json(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ def _get_kwargs(
|
|||||||
"headers": headers,
|
"headers": headers,
|
||||||
"cookies": cookies,
|
"cookies": cookies,
|
||||||
"timeout": client.get_timeout(),
|
"timeout": client.get_timeout(),
|
||||||
"content": body,
|
"content": body.model_dump_json(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ def _get_kwargs(
|
|||||||
"headers": headers,
|
"headers": headers,
|
||||||
"cookies": cookies,
|
"cookies": cookies,
|
||||||
"timeout": client.get_timeout(),
|
"timeout": client.get_timeout(),
|
||||||
"content": body,
|
"content": body.model_dump_json(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ def _get_kwargs(
|
|||||||
"headers": headers,
|
"headers": headers,
|
||||||
"cookies": cookies,
|
"cookies": cookies,
|
||||||
"timeout": client.get_timeout(),
|
"timeout": client.get_timeout(),
|
||||||
"content": body,
|
"content": body.model_dump_json(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ def _get_kwargs(
|
|||||||
"headers": headers,
|
"headers": headers,
|
||||||
"cookies": cookies,
|
"cookies": cookies,
|
||||||
"timeout": client.get_timeout(),
|
"timeout": client.get_timeout(),
|
||||||
"content": body,
|
"content": body.model_dump_json(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from .api.ai import create_text_to_cad, get_text_to_cad_model_for_user
|
||||||
from .api.api_tokens import list_api_tokens_for_user
|
from .api.api_tokens import list_api_tokens_for_user
|
||||||
from .api.file import create_file_conversion, create_file_mass, create_file_volume
|
from .api.file import create_file_conversion, create_file_mass, create_file_volume
|
||||||
from .api.meta import ping
|
from .api.meta import ping
|
||||||
@ -32,6 +34,8 @@ from .models import (
|
|||||||
ModelingCmdId,
|
ModelingCmdId,
|
||||||
Pong,
|
Pong,
|
||||||
System,
|
System,
|
||||||
|
TextToCad,
|
||||||
|
TextToCadCreateBody,
|
||||||
UnitDensity,
|
UnitDensity,
|
||||||
UnitLength,
|
UnitLength,
|
||||||
UnitMass,
|
UnitMass,
|
||||||
@ -489,3 +493,43 @@ def test_serialize_deserialize():
|
|||||||
assert model_dump["resp"]["type"] == "modeling" # type: ignore
|
assert model_dump["resp"]["type"] == "modeling" # type: ignore
|
||||||
assert model_dump["resp"]["data"]["modeling_response"]["type"] == "import_files" # type: ignore
|
assert model_dump["resp"]["data"]["modeling_response"]["type"] == "import_files" # type: ignore
|
||||||
assert model_dump["resp"]["data"]["modeling_response"]["data"]["object_id"] == "f61ac02e-77bd-468f-858f-fd4141a26acd" # type: ignore
|
assert model_dump["resp"]["data"]["modeling_response"]["data"]["object_id"] == "f61ac02e-77bd-468f-858f-fd4141a26acd" # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
def test_text_to_cad():
|
||||||
|
# Create our client.
|
||||||
|
client = ClientFromEnv()
|
||||||
|
|
||||||
|
result: Optional[Union[TextToCad, Error]] = create_text_to_cad.sync(
|
||||||
|
client=client,
|
||||||
|
output_format=FileExportFormat.FBX,
|
||||||
|
body=TextToCadCreateBody(
|
||||||
|
prompt="a 2x4 lego",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if isinstance(result, Error) or result is None:
|
||||||
|
print(result)
|
||||||
|
raise Exception("Error in response")
|
||||||
|
|
||||||
|
body: TextToCad = result
|
||||||
|
|
||||||
|
# Poll the api until the status is completed.
|
||||||
|
# Timeout after 30 seconds.
|
||||||
|
start_time = time.time()
|
||||||
|
while (
|
||||||
|
body.status == ApiCallStatus.IN_PROGRESS or body.status == ApiCallStatus.QUEUED
|
||||||
|
) and time.time() - start_time < 30:
|
||||||
|
result_status: Optional[
|
||||||
|
Union[TextToCad, Error]
|
||||||
|
] = get_text_to_cad_model_for_user.sync(
|
||||||
|
client=client,
|
||||||
|
id=body.id,
|
||||||
|
)
|
||||||
|
|
||||||
|
if isinstance(result_status, Error) or result_status is None:
|
||||||
|
print(result_status)
|
||||||
|
raise Exception("Error in response")
|
||||||
|
|
||||||
|
body = result_status
|
||||||
|
|
||||||
|
assert body.status == ApiCallStatus.COMPLETED
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "kittycad"
|
name = "kittycad"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
description = "A client library for accessing KittyCAD"
|
description = "A client library for accessing KittyCAD"
|
||||||
|
|
||||||
authors = []
|
authors = []
|
||||||
|
Reference in New Issue
Block a user