aignostics 0.0.2__tar.gz → 0.0.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aignostics
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: 🔬 Python SDK providing access to Aignostics AI services.
5
5
  Project-URL: Homepage, https://aignostics.readthedocs.io/en/latest/
6
6
  Project-URL: Documentation, https://aignostics.readthedocs.io/en/latest/
@@ -106,36 +106,44 @@ Description-Content-Type: text/markdown
106
106
 
107
107
  Python SDK providing access to Aignostics AI services.
108
108
 
109
- This [Copier](https://copier.readthedocs.io/en/stable/) template enables you to quickly generate a Python package with fully functioning build and test automation.
110
- Projects generated from this template can be [easily updated](https://copier.readthedocs.io/en/stable/updating/) to benefit from improvements and new features of the template.
111
-
112
- Features:
113
- 1. Package management with [uv](https://github.com/astral-sh/uv)
114
- 2. Code formatting with [Ruff](https://github.com/astral-sh/ruff)
115
- 3. Linting with [Ruff](https://github.com/astral-sh/ruff)
116
- 4. Static type checking with [mypy](https://mypy.readthedocs.io/en/stable/)
117
- 5. Complete set of [pre-commit](https://pre-commit.com/) hooks including [detect-secrets](https://github.com/Yelp/detect-secrets) and [pygrep](https://github.com/pre-commit/pygrep-hooks)
118
- 6. Unit and E2E testing with [pytest](https://docs.pytest.org/en/stable/) including parallel test execution
119
- 7. Matrix testing in multiple environments with [nox](https://nox.thea.codes/en/stable/)
120
- 8. Test coverage reported with [Codecov](https://codecov.io/) and published as release artifact
121
- 9. CI/CD pipeline automated with [GitHub Actions](https://github.com/features/actions)
122
- 10. CI/CD pipeline can be run locally with [act](https://github.com/nektos/act)
123
- 11. Code quality and security checks with [SonarQube](https://www.sonarsource.com/products/sonarcloud) and [GitHub CodeQL](https://codeql.github.com/)
124
- 12. Dependency monitoring with [pip-audit](https://pypi.org/project/pip-audit/), [Renovate](https://github.com/renovatebot/renovate), and [GitHub Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide)
125
- 13. Licenses of dependencies extracted with [pip-licenses](https://pypi.org/project/pip-licenses/) and published as release artifacts in CSV and JSON format for compliance checks
126
- 14. Software Bill of Materials (SBOM) generated with [cyclonedx-python](https://github.com/CycloneDX/cyclonedx-python) and published as release artifact
127
- 15. Version and release management with [bump-my-version](https://callowayproject.github.io/bump-my-version/)
128
- 16. Changelog and release notes generated with [git-cliff](https://git-cliff.org/)
129
- 17. Documentation generated with [Sphinx](https://www.sphinx-doc.org/en/master/) including reference documentation and PDF export
130
- 18. Documentation published to [Read The Docs](https://readthedocs.org/)
131
- 19. Interactive OpenAPI specification with [Swagger](https://swagger.io/)
132
- 20. Python package published to [PyPI](https://pypi.org/)
133
- 21. Docker images published to [Docker.io](https://hub.docker.com/) and [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) with [artifact attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
134
- 22. One-click development environments with [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces)
135
- 23. Settings for use with [VSCode](https://code.visualstudio.com/)
136
- 24. Settings and custom instructions for use with [GitHub Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)
137
-
138
- The generated project includes code, documentation and configuration of a fully functioning demo-application and service, which can be used as a starting point for your own project.
109
+ ### Scaffolding
110
+
111
+ This [Copier](https://copier.readthedocs.io/en/stable/) template enables you to quickly generate (scaffold) a Python package with fully functioning build and test automation:
112
+
113
+ 1. Projects generated from this template can be [easily updated](https://copier.readthedocs.io/en/stable/updating/) to benefit from improvements and new features of the template.
114
+ 2. During project generation, you can flexibly configure naming of the Python distribution, import package, main author, GitHub repository, organization, and many other aspects to match your specific requirements (see [copier.yml](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template/blob/main/copier.yml) for all available options).
115
+
116
+ ### Development Infrastructure
117
+
118
+ Projects generated with this template come with a comprehensive development toolchain and quality assurance framework that supports the entire software development lifecycle - from coding and testing to documentation, release management, and compliance auditing. This infrastructure automates routine tasks, enforces code quality standards, and streamlines the path to production:
119
+
120
+ 1. Linting with [Ruff](https://github.com/astral-sh/ruff)
121
+ 2. Static type checking with [mypy](https://mypy.readthedocs.io/en/stable/)
122
+ 3. Complete set of [pre-commit](https://pre-commit.com/) hooks including [detect-secrets](https://github.com/Yelp/detect-secrets) and [pygrep](https://github.com/pre-commit/pygrep-hooks)
123
+ 4. Unit and E2E testing with [pytest](https://docs.pytest.org/en/stable/) including parallel test execution
124
+ 5. Matrix testing in multiple environments with [nox](https://nox.thea.codes/en/stable/)
125
+ 6. Test coverage reported with [Codecov](https://codecov.io/) and published as release artifact
126
+ 7. CI/CD pipeline automated with [GitHub Actions](https://github.com/features/actions)
127
+ 8. CI/CD pipeline can be run locally with [act](https://github.com/nektos/act)
128
+ 9. Code quality and security checks with [SonarQube](https://www.sonarsource.com/products/sonarcloud) and [GitHub CodeQL](https://codeql.github.com/)
129
+ 10. Dependency monitoring with [pip-audit](https://pypi.org/project/pip-audit/), [Renovate](https://github.com/renovatebot/renovate), and [GitHub Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide)
130
+ 11. Licenses of dependencies extracted with [pip-licenses](https://pypi.org/project/pip-licenses/) and published as release artifacts in CSV and JSON format for compliance checks
131
+ 12. Software Bill of Materials (SBOM) generated with [cyclonedx-python](https://github.com/CycloneDX/cyclonedx-python) and published as release artifact
132
+ 13. Version and release management with [bump-my-version](https://callowayproject.github.io/bump-my-version/)
133
+ 14. Changelog and release notes generated with [git-cliff](https://git-cliff.org/)
134
+ 15. Documentation generated with [Sphinx](https://www.sphinx-doc.org/en/master/) including reference documentation and PDF export
135
+ 16. Documentation published to [Read The Docs](https://readthedocs.org/)
136
+ 17. Interactive OpenAPI specification with [Swagger](https://swagger.io/)
137
+ 18. Python package published to [PyPI](https://pypi.org/)
138
+ 19. Docker images published to [Docker.io](https://hub.docker.com/) and [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) with [artifact attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
139
+ 20. One-click development environments with [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces)
140
+ 21. Settings for use with [VSCode](https://code.visualstudio.com/)
141
+ 22. Settings and custom instructions for use with [GitHub Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)
142
+
143
+ ### Application Features
144
+
145
+ Beyond development tooling, projects generated with this template include the code, documentation, and configuration of a fully functioning demo application and service. This reference implementation serves as a starting point for your own business logic with modern patterns and practices already in place:
146
+
139
147
  1. Service architecture suitable for use as shared library
140
148
  2. Validation with [pydantic](https://docs.pydantic.dev/)
141
149
  3. Command-line interface (CLI) with [Typer](https://typer.tiangolo.com/)
@@ -193,9 +201,10 @@ external services such as CloudCov, SonarQube Cloud, Read The Docs, Docker.io, a
193
201
  ./n bump
194
202
  ```
195
203
  Notes:
196
- 1. You can remove this section post having successfully generated your project.
197
- 2. The following sections refer to the dummy application and service provided by this template.
198
- Use them as inspiration and adapt them to your own project.
204
+ 1. You can remove the above sections - from "Scaffolding" to this notes - post having successfully generated your project.
205
+ 2. The following sections refer to the dummy application and service generated into the `tests` and `src` folder by this template.
206
+ Use the documentation and code as inspiration, adapt to your business logic, or remove and start documenting and coding from scratch.
207
+
199
208
 
200
209
  ## Overview
201
210
 
@@ -45,36 +45,44 @@
45
45
 
46
46
  Python SDK providing access to Aignostics AI services.
47
47
 
48
- This [Copier](https://copier.readthedocs.io/en/stable/) template enables you to quickly generate a Python package with fully functioning build and test automation.
49
- Projects generated from this template can be [easily updated](https://copier.readthedocs.io/en/stable/updating/) to benefit from improvements and new features of the template.
50
-
51
- Features:
52
- 1. Package management with [uv](https://github.com/astral-sh/uv)
53
- 2. Code formatting with [Ruff](https://github.com/astral-sh/ruff)
54
- 3. Linting with [Ruff](https://github.com/astral-sh/ruff)
55
- 4. Static type checking with [mypy](https://mypy.readthedocs.io/en/stable/)
56
- 5. Complete set of [pre-commit](https://pre-commit.com/) hooks including [detect-secrets](https://github.com/Yelp/detect-secrets) and [pygrep](https://github.com/pre-commit/pygrep-hooks)
57
- 6. Unit and E2E testing with [pytest](https://docs.pytest.org/en/stable/) including parallel test execution
58
- 7. Matrix testing in multiple environments with [nox](https://nox.thea.codes/en/stable/)
59
- 8. Test coverage reported with [Codecov](https://codecov.io/) and published as release artifact
60
- 9. CI/CD pipeline automated with [GitHub Actions](https://github.com/features/actions)
61
- 10. CI/CD pipeline can be run locally with [act](https://github.com/nektos/act)
62
- 11. Code quality and security checks with [SonarQube](https://www.sonarsource.com/products/sonarcloud) and [GitHub CodeQL](https://codeql.github.com/)
63
- 12. Dependency monitoring with [pip-audit](https://pypi.org/project/pip-audit/), [Renovate](https://github.com/renovatebot/renovate), and [GitHub Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide)
64
- 13. Licenses of dependencies extracted with [pip-licenses](https://pypi.org/project/pip-licenses/) and published as release artifacts in CSV and JSON format for compliance checks
65
- 14. Software Bill of Materials (SBOM) generated with [cyclonedx-python](https://github.com/CycloneDX/cyclonedx-python) and published as release artifact
66
- 15. Version and release management with [bump-my-version](https://callowayproject.github.io/bump-my-version/)
67
- 16. Changelog and release notes generated with [git-cliff](https://git-cliff.org/)
68
- 17. Documentation generated with [Sphinx](https://www.sphinx-doc.org/en/master/) including reference documentation and PDF export
69
- 18. Documentation published to [Read The Docs](https://readthedocs.org/)
70
- 19. Interactive OpenAPI specification with [Swagger](https://swagger.io/)
71
- 20. Python package published to [PyPI](https://pypi.org/)
72
- 21. Docker images published to [Docker.io](https://hub.docker.com/) and [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) with [artifact attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
73
- 22. One-click development environments with [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces)
74
- 23. Settings for use with [VSCode](https://code.visualstudio.com/)
75
- 24. Settings and custom instructions for use with [GitHub Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)
76
-
77
- The generated project includes code, documentation and configuration of a fully functioning demo-application and service, which can be used as a starting point for your own project.
48
+ ### Scaffolding
49
+
50
+ This [Copier](https://copier.readthedocs.io/en/stable/) template enables you to quickly generate (scaffold) a Python package with fully functioning build and test automation:
51
+
52
+ 1. Projects generated from this template can be [easily updated](https://copier.readthedocs.io/en/stable/updating/) to benefit from improvements and new features of the template.
53
+ 2. During project generation, you can flexibly configure naming of the Python distribution, import package, main author, GitHub repository, organization, and many other aspects to match your specific requirements (see [copier.yml](https://github.com/helmut-hoffer-von-ankershoffen/oe-python-template/blob/main/copier.yml) for all available options).
54
+
55
+ ### Development Infrastructure
56
+
57
+ Projects generated with this template come with a comprehensive development toolchain and quality assurance framework that supports the entire software development lifecycle - from coding and testing to documentation, release management, and compliance auditing. This infrastructure automates routine tasks, enforces code quality standards, and streamlines the path to production:
58
+
59
+ 1. Linting with [Ruff](https://github.com/astral-sh/ruff)
60
+ 2. Static type checking with [mypy](https://mypy.readthedocs.io/en/stable/)
61
+ 3. Complete set of [pre-commit](https://pre-commit.com/) hooks including [detect-secrets](https://github.com/Yelp/detect-secrets) and [pygrep](https://github.com/pre-commit/pygrep-hooks)
62
+ 4. Unit and E2E testing with [pytest](https://docs.pytest.org/en/stable/) including parallel test execution
63
+ 5. Matrix testing in multiple environments with [nox](https://nox.thea.codes/en/stable/)
64
+ 6. Test coverage reported with [Codecov](https://codecov.io/) and published as release artifact
65
+ 7. CI/CD pipeline automated with [GitHub Actions](https://github.com/features/actions)
66
+ 8. CI/CD pipeline can be run locally with [act](https://github.com/nektos/act)
67
+ 9. Code quality and security checks with [SonarQube](https://www.sonarsource.com/products/sonarcloud) and [GitHub CodeQL](https://codeql.github.com/)
68
+ 10. Dependency monitoring with [pip-audit](https://pypi.org/project/pip-audit/), [Renovate](https://github.com/renovatebot/renovate), and [GitHub Dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide)
69
+ 11. Licenses of dependencies extracted with [pip-licenses](https://pypi.org/project/pip-licenses/) and published as release artifacts in CSV and JSON format for compliance checks
70
+ 12. Software Bill of Materials (SBOM) generated with [cyclonedx-python](https://github.com/CycloneDX/cyclonedx-python) and published as release artifact
71
+ 13. Version and release management with [bump-my-version](https://callowayproject.github.io/bump-my-version/)
72
+ 14. Changelog and release notes generated with [git-cliff](https://git-cliff.org/)
73
+ 15. Documentation generated with [Sphinx](https://www.sphinx-doc.org/en/master/) including reference documentation and PDF export
74
+ 16. Documentation published to [Read The Docs](https://readthedocs.org/)
75
+ 17. Interactive OpenAPI specification with [Swagger](https://swagger.io/)
76
+ 18. Python package published to [PyPI](https://pypi.org/)
77
+ 19. Docker images published to [Docker.io](https://hub.docker.com/) and [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) with [artifact attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
78
+ 20. One-click development environments with [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) and [GitHub Codespaces](https://github.com/features/codespaces)
79
+ 21. Settings for use with [VSCode](https://code.visualstudio.com/)
80
+ 22. Settings and custom instructions for use with [GitHub Copilot](https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)
81
+
82
+ ### Application Features
83
+
84
+ Beyond development tooling, projects generated with this template include the code, documentation, and configuration of a fully functioning demo application and service. This reference implementation serves as a starting point for your own business logic with modern patterns and practices already in place:
85
+
78
86
  1. Service architecture suitable for use as shared library
79
87
  2. Validation with [pydantic](https://docs.pydantic.dev/)
80
88
  3. Command-line interface (CLI) with [Typer](https://typer.tiangolo.com/)
@@ -132,9 +140,10 @@ external services such as CloudCov, SonarQube Cloud, Read The Docs, Docker.io, a
132
140
  ./n bump
133
141
  ```
134
142
  Notes:
135
- 1. You can remove this section post having successfully generated your project.
136
- 2. The following sections refer to the dummy application and service provided by this template.
137
- Use them as inspiration and adapt them to your own project.
143
+ 1. You can remove the above sections - from "Scaffolding" to this notes - post having successfully generated your project.
144
+ 2. The following sections refer to the dummy application and service generated into the `tests` and `src` folder by this template.
145
+ Use the documentation and code as inspiration, adapt to your business logic, or remove and start documenting and coding from scratch.
146
+
138
147
 
139
148
  ## Overview
140
149
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aignostics"
3
- version = "0.0.2"
3
+ version = "0.0.4"
4
4
  description = "🔬 Python SDK providing access to Aignostics AI services."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -125,7 +125,6 @@ dev = [
125
125
  "sphinx-copybutton>=0.5.2",
126
126
  "sphinx-inline-tabs>=2023.4.21",
127
127
  "sphinx-mdinclude>=0.6.2",
128
- "sphinx-pydantic>=0.1.1",
129
128
  "sphinx-rtd-theme>=3.0.2",
130
129
  "sphinx_selective_exclude>=1.0.3",
131
130
  "sphinx-toolbox>=3.9.0",
@@ -136,6 +135,12 @@ dev = [
136
135
  "watchdog>=6.0.0",
137
136
  ]
138
137
 
138
+ [tool.uv]
139
+ override-dependencies = [ # https://github.com/astral-sh/uv/issues/4422
140
+ "rfc3987; sys_platform == 'never'", # GPLv3
141
+ ]
142
+
143
+
139
144
  [tool.ruff]
140
145
  target-version = "py311"
141
146
  preview = true
@@ -248,7 +253,7 @@ source = ["src/"]
248
253
 
249
254
 
250
255
  [tool.bumpversion]
251
- current_version = "0.0.2"
256
+ current_version = "0.0.4"
252
257
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
253
258
  serialize = ["{major}.{minor}.{patch}"]
254
259
  search = "{current_version}"
@@ -5,10 +5,15 @@ from .constants import (
5
5
  __project_path__,
6
6
  __version__,
7
7
  )
8
+ from .models import Echo, Health, HealthStatus, Utterance
8
9
  from .service import Service
9
10
 
10
11
  __all__ = [
12
+ "Echo",
13
+ "Health",
14
+ "HealthStatus",
11
15
  "Service",
16
+ "Utterance",
12
17
  "__project_name__",
13
18
  "__project_path__",
14
19
  "__version__",
@@ -10,13 +10,12 @@ The endpoints use Pydantic models for request and response validation.
10
10
 
11
11
  import os
12
12
  from collections.abc import Generator
13
- from enum import StrEnum
14
13
  from typing import Annotated
15
14
 
16
15
  from fastapi import Depends, FastAPI, Response, status
17
16
  from pydantic import BaseModel, Field
18
17
 
19
- from aignostics import Service
18
+ from aignostics import Echo, Health, HealthStatus, Service, Utterance
20
19
 
21
20
  TITLE = "Aignostics Python SDK"
22
21
  HELLO_WORLD_EXAMPLE = "Hello, world!"
@@ -94,30 +93,6 @@ api_v2 = FastAPI(
94
93
  )
95
94
 
96
95
 
97
- class _HealthStatus(StrEnum):
98
- """Health status enumeration."""
99
-
100
- UP = "UP"
101
- DOWN = "DOWN"
102
-
103
-
104
- class Health(BaseModel):
105
- """Health status model."""
106
-
107
- status: _HealthStatus
108
- reason: str | None = None
109
-
110
-
111
- class HealthResponse(BaseModel):
112
- """Response model for health endpoint."""
113
-
114
- health: str = Field(
115
- ...,
116
- description="The hello world message",
117
- examples=[HELLO_WORLD_EXAMPLE],
118
- )
119
-
120
-
121
96
  @api_v1.get("/healthz", tags=["Observability"])
122
97
  @api_v1.get("/health", tags=["Observability"])
123
98
  @api_v2.get("/healthz", tags=["Observability"])
@@ -136,17 +111,17 @@ async def health(service: Annotated[Service, Depends(get_service)], response: Re
136
111
  Health: The health status of the service.
137
112
  """
138
113
  if service.healthy():
139
- health_result = Health(status=_HealthStatus.UP)
114
+ health_result = Health(status=HealthStatus.UP)
140
115
  else:
141
- health_result = Health(status=_HealthStatus.DOWN, reason="Service is unhealthy")
116
+ health_result = Health(status=HealthStatus.DOWN, reason="Service is unhealthy")
142
117
 
143
- if health_result.status == _HealthStatus.DOWN:
118
+ if health_result.status == HealthStatus.DOWN:
144
119
  response.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
145
120
 
146
121
  return health_result
147
122
 
148
123
 
149
- class HelloWorldResponse(BaseModel):
124
+ class _HelloWorldResponse(BaseModel):
150
125
  """Response model for hello-world endpoint."""
151
126
 
152
127
  message: str = Field(
@@ -158,81 +133,48 @@ class HelloWorldResponse(BaseModel):
158
133
 
159
134
  @api_v1.get("/hello-world", tags=["Basics"])
160
135
  @api_v2.get("/hello-world", tags=["Basics"])
161
- async def hello_world() -> HelloWorldResponse:
136
+ async def hello_world() -> _HelloWorldResponse:
162
137
  """
163
138
  Return a hello world message.
164
139
 
165
140
  Returns:
166
- HelloWorldResponse: A response containing the hello world message.
141
+ _HelloWorldResponse: A response containing the hello world message.
167
142
  """
168
- return HelloWorldResponse(message=Service.get_hello_world())
169
-
170
-
171
- class EchoResponse(BaseModel):
172
- """Response model for echo endpoint."""
173
-
174
- message: str = Field(
175
- ...,
176
- min_length=1,
177
- description="The message content",
178
- examples=[HELLO_WORLD_EXAMPLE],
179
- )
180
-
181
-
182
- class EchoRequest(BaseModel):
183
- """Request model for echo endpoint."""
184
-
185
- text: str = Field(
186
- ...,
187
- min_length=1,
188
- description="The text to echo back",
189
- examples=[HELLO_WORLD_EXAMPLE],
190
- )
143
+ return _HelloWorldResponse(message=Service.get_hello_world())
191
144
 
192
145
 
193
- @api_v1.post("/echo", tags=["Basics"])
194
- async def echo(request: EchoRequest) -> EchoResponse:
146
+ @api_v1.get("/echo/{text}", tags=["Basics"])
147
+ async def echo(text: str) -> Echo:
195
148
  """
196
149
  Echo back the provided text.
197
150
 
198
151
  Args:
199
- request (EchoRequest): The request containing the text to echo back.
152
+ text (str): The text to echo.
200
153
 
201
154
  Returns:
202
- EchoResponse: A response containing the echoed text.
155
+ Echo: The echo.
203
156
 
204
157
  Raises:
205
158
  422 Unprocessable Entity: If text is not provided or empty.
206
159
  """
207
- return EchoResponse(message=request.text)
208
-
209
-
210
- class Utterance(BaseModel):
211
- """Request model for echo endpoint."""
212
-
213
- utterance: str = Field(
214
- ...,
215
- min_length=1,
216
- description="The utterance to echo back",
217
- examples=[HELLO_WORLD_EXAMPLE],
218
- )
160
+ return Service.echo(Utterance(text=text))
219
161
 
220
162
 
221
163
  @api_v2.post("/echo", tags=["Basics"])
222
- async def echo_v2(request: Utterance) -> EchoResponse:
164
+ async def echo_v2(request: Utterance) -> Echo:
223
165
  """
224
166
  Echo back the provided utterance.
225
167
 
226
168
  Args:
227
- request (Utterance): The request containing the utterance to echo back.
169
+ request (Utterance): The utterance to echo back.
228
170
 
229
171
  Returns:
230
- EchoResponse: A response containing the echoed utterance.
172
+ Echo: The echo.
231
173
 
232
174
  Raises:
233
175
  422 Unprocessable Entity: If utterance is not provided or empty.
234
176
  """
235
- return EchoResponse(message=request.utterance)
177
+ return Service.echo(request)
236
178
 
237
179
 
238
180
  api.mount("/v1", api_v1)
@@ -9,7 +9,7 @@ import uvicorn
9
9
  import yaml
10
10
  from rich.console import Console
11
11
 
12
- from aignostics import Service, __version__
12
+ from aignostics import Service, Utterance, __version__
13
13
  from aignostics.api import api_v1, api_v2
14
14
 
15
15
  console = Console()
@@ -30,10 +30,11 @@ def echo(
30
30
  ] = False,
31
31
  ) -> None:
32
32
  """Echo the text."""
33
+ echo = Service.echo(Utterance(text=text))
33
34
  if json:
34
- console.print_json(data={"text": text})
35
+ console.print_json(data={"text": echo.text})
35
36
  else:
36
- console.print(text)
37
+ console.print(echo.text)
37
38
 
38
39
 
39
40
  @cli.command()
@@ -0,0 +1,44 @@
1
+ """Models used throughout Aignostics Python SDK's codebase ."""
2
+
3
+ from enum import StrEnum
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+ UTTERANCE_EXAMPLE = "Hello, world!"
8
+ ECHO_EXAMPLE = "HELLO, WORLD!"
9
+
10
+
11
+ class Utterance(BaseModel):
12
+ """Model representing a text utterance."""
13
+
14
+ text: str = Field(
15
+ ...,
16
+ min_length=1,
17
+ description="The utterance to echo back",
18
+ examples=[UTTERANCE_EXAMPLE],
19
+ )
20
+
21
+
22
+ class Echo(BaseModel):
23
+ """Response model for echo endpoint."""
24
+
25
+ text: str = Field(
26
+ ...,
27
+ min_length=1,
28
+ description="The echo",
29
+ examples=[ECHO_EXAMPLE],
30
+ )
31
+
32
+
33
+ class HealthStatus(StrEnum):
34
+ """Health status enumeration."""
35
+
36
+ UP = "UP"
37
+ DOWN = "DOWN"
38
+
39
+
40
+ class Health(BaseModel):
41
+ """Health status model."""
42
+
43
+ status: HealthStatus
44
+ reason: str | None = None
@@ -1,9 +1,11 @@
1
- """Service of Aignostics Python SDK."""
1
+ """Service of Aignostics Python SDK's."""
2
2
 
3
3
  import os
4
4
 
5
5
  from dotenv import load_dotenv
6
6
 
7
+ from aignostics.models import Echo, Utterance
8
+
7
9
  load_dotenv()
8
10
  THE_VAR = os.getenv("THE_VAR", "not defined")
9
11
 
@@ -33,3 +35,19 @@ class Service:
33
35
  bool: True if the service is healthy, False otherwise.
34
36
  """
35
37
  return self.is_healthy
38
+
39
+ @staticmethod
40
+ def echo(utterance: Utterance) -> Echo:
41
+ """
42
+ Loudly echo utterance.
43
+
44
+ Args:
45
+ utterance (Utterance): The utterance to echo.
46
+
47
+ Returns:
48
+ Echo: The loudly echoed utterance.
49
+
50
+ Raises:
51
+ ValueError: If the utterance is empty or contains only whitespace.
52
+ """
53
+ return Echo(text=utterance.text.upper())
File without changes
File without changes