phenoml 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of phenoml might be problematic. Click here for more details.

Files changed (143) hide show
  1. phenoml/__init__.py +30 -0
  2. phenoml/agent/__init__.py +58 -0
  3. phenoml/agent/client.py +820 -0
  4. phenoml/agent/errors/__init__.py +11 -0
  5. phenoml/agent/errors/bad_request_error.py +10 -0
  6. phenoml/agent/errors/forbidden_error.py +10 -0
  7. phenoml/agent/errors/internal_server_error.py +10 -0
  8. phenoml/agent/errors/not_found_error.py +10 -0
  9. phenoml/agent/errors/unauthorized_error.py +10 -0
  10. phenoml/agent/prompts/__init__.py +7 -0
  11. phenoml/agent/prompts/client.py +707 -0
  12. phenoml/agent/prompts/raw_client.py +1345 -0
  13. phenoml/agent/prompts/types/__init__.py +8 -0
  14. phenoml/agent/prompts/types/prompts_delete_response.py +20 -0
  15. phenoml/agent/prompts/types/prompts_list_response.py +22 -0
  16. phenoml/agent/raw_client.py +1501 -0
  17. phenoml/agent/types/__init__.py +45 -0
  18. phenoml/agent/types/agent_chat_response.py +33 -0
  19. phenoml/agent/types/agent_create_request_provider.py +13 -0
  20. phenoml/agent/types/agent_create_request_provider_item.py +7 -0
  21. phenoml/agent/types/agent_delete_response.py +20 -0
  22. phenoml/agent/types/agent_fhir_config.py +31 -0
  23. phenoml/agent/types/agent_list_response.py +22 -0
  24. phenoml/agent/types/agent_prompts_response.py +22 -0
  25. phenoml/agent/types/agent_response.py +22 -0
  26. phenoml/agent/types/agent_template.py +56 -0
  27. phenoml/agent/types/agent_template_provider.py +13 -0
  28. phenoml/agent/types/agent_template_provider_item.py +5 -0
  29. phenoml/agent/types/agent_update_request_provider.py +13 -0
  30. phenoml/agent/types/agent_update_request_provider_item.py +7 -0
  31. phenoml/agent/types/chat_fhir_client_config.py +31 -0
  32. phenoml/agent/types/json_patch.py +7 -0
  33. phenoml/agent/types/json_patch_operation.py +36 -0
  34. phenoml/agent/types/json_patch_operation_op.py +5 -0
  35. phenoml/agent/types/prompt_template.py +52 -0
  36. phenoml/agent/types/success_response.py +20 -0
  37. phenoml/authtoken/__init__.py +17 -0
  38. phenoml/authtoken/auth/__init__.py +7 -0
  39. phenoml/authtoken/auth/client.py +129 -0
  40. phenoml/authtoken/auth/raw_client.py +173 -0
  41. phenoml/authtoken/auth/types/__init__.py +7 -0
  42. phenoml/authtoken/auth/types/auth_generate_token_response.py +22 -0
  43. phenoml/authtoken/client.py +39 -0
  44. phenoml/authtoken/errors/__init__.py +8 -0
  45. phenoml/authtoken/errors/bad_request_error.py +10 -0
  46. phenoml/authtoken/errors/unauthorized_error.py +10 -0
  47. phenoml/authtoken/raw_client.py +13 -0
  48. phenoml/authtoken/types/__init__.py +8 -0
  49. phenoml/authtoken/types/bad_request_error_body.py +21 -0
  50. phenoml/authtoken/types/unauthorized_error_body.py +21 -0
  51. phenoml/client.py +168 -0
  52. phenoml/cohort/__init__.py +8 -0
  53. phenoml/cohort/client.py +113 -0
  54. phenoml/cohort/errors/__init__.py +9 -0
  55. phenoml/cohort/errors/bad_request_error.py +10 -0
  56. phenoml/cohort/errors/internal_server_error.py +10 -0
  57. phenoml/cohort/errors/unauthorized_error.py +10 -0
  58. phenoml/cohort/raw_client.py +185 -0
  59. phenoml/cohort/types/__init__.py +8 -0
  60. phenoml/cohort/types/cohort_response.py +33 -0
  61. phenoml/cohort/types/search_concept.py +37 -0
  62. phenoml/construe/__init__.py +45 -0
  63. phenoml/construe/client.py +399 -0
  64. phenoml/construe/errors/__init__.py +11 -0
  65. phenoml/construe/errors/bad_request_error.py +10 -0
  66. phenoml/construe/errors/conflict_error.py +10 -0
  67. phenoml/construe/errors/failed_dependency_error.py +10 -0
  68. phenoml/construe/errors/internal_server_error.py +10 -0
  69. phenoml/construe/errors/unauthorized_error.py +10 -0
  70. phenoml/construe/raw_client.py +706 -0
  71. phenoml/construe/types/__init__.py +41 -0
  72. phenoml/construe/types/bad_request_error_body.py +27 -0
  73. phenoml/construe/types/construe_cohort_request_config.py +37 -0
  74. phenoml/construe/types/construe_cohort_response.py +33 -0
  75. phenoml/construe/types/construe_cohort_response_queries_item.py +49 -0
  76. phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item.py +31 -0
  77. phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py +32 -0
  78. phenoml/construe/types/construe_upload_code_system_response.py +19 -0
  79. phenoml/construe/types/extract_codes_result.py +22 -0
  80. phenoml/construe/types/extract_request_config.py +23 -0
  81. phenoml/construe/types/extract_request_config_chunking_method.py +5 -0
  82. phenoml/construe/types/extract_request_system.py +37 -0
  83. phenoml/construe/types/extracted_code_result.py +41 -0
  84. phenoml/construe/types/internal_server_error_body.py +27 -0
  85. phenoml/construe/types/unauthorized_error_body.py +27 -0
  86. phenoml/construe/types/upload_request_format.py +5 -0
  87. phenoml/core/__init__.py +52 -0
  88. phenoml/core/api_error.py +23 -0
  89. phenoml/core/client_wrapper.py +85 -0
  90. phenoml/core/datetime_utils.py +28 -0
  91. phenoml/core/file.py +67 -0
  92. phenoml/core/force_multipart.py +16 -0
  93. phenoml/core/http_client.py +543 -0
  94. phenoml/core/http_response.py +55 -0
  95. phenoml/core/jsonable_encoder.py +100 -0
  96. phenoml/core/pydantic_utilities.py +255 -0
  97. phenoml/core/query_encoder.py +58 -0
  98. phenoml/core/remove_none_from_dict.py +11 -0
  99. phenoml/core/request_options.py +35 -0
  100. phenoml/core/serialization.py +276 -0
  101. phenoml/environment.py +7 -0
  102. phenoml/lang2fhir/__init__.py +27 -0
  103. phenoml/lang2fhir/client.py +430 -0
  104. phenoml/lang2fhir/errors/__init__.py +11 -0
  105. phenoml/lang2fhir/errors/bad_request_error.py +10 -0
  106. phenoml/lang2fhir/errors/failed_dependency_error.py +10 -0
  107. phenoml/lang2fhir/errors/forbidden_error.py +10 -0
  108. phenoml/lang2fhir/errors/internal_server_error.py +10 -0
  109. phenoml/lang2fhir/errors/unauthorized_error.py +10 -0
  110. phenoml/lang2fhir/raw_client.py +788 -0
  111. phenoml/lang2fhir/types/__init__.py +19 -0
  112. phenoml/lang2fhir/types/create_request_resource.py +25 -0
  113. phenoml/lang2fhir/types/document_request_file_type.py +7 -0
  114. phenoml/lang2fhir/types/document_request_resource.py +5 -0
  115. phenoml/lang2fhir/types/fhir_resource.py +5 -0
  116. phenoml/lang2fhir/types/lang2fhir_upload_profile_response.py +23 -0
  117. phenoml/lang2fhir/types/search_response.py +33 -0
  118. phenoml/py.typed +0 -0
  119. phenoml/tools/__init__.py +33 -0
  120. phenoml/tools/client.py +392 -0
  121. phenoml/tools/errors/__init__.py +11 -0
  122. phenoml/tools/errors/bad_request_error.py +10 -0
  123. phenoml/tools/errors/failed_dependency_error.py +10 -0
  124. phenoml/tools/errors/forbidden_error.py +10 -0
  125. phenoml/tools/errors/internal_server_error.py +10 -0
  126. phenoml/tools/errors/unauthorized_error.py +10 -0
  127. phenoml/tools/raw_client.py +745 -0
  128. phenoml/tools/types/__init__.py +25 -0
  129. phenoml/tools/types/cohort_request_provider.py +5 -0
  130. phenoml/tools/types/cohort_response.py +49 -0
  131. phenoml/tools/types/fhir_client_config.py +31 -0
  132. phenoml/tools/types/lang2fhir_and_create_request_provider.py +7 -0
  133. phenoml/tools/types/lang2fhir_and_create_request_resource.py +25 -0
  134. phenoml/tools/types/lang2fhir_and_create_response.py +33 -0
  135. phenoml/tools/types/lang2fhir_and_search_request_provider.py +7 -0
  136. phenoml/tools/types/lang2fhir_and_search_response.py +40 -0
  137. phenoml/tools/types/search_concept.py +41 -0
  138. phenoml/version.py +3 -0
  139. phenoml/wrapper_client.py +123 -0
  140. phenoml-0.0.1.dist-info/LICENSE +21 -0
  141. phenoml-0.0.1.dist-info/METADATA +192 -0
  142. phenoml-0.0.1.dist-info/RECORD +143 -0
  143. phenoml-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,41 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .bad_request_error_body import BadRequestErrorBody
