@ -51,7 +51,7 @@ def _get_kwargs(
 | 
			
		||||
        "headers": headers,
 | 
			
		||||
        "cookies": cookies,
 | 
			
		||||
        "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,
 | 
			
		||||
            "parse_response": str,
 | 
			
		||||
            "has_request_body": bool,
 | 
			
		||||
            "request_body_type": str,
 | 
			
		||||
        },
 | 
			
		||||
    )
 | 
			
		||||
    template_info: TemplateType = {
 | 
			
		||||
@ -716,6 +717,7 @@ async def test_"""
 | 
			
		||||
        "docs": "",
 | 
			
		||||
        "parse_response": "",
 | 
			
		||||
        "has_request_body": False,
 | 
			
		||||
        "request_body_type": "",
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if len(endpoint_refs) == 0:
 | 
			
		||||
@ -954,6 +956,7 @@ async def test_"""
 | 
			
		||||
            }
 | 
			
		||||
        )
 | 
			
		||||
        template_info["has_request_body"] = True
 | 
			
		||||
        template_info["request_body_type"] = request_body_type
 | 
			
		||||
 | 
			
		||||
    # Generate the template for the functions.
 | 
			
		||||
    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,
 | 
			
		||||
        "cookies": cookies,
 | 
			
		||||
        "timeout": client.get_timeout(),
 | 
			
		||||
        "content": body,
 | 
			
		||||
        "content": body.model_dump_json(),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ def _get_kwargs(
 | 
			
		||||
        "headers": headers,
 | 
			
		||||
        "cookies": cookies,
 | 
			
		||||
        "timeout": client.get_timeout(),
 | 
			
		||||
        "content": body,
 | 
			
		||||
        "content": body.model_dump_json(),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ def _get_kwargs(
 | 
			
		||||
        "headers": headers,
 | 
			
		||||
        "cookies": cookies,
 | 
			
		||||
        "timeout": client.get_timeout(),
 | 
			
		||||
        "content": body,
 | 
			
		||||
        "content": body.model_dump_json(),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ def _get_kwargs(
 | 
			
		||||
        "headers": headers,
 | 
			
		||||
        "cookies": cookies,
 | 
			
		||||
        "timeout": client.get_timeout(),
 | 
			
		||||
        "content": body,
 | 
			
		||||
        "content": body.model_dump_json(),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ def _get_kwargs(
 | 
			
		||||
        "headers": headers,
 | 
			
		||||
        "cookies": cookies,
 | 
			
		||||
        "timeout": client.get_timeout(),
 | 
			
		||||
        "content": body,
 | 
			
		||||
        "content": body.model_dump_json(),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,12 @@
 | 
			
		||||
import json
 | 
			
		||||
import os
 | 
			
		||||
import time
 | 
			
		||||
import uuid
 | 
			
		||||
from typing import Optional, Union
 | 
			
		||||
 | 
			
		||||
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.file import create_file_conversion, create_file_mass, create_file_volume
 | 
			
		||||
from .api.meta import ping
 | 
			
		||||
@ -32,6 +34,8 @@ from .models import (
 | 
			
		||||
    ModelingCmdId,
 | 
			
		||||
    Pong,
 | 
			
		||||
    System,
 | 
			
		||||
    TextToCad,
 | 
			
		||||
    TextToCadCreateBody,
 | 
			
		||||
    UnitDensity,
 | 
			
		||||
    UnitLength,
 | 
			
		||||
    UnitMass,
 | 
			
		||||
@ -489,3 +493,43 @@ def test_serialize_deserialize():
 | 
			
		||||
    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"]["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]
 | 
			
		||||
name = "kittycad"
 | 
			
		||||
version = "0.6.0"
 | 
			
		||||
version = "0.6.1"
 | 
			
		||||
description = "A client library for accessing KittyCAD"
 | 
			
		||||
 | 
			
		||||
authors = []
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user