2
2
3
3
import typing
4
4
from ...core .client_wrapper import SyncClientWrapper
5
- from ...types .netlist import Netlist
6
- from ...types .statement_dictionary import StatementDictionary
7
- from ...types .computation import Computation
8
5
from ...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
11
7
from ...core .pydantic_utilities import parse_obj_as
12
8
from ...errors .unprocessable_entity_error import UnprocessableEntityError
13
9
from ...types .http_validation_error import HttpValidationError
14
10
from json .decoder import JSONDecodeError
15
11
from ...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
16
17
from ...types .pdk_type import PdkType
17
18
from ...types .formalize_circuit_response import FormalizeCircuitResponse
18
19
from .types .statement import Statement
@@ -38,6 +39,78 @@ class CircuitClient:
38
39
def __init__ (self , * , client_wrapper : SyncClientWrapper ):
39
40
self ._client_wrapper = client_wrapper
40
41
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
+
41
114
def validate (
42
115
self ,
43
116
* ,
@@ -928,6 +1001,86 @@ class AsyncCircuitClient:
928
1001
def __init__ (self , * , client_wrapper : AsyncClientWrapper ):
929
1002
self ._client_wrapper = client_wrapper
930
1003
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
+
931
1084
async def validate (
932
1085
self ,
933
1086
* ,
0 commit comments