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,25 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .cohort_request_provider import CohortRequestProvider
6
+ from .cohort_response import CohortResponse
7
+ from .fhir_client_config import FhirClientConfig
8
+ from .lang2fhir_and_create_request_provider import Lang2FhirAndCreateRequestProvider
9
+ from .lang2fhir_and_create_request_resource import Lang2FhirAndCreateRequestResource
10
+ from .lang2fhir_and_create_response import Lang2FhirAndCreateResponse
11
+ from .lang2fhir_and_search_request_provider import Lang2FhirAndSearchRequestProvider
12
+ from .lang2fhir_and_search_response import Lang2FhirAndSearchResponse
13
+ from .search_concept import SearchConcept
14
+
15
+ __all__ = [
16
+ "CohortRequestProvider",
17
+ "CohortResponse",
18
+ "FhirClientConfig",
19
+ "Lang2FhirAndCreateRequestProvider",
20
+ "Lang2FhirAndCreateRequestResource",
21
+ "Lang2FhirAndCreateResponse",
22
+ "Lang2FhirAndSearchRequestProvider",
23
+ "Lang2FhirAndSearchResponse",
24
+ "SearchConcept",
25
+ ]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ CohortRequestProvider = typing.Union[typing.Literal["medplum", "google_healthcare", "canvas", "hapi"], typing.Any]
@@ -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 .search_concept import SearchConcept
10
+
11
+
12
+ class CohortResponse(UniversalBaseModel):
13
+ success: typing.Optional[bool] = pydantic.Field(default=None)
14
+ """
15
+ Whether the cohort analysis was successful
16
+ """
17
+
18
+ message: typing.Optional[str] = pydantic.Field(default=None)
19
+ """
20
+ Status message with details about the analysis
21
+ """
22
+
23
+ patient_ids: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="patientIds")] = (
24
+ pydantic.Field(default=None)
25
+ )
26
+ """
27
+ Array of patient IDs that match the cohort criteria
28
+ """
29
+
30
+ patient_count: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="patientCount")] = (
31
+ pydantic.Field(default=None)
32
+ )
33
+ """
34
+ Total number of patients in the cohort
35
+ """
36
+
37
+ queries: typing.Optional[typing.List[SearchConcept]] = pydantic.Field(default=None)
38
+ """
39
+ Individual search concepts that were identified and executed
40
+ """
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
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class FhirClientConfig(UniversalBaseModel):
10
+ """
11
+ Provider-specific configuration and metadata
12
+ """
13
+
14
+ fhir_store_id: typing.Optional[str] = pydantic.Field(default=None)
15
+ """
16
+ FHIR store ID for Google Healthcare provider
17
+ """
18
+
19
+ on_behalf_of_email: typing.Optional[str] = pydantic.Field(default=None)
20
+ """
21
+ Email address to use for On-Behalf-Of requests (Medplum only). If provided, the request will be made on behalf of the Patient or Practitioner with this email address.
22
+ """
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,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ Lang2FhirAndCreateRequestProvider = typing.Union[
6
+ typing.Literal["medplum", "google_healthcare", "canvas", "hapi"], typing.Any
7
+ ]
@@ -0,0 +1,25 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ Lang2FhirAndCreateRequestResource = typing.Union[
6
+ typing.Literal[
7
+ "auto",
8
+ "appointment",
9
+ "condition-encounter-diagnosis",
10
+ "medicationrequest",
11
+ "careplan",
12
+ "condition-problems-health-concerns",
13
+ "coverage",
14
+ "encounter",
15
+ "observation-clinical-result",
16
+ "observation-lab",
17
+ "patient",
18
+ "procedure",
19
+ "questionnaire",
20
+ "questionnaireresponse",
21
+ "simple-observation",
22
+ "vital-signs",
23
+ ],
24
+ typing.Any,
25
+ ]
@@ -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
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class Lang2FhirAndCreateResponse(UniversalBaseModel):
10
+ fhir_resource: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
11
+ """
12
+ The created FHIR resource
13
+ """
14
+
15
+ fhir_id: typing.Optional[str] = pydantic.Field(default=None)
16
+ """
17
+ ID of the resource in the FHIR server (if successfully stored)
18
+ """
19
+
20
+ success: typing.Optional[bool] = None
21
+ message: typing.Optional[str] = pydantic.Field(default=None)
22
+ """
23
+ Status message
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,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ Lang2FhirAndSearchRequestProvider = typing.Union[
6
+ typing.Literal["medplum", "google_healthcare", "canvas", "hapi"], typing.Any
7
+ ]
@@ -0,0 +1,40 @@
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 Lang2FhirAndSearchResponse(UniversalBaseModel):
10
+ resource_type: typing.Optional[str] = pydantic.Field(default=None)
11
+ """
12
+ The FHIR resource type identified for the search
13
+ """
14
+
15
+ search_params: typing.Optional[str] = pydantic.Field(default=None)
16
+ """
17
+ FHIR search parameters in standard format
18
+ """
19
+
20
+ fhir_results: typing.Optional[typing.List[typing.Dict[str, typing.Optional[typing.Any]]]] = pydantic.Field(
21
+ default=None
22
+ )
23
+ """
24
+ Array of FHIR resources returned from the search
25
+ """
26
+
27
+ success: typing.Optional[bool] = None
28
+ message: typing.Optional[str] = pydantic.Field(default=None)
29
+ """
30
+ Status message
31
+ """
32
+
33
+ if IS_PYDANTIC_V2:
34
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
35
+ else:
36
+
37
+ class Config:
38
+ frozen = True
39
+ smart_union = True
40
+ 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
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class SearchConcept(UniversalBaseModel):
10
+ """
11
+ A single search concept detected in cohort mode
12
+ """
13
+
14
+ resource_type: typing.Optional[str] = pydantic.Field(default=None)
15
+ """
16
+ The FHIR resource type identified for this concept
17
+ """
18
+
19
+ search_params: typing.Optional[str] = pydantic.Field(default=None)
20
+ """
21
+ FHIR search parameters for this concept
22
+ """
23
+
24
+ concept: typing.Optional[str] = pydantic.Field(default=None)
25
+ """
26
+ Description of what this search represents
27
+ """
28
+
29
+ exclude: typing.Optional[bool] = pydantic.Field(default=None)
30
+ """
31
+ Whether this is an exclusion criteria
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
phenoml/version.py ADDED
@@ -0,0 +1,3 @@
1
+ from importlib import metadata
2
+
3
+ __version__ = metadata.version("phenoml")
@@ -0,0 +1,123 @@
1
+ """
2
+ Simple wrapper that extends the base client with automatic token generation.
3
+ """
4
+
5
+ import httpx
6
+ from typing import Optional, Union, Callable
7
+
8
+ from .client import phenoml, Asyncphenoml
9
+ from .environment import phenomlEnvironment
10
+ from .authtoken.client import AuthtokenClient, AsyncAuthtokenClient
11
+ from .core.client_wrapper import SyncClientWrapper, AsyncClientWrapper
12
+
13
+
14
+ class PhenoMLClient(phenoml):
15
+ """
16
+ Extends the base client with automatic token generation from username/password.
17
+ """
18
+
19
+ def __init__(
20
+ self,
21
+ *,
22
+ token: Optional[Union[str, Callable[[], str]]] = None,
23
+ username: Optional[str] = None,
24
+ password: Optional[str] = None,
25
+ **kwargs
26
+ ):
27
+ # Validate authentication
28
+ if token is None and (username is None or password is None):
29
+ raise ValueError("Must provide either 'token' or both 'username' and 'password'")
30
+
31
+ if token is not None and (username is not None or password is not None):
32
+ raise ValueError("Cannot provide both 'token' and 'username'/'password'")
33
+
34
+ # Generate token if needed
35
+ if token is None:
36
+ if username is None or password is None:
37
+ raise ValueError("Must provide both 'username' and 'password'")
38
+ base_url = kwargs.get('base_url')
39
+ if base_url is None:
40
+ raise ValueError("Must provide 'base_url' when using username/password")
41
+ token = self._generate_token(username, password, base_url)
42
+
43
+ # Call parent constructor with the resolved token and all kwargs
44
+ super().__init__(token=token, **kwargs)
45
+
46
+ def _generate_token(self, username: str, password: str, base_url: str) -> str:
47
+ """Generate token using the auth client."""
48
+ # Create a simple client wrapper without authentication
49
+ client_wrapper = SyncClientWrapper(
50
+ token="", # No auth needed since we're using basic auth in the request
51
+ base_url=base_url,
52
+ httpx_client=httpx.Client()
53
+ )
54
+
55
+ # Create the auth client using the existing SDK
56
+ auth_client = AuthtokenClient(client_wrapper=client_wrapper)
57
+
58
+ print(f"Generating token for {username} using auth client")
59
+ response = auth_client.auth.generate_token(username=username, password=password)
60
+ print(f"Token response: {response}")
61
+ return response.token
62
+
63
+
64
+ class AsyncPhenoMLClient(Asyncphenoml):
65
+ """
66
+ Extends the async base client with automatic token generation from username/password.
67
+ """
68
+
69
+ def __init__(
70
+ self,
71
+ *,
72
+ token: Optional[Union[str, Callable[[], str]]] = None,
73
+ username: Optional[str] = None,
74
+ password: Optional[str] = None,
75
+ **kwargs
76
+ ):
77
+ # Validate authentication
78
+ if token is None and (username is None or password is None):
79
+ raise ValueError("Must provide either 'token' or both 'username' and 'password'")
80
+
81
+ if token is not None and (username is not None or password is not None):
82
+ raise ValueError("Cannot provide both 'token' and 'username'/'password'")
83
+
84
+ # Store for async token generation (needed for initialize)
85
+ self._username = username
86
+ self._password = password
87
+ self._base_url = kwargs.get('base_url')
88
+ if self._base_url is None:
89
+ raise ValueError("Must provide 'base_url' when using username/password")
90
+
91
+ # Create with temporary token if needed
92
+ self._current_token = ""
93
+ super().__init__(token=token or (lambda: self._current_token), **kwargs)
94
+
95
+ async def initialize(self) -> None:
96
+ """Generate token if username/password was provided."""
97
+ if self._username and self._password:
98
+ token = await self._generate_token()
99
+ # Update the token on the existing instance instead of recreating
100
+ # This is a workaround since we can't easily recreate the instance
101
+ self._current_token = token
102
+
103
+ async def _generate_token(self) -> str:
104
+ """Generate token using the auth client."""
105
+ # Ensure base_url is a string
106
+ if self._base_url is None:
107
+ raise ValueError("Base URL must be provided")
108
+
109
+ # Create a simple client wrapper without authentication
110
+ client_wrapper = AsyncClientWrapper(
111
+ token="", # No auth needed since we're using basic auth in the request
112
+ base_url=self._base_url,
113
+ httpx_client=httpx.AsyncClient()
114
+ )
115
+
116
+ # Create the auth client using the existing SDK
117
+ auth_client = AsyncAuthtokenClient(client_wrapper=client_wrapper)
118
+
119
+ if self._username is None or self._password is None:
120
+ raise ValueError("Username and password must be provided")
121
+
122
+ response = await auth_client.auth.generate_token(username=self._username, password=self._password)
123
+ return response.token
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 PhenoML
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.1
2
+ Name: phenoml
3
+ Version: 0.0.1
4
+ Summary:
5
+ Requires-Python: >=3.8,<4.0
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Operating System :: POSIX
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: httpx (>=0.21.2)
22
+ Requires-Dist: pydantic (>=1.9.2)
23
+ Requires-Dist: pydantic-core (>=2.18.2)
24
+ Requires-Dist: typing_extensions (>=4.0.0)
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Phenoml Python Library
28
+
29
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Ffern-demo%2Fphenoml-python-sdk)
30
+ [![pypi](https://img.shields.io/pypi/v/phenoml)](https://pypi.python.org/pypi/phenoml)
31
+
32
+ The Phenoml Python library provides convenient access to the Phenoml API from Python.
33
+
34
+ ## Installation
35
+
36
+ ```sh
37
+ pip install phenoml
38
+ ```
39
+
40
+ ## Reference
41
+
42
+ A full reference for this library is available [here](https://github.com/phenoml/phenoml-python-sdk/blob/HEAD/./reference.md).
43
+
44
+ ## Usage
45
+
46
+ Instantiate and use the client with the following:
47
+
48
+ ```python
49
+ from phenoml import Client
50
+
51
+ client = Client(
52
+ username="your_username",
53
+ password="your_password",
54
+ base_url="https://your-phenoml-instance.com"
55
+ )
56
+
57
+ client.agent.create(
58
+ name="name",
59
+ prompts=["prompt_123", "prompt_456"],
60
+ is_active=True,
61
+ )
62
+ ```
63
+
64
+ ## Async Client
65
+
66
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API.
67
+
68
+ ```python
69
+ import asyncio
70
+
71
+ from phenoml import AsyncClient
72
+
73
+ client = AsyncClient(
74
+ username="your_username",
75
+ password="your_password",
76
+ base_url="https://your-phenoml-instance.com"
77
+ )
78
+
79
+
80
+ async def main() -> None:
81
+ await client.initialize() # Generate token from username/password
82
+ await client.agent.create(
83
+ name="name",
84
+ prompts=["prompt_123", "prompt_456"],
85
+ is_active=True,
86
+ )
87
+
88
+
89
+ asyncio.run(main())
90
+ ```
91
+
92
+ ## Exception Handling
93
+
94
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
95
+ will be thrown.
96
+
97
+ ```python
98
+ from phenoml.core.api_error import ApiError
99
+
100
+ try:
101
+ client.agent.create(...)
102
+ except ApiError as e:
103
+ print(e.status_code)
104
+ print(e.body)
105
+ ```
106
+
107
+ ## Advanced
108
+
109
+ ### Access Raw Response Data
110
+
111
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
112
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
113
+
114
+ ```python
115
+ from phenoml import phenoml
116
+
117
+ client = phenoml(
118
+ ...,
119
+ )
120
+ response = client.agent.with_raw_response.create(...)
121
+ print(response.headers) # access the response headers
122
+ print(response.data) # access the underlying object
123
+ ```
124
+
125
+ ### Retries
126
+
127
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
128
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
129
+ retry limit (default: 2).
130
+
131
+ A request is deemed retryable when any of the following HTTP status codes is returned:
132
+
133
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
134
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
135
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
136
+
137
+ Use the `max_retries` request option to configure this behavior.
138
+
139
+ ```python
140
+ client.agent.create(..., request_options={
141
+ "max_retries": 1
142
+ })
143
+ ```
144
+
145
+ ### Timeouts
146
+
147
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
148
+
149
+ ```python
150
+
151
+ from phenoml import phenoml
152
+
153
+ client = phenoml(
154
+ ...,
155
+ timeout=20.0,
156
+ )
157
+
158
+
159
+ # Override timeout for a specific method
160
+ client.agent.create(..., request_options={
161
+ "timeout_in_seconds": 1
162
+ })
163
+ ```
164
+
165
+ ### Custom Client
166
+
167
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
168
+ and transports.
169
+
170
+ ```python
171
+ import httpx
172
+ from phenoml import phenoml
173
+
174
+ client = phenoml(
175
+ ...,
176
+ httpx_client=httpx.Client(
177
+ proxies="http://my.test.proxy.example.com",
178
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
179
+ ),
180
+ )
181
+ ```
182
+
183
+ ## Contributing
184
+
185
+ While we value open-source contributions to this SDK, this library is generated programmatically.
186
+ Additions made directly to this library would have to be moved over to our generation code,
187
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
188
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
189
+ an issue first to discuss with us!
190
+
191
+ On the other hand, contributions to the README are always very welcome!
192
+