6
+ from .construe_cohort_request_config import ConstrueCohortRequestConfig
7
+ from .construe_cohort_response import ConstrueCohortResponse
8
+ from .construe_cohort_response_queries_item import ConstrueCohortResponseQueriesItem
9
+ from .construe_cohort_response_queries_item_code_extract_results_item import (
10
+ ConstrueCohortResponseQueriesItemCodeExtractResultsItem,
11
+ )
12
+ from .construe_cohort_response_queries_item_code_extract_results_item_codes_item import (
13
+ ConstrueCohortResponseQueriesItemCodeExtractResultsItemCodesItem,
14
+ )
15
+ from .construe_upload_code_system_response import ConstrueUploadCodeSystemResponse
16
+ from .extract_codes_result import ExtractCodesResult
17
+ from .extract_request_config import ExtractRequestConfig
18
+ from .extract_request_config_chunking_method import ExtractRequestConfigChunkingMethod
19
+ from .extract_request_system import ExtractRequestSystem
20
+ from .extracted_code_result import ExtractedCodeResult
21
+ from .internal_server_error_body import InternalServerErrorBody
22
+ from .unauthorized_error_body import UnauthorizedErrorBody
23
+ from .upload_request_format import UploadRequestFormat
24
+
25
+ __all__ = [
26
+ "BadRequestErrorBody",
27
+ "ConstrueCohortRequestConfig",
28
+ "ConstrueCohortResponse",
29
+ "ConstrueCohortResponseQueriesItem",
30
+ "ConstrueCohortResponseQueriesItemCodeExtractResultsItem",
31
+ "ConstrueCohortResponseQueriesItemCodeExtractResultsItemCodesItem",
32
+ "ConstrueUploadCodeSystemResponse",
33
+ "ExtractCodesResult",
34
+ "ExtractRequestConfig",
35
+ "ExtractRequestConfigChunkingMethod",
36
+ "ExtractRequestSystem",
37
+ "ExtractedCodeResult",
38
+ "InternalServerErrorBody",
39
+ "UnauthorizedErrorBody",
40
+ "UploadRequestFormat",
41
+ ]
@@ -0,0 +1,27 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class BadRequestErrorBody(UniversalBaseModel):
10
+ status: typing.Optional[int] = pydantic.Field(default=None)
11
+ """
12
+ HTTP status code.
13
+ """
14
+
15
+ message: typing.Optional[str] = pydantic.Field(default=None)
16
+ """
17
+ Error message.
18
+ """
19
+
20
+ if IS_PYDANTIC_V2:
21
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
22
+ else:
23
+
24
+ class Config:
25
+ frozen = True
26
+ smart_union = True
27
+ extra = pydantic.Extra.allow
@@ -0,0 +1,37 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class ConstrueCohortRequestConfig(UniversalBaseModel):
10
+ include_extract_results: typing.Optional[bool] = pydantic.Field(default=None)
11
+ """
12
+ When enabled, includes detailed information about medical codes extracted from the text.
13
+ """
14
+
15
+ include_rationale: typing.Optional[bool] = pydantic.Field(default=None)
16
+ """
17
+ When enabled, includes AI-generated explanations for each query component and code extraction.
18
+ """
19
+
20
+ exclude_deceased: typing.Optional[bool] = pydantic.Field(default=None)
21
+ """
22
+ Controls whether deceased patients should be excluded from the cohort.
23
+ """
24
+
25
+ sql_syntax: typing.Optional[typing.Literal["bigquery"]] = pydantic.Field(default=None)
26
+ """
27
+ Specifies the SQL dialect for query generation. Currently, only "bigquery" is supported.
28
+ """
29
+
30
+ if IS_PYDANTIC_V2:
31
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
32
+ else:
33
+
34
+ class Config:
35
+ frozen = True
36
+ smart_union = True
37
+ extra = pydantic.Extra.allow
@@ -0,0 +1,33 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ import typing_extensions
7
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from ...core.serialization import FieldMetadata
9
+ from .construe_cohort_response_queries_item import ConstrueCohortResponseQueriesItem
10
+
11
+
12
+ class ConstrueCohortResponse(UniversalBaseModel):
13
+ queries: typing.Optional[typing.List[ConstrueCohortResponseQueriesItem]] = None
14
+ sql: typing.Optional[str] = pydantic.Field(default=None)
15
+ """
16
+ Generated SQL query when `sql_syntax` is specified. Variables in curly braces need to be replaced with your actual table names.
17
+ """
18
+
19
+ cohort_description: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="cohortDescription")] = (
20
+ pydantic.Field(default=None)
21
+ )
22
+ """
23
+ Echo of the input text description for reference.
24
+ """
25
+
26
+ if IS_PYDANTIC_V2:
27
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
28
+ else:
29
+
30
+ class Config:
31
+ frozen = True
32
+ smart_union = True
33
+ extra = pydantic.Extra.allow
@@ -0,0 +1,49 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ import typing_extensions
7
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from ...core.serialization import FieldMetadata
9
+ from .construe_cohort_response_queries_item_code_extract_results_item import (
10
+ ConstrueCohortResponseQueriesItemCodeExtractResultsItem,
11
+ )
12
+
13
+
14
+ class ConstrueCohortResponseQueriesItem(UniversalBaseModel):
15
+ resource: typing.Optional[str] = pydantic.Field(default=None)
16
+ """
17
+ FHIR resource type (e.g., "Patient", "Condition").
18
+ """
19
+
20
+ search_params: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="searchParams")] = (
21
+ pydantic.Field(default=None)
22
+ )
23
+ """
24
+ FHIR search parameters.
25
+ """
26
+
27
+ exclude: typing.Optional[bool] = pydantic.Field(default=None)
28
+ """
29
+ Indicates if this is an exclusion criteria.
30
+ """
31
+
32
+ rationale: typing.Optional[str] = pydantic.Field(default=None)
33
+ """
34
+ AI-generated explanation for the query component.
35
+ """
36
+
37
+ code_extract_results: typing_extensions.Annotated[
38
+ typing.Optional[typing.List[ConstrueCohortResponseQueriesItemCodeExtractResultsItem]],
39
+ FieldMetadata(alias="codeExtractResults"),
40
+ ] = None
41
+
42
+ if IS_PYDANTIC_V2:
43
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
44
+ else:
45
+
46
+ class Config:
47
+ frozen = True
48
+ smart_union = True
49
+ extra = pydantic.Extra.allow
@@ -0,0 +1,31 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ import typing_extensions
7
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from ...core.serialization import FieldMetadata
9
+ from .construe_cohort_response_queries_item_code_extract_results_item_codes_item import (
10
+ ConstrueCohortResponseQueriesItemCodeExtractResultsItemCodesItem,
11
+ )
12
+
13
+
14
+ class ConstrueCohortResponseQueriesItemCodeExtractResultsItem(UniversalBaseModel):
15
+ system_name: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="systemName")] = pydantic.Field(
16
+ default=None
17
+ )
18
+ """
19
+ Name of the coding system (e.g., "SNOMED_CT_US_LITE").
20
+ """
21
+
22
+ codes: typing.Optional[typing.List[ConstrueCohortResponseQueriesItemCodeExtractResultsItemCodesItem]] = None
23
+
24
+ if IS_PYDANTIC_V2:
25
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
26
+ else:
27
+
28
+ class Config:
29
+ frozen = True
30
+ smart_union = True
31
+ extra = pydantic.Extra.allow
@@ -0,0 +1,32 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class ConstrueCohortResponseQueriesItemCodeExtractResultsItemCodesItem(UniversalBaseModel):
10
+ code: typing.Optional[str] = pydantic.Field(default=None)
11
+ """
12
+ Medical code.
13
+ """
14
+
15
+ description: typing.Optional[str] = pydantic.Field(default=None)
16
+ """
17
+ Description of the medical code.
18
+ """
19
+
20
+ reason: typing.Optional[str] = pydantic.Field(default=None)
21
+ """
22
+ Reason for selecting the code.
23
+ """
24
+
25
+ if IS_PYDANTIC_V2:
26
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
27
+ else:
28
+
29
+ class Config:
30
+ frozen = True
31
+ smart_union = True
32
+ extra = pydantic.Extra.allow
@@ -0,0 +1,19 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class ConstrueUploadCodeSystemResponse(UniversalBaseModel):
10
+ status: typing.Optional[str] = None
11
+
12
+ if IS_PYDANTIC_V2:
13
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
14
+ else:
15
+
16
+ class Config:
17
+ frozen = True
18
+ smart_union = True
19
+ extra = pydantic.Extra.allow
@@ -0,0 +1,22 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .extract_request_system import ExtractRequestSystem
8
+ from .extracted_code_result import ExtractedCodeResult
9
+
10
+
11
+ class ExtractCodesResult(UniversalBaseModel):
12
+ system: ExtractRequestSystem
13
+ codes: typing.List[ExtractedCodeResult]
14
+
15
+ if IS_PYDANTIC_V2:
16
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17
+ else:
18
+
19
+ class Config:
20
+ frozen = True
21
+ smart_union = True
22
+ extra = pydantic.Extra.allow
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .extract_request_config_chunking_method import ExtractRequestConfigChunkingMethod
8
+
9
+
10
+ class ExtractRequestConfig(UniversalBaseModel):
11
+ chunking_method: typing.Optional[ExtractRequestConfigChunkingMethod] = None
12
+ max_codes_per_chunk: typing.Optional[int] = None
13
+ code_similarity_filter: typing.Optional[float] = None
14
+ include_rationale: typing.Optional[bool] = None
15
+
16
+ if IS_PYDANTIC_V2:
17
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
18
+ else:
19
+
20
+ class Config:
21
+ frozen = True
22
+ smart_union = True
23
+ extra = pydantic.Extra.allow
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ExtractRequestConfigChunkingMethod = typing.Union[typing.Literal["none", "sentence", "paragraph", "topics"], typing.Any]
@@ -0,0 +1,37 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class ExtractRequestSystem(UniversalBaseModel):
10
+ name: typing.Optional[str] = pydantic.Field(default=None)
11
+ """
12
+ Code system name. Can be a built-in system or a custom system name.
13
+
14
+ Built-in systems:
15
+ * SNOMED_CT_US_LITE - version 20240901
16
+ * RXNORM - version 11042024
17
+ * ICD-10-CM - version 2025
18
+ * ICD-10-PCS - version 2025
19
+ * LOINC - version 2.78
20
+
21
+ Custom systems:
22
+ * Any valid system name configured in your environment. Must have self-hosted construe module.
23
+ """
24
+
25
+ version: typing.Optional[str] = pydantic.Field(default=None)
26
+ """
27
+ Code system version. Must match the version available in your environment.
28
+ """
29
+
30
+ if IS_PYDANTIC_V2:
31
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
32
+ else:
33
+
34
+ class Config:
35
+ frozen = True
36
+ smart_union = True
37
+ extra = pydantic.Extra.allow
@@ -0,0 +1,41 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ import typing_extensions
7
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from ...core.serialization import FieldMetadata
9
+
10
+
11
+ class ExtractedCodeResult(UniversalBaseModel):
12
+ code: str = pydantic.Field()
13
+ """
14
+ The extracted code
15
+ """
16
+
17
+ description: str = pydantic.Field()
18
+ """
19
+ Short description of the code
20
+ """
21
+
22
+ long_description: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="longDescription")] = (
23
+ pydantic.Field(default=None)
24
+ )
25
+ """
26
+ Long description of the code
27
+ """
28
+
29
+ rationale: typing.Optional[str] = pydantic.Field(default=None)
30
+ """
31
+ Explanation for why this code was extracted (if include_rationale is true)
32
+ """
33
+
34
+ if IS_PYDANTIC_V2:
35
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
36
+ else:
37
+
38
+ class Config:
39
+ frozen = True
40
+ smart_union = True
41
+ extra = pydantic.Extra.allow
@@ -0,0 +1,27 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class InternalServerErrorBody(UniversalBaseModel):
10
+ status: typing.Optional[int] = pydantic.Field(default=None)
11
+ """
12
+ HTTP status code.
13
+ """
14
+
15
+ message: typing.Optional[str] = pydantic.Field(default=None)
16
+ """
17
+ Error message.
18
+ """
19
+
20
+ if IS_PYDANTIC_V2:
21
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
22
+ else:
23
+
24
+ class Config:
25
+ frozen = True
26
+ smart_union = True
27
+ extra = pydantic.Extra.allow
@@ -0,0 +1,27 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class UnauthorizedErrorBody(UniversalBaseModel):
10
+ status: typing.Optional[int] = pydantic.Field(default=None)
11
+ """
12
+ HTTP status code.
13
+ """
14
+
15
+ message: typing.Optional[str] = pydantic.Field(default=None)
16
+ """
17
+ Error message.
18
+ """
19
+
20
+ if IS_PYDANTIC_V2:
21
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
22
+ else:
23
+
24
+ class Config:
25
+ frozen = True
26
+ smart_union = True
27
+ extra = pydantic.Extra.allow
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ UploadRequestFormat = typing.Union[typing.Literal["json", "csv"], typing.Any]
@@ -0,0 +1,52 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .api_error import ApiError
6
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
7
+ from .datetime_utils import serialize_datetime
8
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
9
+ from .http_client import AsyncHttpClient, HttpClient
10
+ from .http_response import AsyncHttpResponse, HttpResponse
11
+ from .jsonable_encoder import jsonable_encoder
12
+ from .pydantic_utilities import (
13
+ IS_PYDANTIC_V2,
14
+ UniversalBaseModel,
15
+ UniversalRootModel,
16
+ parse_obj_as,
17
+ universal_field_validator,
18
+ universal_root_validator,
19
+ update_forward_refs,
20
+ )
21
+ from .query_encoder import encode_query
22
+ from .remove_none_from_dict import remove_none_from_dict
23
+ from .request_options import RequestOptions
24
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
25
+
26
+ __all__ = [
27
+ "ApiError",
28
+ "AsyncClientWrapper",
29
+ "AsyncHttpClient",
30
+ "AsyncHttpResponse",
31
+ "BaseClientWrapper",
32
+ "FieldMetadata",
33
+ "File",
34
+ "HttpClient",
35
+ "HttpResponse",
36
+ "IS_PYDANTIC_V2",
37
+ "RequestOptions",
38
+ "SyncClientWrapper",
39
+ "UniversalBaseModel",
40
+ "UniversalRootModel",
41
+ "convert_and_respect_annotation_metadata",
42
+ "convert_file_dict_to_httpx_tuples",
43
+ "encode_query",
44
+ "jsonable_encoder",
45
+ "parse_obj_as",
46
+ "remove_none_from_dict",
47
+ "serialize_datetime",
48
+ "universal_field_validator",
49
+ "universal_root_validator",
50
+ "update_forward_refs",
51
+ "with_content_type",
52
+ ]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,85 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .http_client import AsyncHttpClient, HttpClient
7
+
8
+
9
+ class BaseClientWrapper:
10
+ def __init__(
11
+ self,
12
+ *,
13
+ token: typing.Union[str, typing.Callable[[], str]],
14
+ headers: typing.Optional[typing.Dict[str, str]] = None,
15
+ base_url: str,
16
+ timeout: typing.Optional[float] = None,
17
+ ):
18
+ self._token = token
19
+ self._headers = headers
20
+ self._base_url = base_url
21
+ self._timeout = timeout
22
+
23
+ def get_headers(self) -> typing.Dict[str, str]:
24
+ headers: typing.Dict[str, str] = {
25
+ "User-Agent": "phenoml/0.0.1",
26
+ "X-Fern-Language": "Python",
27
+ "X-Fern-SDK-Name": "phenoml",
28
+ "X-Fern-SDK-Version": "0.0.1",
29
+ **(self.get_custom_headers() or {}),
30
+ }
31
+ headers["Authorization"] = f"Bearer {self._get_token()}"
32
+ return headers
33
+
34
+ def _get_token(self) -> str:
35
+ if isinstance(self._token, str):
36
+ return self._token
37
+ else:
38
+ return self._token()
39
+
40
+ def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
41
+ return self._headers
42
+
43
+ def get_base_url(self) -> str:
44
+ return self._base_url
45
+
46
+ def get_timeout(self) -> typing.Optional[float]:
47
+ return self._timeout
48
+
49
+
50
+ class SyncClientWrapper(BaseClientWrapper):
51
+ def __init__(
52
+ self,
53
+ *,
54
+ token: typing.Union[str, typing.Callable[[], str]],
55
+ headers: typing.Optional[typing.Dict[str, str]] = None,
56
+ base_url: str,
57
+ timeout: typing.Optional[float] = None,
58
+ httpx_client: httpx.Client,
59
+ ):
60
+ super().__init__(token=token, headers=headers, base_url=base_url, timeout=timeout)
61
+ self.httpx_client = HttpClient(
62
+ httpx_client=httpx_client,
63
+ base_headers=self.get_headers,
64
+ base_timeout=self.get_timeout,
65
+ base_url=self.get_base_url,
66
+ )
67
+
68
+
69
+ class AsyncClientWrapper(BaseClientWrapper):
70
+ def __init__(
71
+ self,
72
+ *,
73
+ token: typing.Union[str, typing.Callable[[], str]],
74
+ headers: typing.Optional[typing.Dict[str, str]] = None,
75
+ base_url: str,
76
+ timeout: typing.Optional[float] = None,
77
+ httpx_client: httpx.AsyncClient,
78
+ ):
79
+ super().__init__(token=token, headers=headers, base_url=base_url, timeout=timeout)
80
+ self.httpx_client = AsyncHttpClient(
81
+ httpx_client=httpx_client,
82
+ base_headers=self.get_headers,
83
+ base_timeout=self.get_timeout,
84
+ base_url=self.get_base_url,
85
+ )
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+
6
+ def serialize_datetime(v: dt.datetime) -> str:
7
+ """
8
+ Serialize a datetime including timezone info.
9
+
10
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11
+
12
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13
+ """
14
+
15
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
16
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
17
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
18
+ return v.isoformat().replace("+00:00", "Z")
19
+ else:
20
+ # Delegate to the typical +/- offset format
21
+ return v.isoformat()
22
+
23
+ if v.tzinfo is not None:
24
+ return _serialize_zoned_datetime(v)
25
+ else:
26
+ local_tz = dt.datetime.now().astimezone().tzinfo
27
+ localized_dt = v.replace(tzinfo=local_tz)
28
+ return _serialize_zoned_datetime(localized_dt)