22
33import typing
44from ...core .client_wrapper import SyncClientWrapper
5- from ...types .netlist import Netlist
6- from ...types .statement_dictionary import StatementDictionary
7- from ...types .computation import Computation
85from ...core .request_options import RequestOptions
9- from ...types .validate_netlist_response import ValidateNetlistResponse
10- from ...core .serialization import convert_and_respect_annotation_metadata
6+ from ...types .parse_statement_response import ParseStatementResponse
117from ...core .pydantic_utilities import parse_obj_as
128from ...errors .unprocessable_entity_error import UnprocessableEntityError
139from ...types .http_validation_error import HttpValidationError
1410from json .decoder import JSONDecodeError
1511from ...core .api_error import ApiError
12+ from ...types .netlist import Netlist
13+ from ...types .statement_dictionary import StatementDictionary
14+ from ...types .computation import Computation
15+ from ...types .validate_netlist_response import ValidateNetlistResponse
16+ from ...core .serialization import convert_and_respect_annotation_metadata
1617from ...types .pdk_type import PdkType
1718from ...types .formalize_circuit_response import FormalizeCircuitResponse
1819from .types .statement import Statement
@@ -38,6 +39,78 @@ class CircuitClient:
3839 def __init__ (self , * , client_wrapper : SyncClientWrapper ):
3940 self ._client_wrapper = client_wrapper
4041
42+ def parse (
43+ self ,
44+ * ,
45+ text : str ,
46+ informalize : typing .Optional [bool ] = OMIT ,
47+ request_options : typing .Optional [RequestOptions ] = None ,
48+ ) -> ParseStatementResponse :
49+ """
50+ Parse a piece of text into a valid formal statement, if possible.
51+
52+ Parameters
53+ ----------
54+ text : str
55+
56+ informalize : typing.Optional[bool]
57+
58+ request_options : typing.Optional[RequestOptions]
59+ Request-specific configuration.
60+
61+ Returns
62+ -------
63+ ParseStatementResponse
64+ Successful Response
65+
66+ Examples
67+ --------
68+ from axiomatic import Axiomatic
69+
70+ client = Axiomatic(
71+ api_key="YOUR_API_KEY",
72+ )
73+ client.pic.circuit.parse(
74+ text="text",
75+ )
76+ """
77+ _response = self ._client_wrapper .httpx_client .request (
78+ "pic/circuit/statement/parse" ,
79+ method = "POST" ,
80+ json = {
81+ "text" : text ,
82+ "informalize" : informalize ,
83+ },
84+ headers = {
85+ "content-type" : "application/json" ,
86+ },
87+ request_options = request_options ,
88+ omit = OMIT ,
89+ )
90+ try :
91+ if 200 <= _response .status_code < 300 :
92+ return typing .cast (
93+ ParseStatementResponse ,
94+ parse_obj_as (
95+ type_ = ParseStatementResponse , # type: ignore
96+ object_ = _response .json (),
97+ ),
98+ )
99+ if _response .status_code == 422 :
100+ raise UnprocessableEntityError (
101+ typing .cast (
102+ HttpValidationError ,
103+ parse_obj_as (
104+ type_ = HttpValidationError , # type: ignore
105+ object_ = _response .json (),
106+ ),
107+ )
108+ )
109+ _response_json = _response .json ()
110+ except JSONDecodeError :
111+ raise ApiError (status_code = _response .status_code , body = _response .text )
112+ raise ApiError (status_code = _response .status_code , body = _response_json )
113+
41114 def validate (
42115 self ,
43116 * ,
@@ -928,6 +1001,86 @@ class AsyncCircuitClient:
9281001 def __init__ (self , * , client_wrapper : AsyncClientWrapper ):
9291002 self ._client_wrapper = client_wrapper
9301003
1004+ async def parse (
1005+ self ,
1006+ * ,
1007+ text : str ,
1008+ informalize : typing .Optional [bool ] = OMIT ,
1009+ request_options : typing .Optional [RequestOptions ] = None ,
1010+ ) -> ParseStatementResponse :
1011+ """
1012+ Parse a piece of text into a valid formal statement, if possible.
1013+
1014+ Parameters
1015+ ----------
1016+ text : str
1017+
1018+ informalize : typing.Optional[bool]
1019+
1020+ request_options : typing.Optional[RequestOptions]
1021+ Request-specific configuration.
1022+
1023+ Returns
1024+ -------
1025+ ParseStatementResponse
1026+ Successful Response
1027+
1028+ Examples
1029+ --------
1030+ import asyncio
1031+
1032+ from axiomatic import AsyncAxiomatic
1033+
1034+ client = AsyncAxiomatic(
1035+ api_key="YOUR_API_KEY",
1036+ )
1037+
1038+
1039+ async def main() -> None:
1040+ await client.pic.circuit.parse(
1041+ text="text",
1042+ )
1043+
1044+
1045+ asyncio.run(main())
1046+ """
1047+ _response = await self ._client_wrapper .httpx_client .request (
1048+ "pic/circuit/statement/parse" ,
1049+ method = "POST" ,
1050+ json = {
1051+ "text" : text ,
1052+ "informalize" : informalize ,
1053+ },
1054+ headers = {
1055+ "content-type" : "application/json" ,
1056+ },
1057+ request_options = request_options ,
1058+ omit = OMIT ,
1059+ )
1060+ try :
1061+ if 200 <= _response .status_code < 300 :
1062+ return typing .cast (
1063+ ParseStatementResponse ,
1064+ parse_obj_as (
1065+ type_ = ParseStatementResponse , # type: ignore
1066+ object_ = _response .json (),
1067+ ),
1068+ )
1069+ if _response .status_code == 422 :
1070+ raise UnprocessableEntityError (
1071+ typing .cast (
1072+ HttpValidationError ,
1073+ parse_obj_as (
1074+ type_ = HttpValidationError , # type: ignore
1075+ object_ = _response .json (),
1076+ ),
1077+ )
1078+ )
1079+ _response_json = _response .json ()
1080+ except JSONDecodeError :
1081+ raise ApiError (status_code = _response .status_code , body = _response .text )
1082+ raise ApiError (status_code = _response .status_code , body = _response_json )
1083+
9311084 async def validate (
9321085 self ,
9331086 * ,
0 commit comments