Skip to content

Commit bb812b6

Browse files
Include metrics (#17)
* Include metrics * Update notebook * Update notebook * update notebook --------- Co-authored-by: Ramon Marques <ramon.marques@toptal.com>
1 parent b01f944 commit bb812b6

17 files changed

+343
-198
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ data_to_send = [{
5151
response = client.inference.detect(body=data_to_send)[0]
5252
```
5353

54-
- Step 4: For an example of how to instrument an LLM application **asynchronously** using the SDK, please refer to the [sample notebook](examples/notebooks/aimon_sdk_langchain_summarization.ipynb)
54+
- Step 4: For an example of how to instrument an LLM application **asynchronously** using the SDK, please refer to the [sample notebook](examples/notebooks/aimon_sdk_langchain_summarization_0_5_0.ipynb)
5555
- Step 5: For an example of synchronous detections using the SDK, please refer to the sample [streamlit application](examples/langchain_summarization_app.py)
5656

5757
<div align="center">

aimon/_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Client(SyncAPIClient):
4141
applications: resources.ApplicationsResource
4242
datasets: resources.DatasetsResource
4343
evaluations: resources.EvaluationsResource
44+
analyze: resources.AnalyzeResource
4445
inference: resources.InferenceResource
4546
with_raw_response: ClientWithRawResponse
4647
with_streaming_response: ClientWithStreamedResponse
@@ -95,6 +96,7 @@ def __init__(
9596
self.applications = resources.ApplicationsResource(self)
9697
self.datasets = resources.DatasetsResource(self)
9798
self.evaluations = resources.EvaluationsResource(self)
99+
self.analyze = resources.AnalyzeResource(self)
98100
self.inference = resources.InferenceResource(self)
99101
self.with_raw_response = ClientWithRawResponse(self)
100102
self.with_streaming_response = ClientWithStreamedResponse(self)
@@ -210,6 +212,7 @@ class AsyncClient(AsyncAPIClient):
210212
applications: resources.AsyncApplicationsResource
211213
datasets: resources.AsyncDatasetsResource
212214
evaluations: resources.AsyncEvaluationsResource
215+
analyze: resources.AsyncAnalyzeResource
213216
inference: resources.AsyncInferenceResource
214217
with_raw_response: AsyncClientWithRawResponse
215218
with_streaming_response: AsyncClientWithStreamedResponse
@@ -264,6 +267,7 @@ def __init__(
264267
self.applications = resources.AsyncApplicationsResource(self)
265268
self.datasets = resources.AsyncDatasetsResource(self)
266269
self.evaluations = resources.AsyncEvaluationsResource(self)
270+
self.analyze = resources.AsyncAnalyzeResource(self)
267271
self.inference = resources.AsyncInferenceResource(self)
268272
self.with_raw_response = AsyncClientWithRawResponse(self)
269273
self.with_streaming_response = AsyncClientWithStreamedResponse(self)
@@ -380,6 +384,7 @@ def __init__(self, client: Client) -> None:
380384
self.applications = resources.ApplicationsResourceWithRawResponse(client.applications)
381385
self.datasets = resources.DatasetsResourceWithRawResponse(client.datasets)
382386
self.evaluations = resources.EvaluationsResourceWithRawResponse(client.evaluations)
387+
self.analyze = resources.AnalyzeResourceWithRawResponse(client.analyze)
383388
self.inference = resources.InferenceResourceWithRawResponse(client.inference)
384389

385390

@@ -390,6 +395,7 @@ def __init__(self, client: AsyncClient) -> None:
390395
self.applications = resources.AsyncApplicationsResourceWithRawResponse(client.applications)
391396
self.datasets = resources.AsyncDatasetsResourceWithRawResponse(client.datasets)
392397
self.evaluations = resources.AsyncEvaluationsResourceWithRawResponse(client.evaluations)
398+
self.analyze = resources.AsyncAnalyzeResourceWithRawResponse(client.analyze)
393399
self.inference = resources.AsyncInferenceResourceWithRawResponse(client.inference)
394400

395401

@@ -400,6 +406,7 @@ def __init__(self, client: Client) -> None:
400406
self.applications = resources.ApplicationsResourceWithStreamingResponse(client.applications)
401407
self.datasets = resources.DatasetsResourceWithStreamingResponse(client.datasets)
402408
self.evaluations = resources.EvaluationsResourceWithStreamingResponse(client.evaluations)
409+
self.analyze = resources.AnalyzeResourceWithStreamingResponse(client.analyze)
403410
self.inference = resources.InferenceResourceWithStreamingResponse(client.inference)
404411

405412

@@ -410,6 +417,7 @@ def __init__(self, client: AsyncClient) -> None:
410417
self.applications = resources.AsyncApplicationsResourceWithStreamingResponse(client.applications)
411418
self.datasets = resources.AsyncDatasetsResourceWithStreamingResponse(client.datasets)
412419
self.evaluations = resources.AsyncEvaluationsResourceWithStreamingResponse(client.evaluations)
420+
self.analyze = resources.AsyncAnalyzeResourceWithStreamingResponse(client.analyze)
413421
self.inference = resources.AsyncInferenceResourceWithStreamingResponse(client.inference)
414422

415423

aimon/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
ModelsResourceWithStreamingResponse,
1717
AsyncModelsResourceWithStreamingResponse,
1818
)
19+
from .analyze import (
20+
AnalyzeResource,
21+
AsyncAnalyzeResource,
22+
AnalyzeResourceWithRawResponse,
23+
AsyncAnalyzeResourceWithRawResponse,
24+
AnalyzeResourceWithStreamingResponse,
25+
AsyncAnalyzeResourceWithStreamingResponse,
26+
)
1927
from .datasets import (
2028
DatasetsResource,
2129
AsyncDatasetsResource,
@@ -80,6 +88,12 @@
8088
"AsyncEvaluationsResourceWithRawResponse",
8189
"EvaluationsResourceWithStreamingResponse",
8290
"AsyncEvaluationsResourceWithStreamingResponse",
91+
"AnalyzeResource",
92+
"AsyncAnalyzeResource",
93+
"AnalyzeResourceWithRawResponse",
94+
"AsyncAnalyzeResourceWithRawResponse",
95+
"AnalyzeResourceWithStreamingResponse",
96+
"AsyncAnalyzeResourceWithStreamingResponse",
8397
"InferenceResource",
8498
"AsyncInferenceResource",
8599
"InferenceResourceWithRawResponse",

aimon/resources/analyze.py

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Iterable
6+
7+
import httpx
8+
9+
from ..types import analyze_create_params
10+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11+
from .._utils import (
12+
maybe_transform,
13+
async_maybe_transform,
14+
)
15+
from .._compat import cached_property
16+
from .._resource import SyncAPIResource, AsyncAPIResource
17+
from .._response import (
18+
to_raw_response_wrapper,
19+
to_streamed_response_wrapper,
20+
async_to_raw_response_wrapper,
21+
async_to_streamed_response_wrapper,
22+
)
23+
from .._base_client import make_request_options
24+
from ..types.analyze_create_response import AnalyzeCreateResponse
25+
26+
__all__ = ["AnalyzeResource", "AsyncAnalyzeResource"]
27+
28+
29+
class AnalyzeResource(SyncAPIResource):
30+
@cached_property
31+
def with_raw_response(self) -> AnalyzeResourceWithRawResponse:
32+
return AnalyzeResourceWithRawResponse(self)
33+
34+
@cached_property
35+
def with_streaming_response(self) -> AnalyzeResourceWithStreamingResponse:
36+
return AnalyzeResourceWithStreamingResponse(self)
37+
38+
def create(
39+
self,
40+
*,
41+
body: Iterable[analyze_create_params.Body],
42+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
43+
# The extra values given here take precedence over values defined on the client or passed to this method.
44+
extra_headers: Headers | None = None,
45+
extra_query: Query | None = None,
46+
extra_body: Body | None = None,
47+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
48+
) -> AnalyzeCreateResponse:
49+
"""
50+
Save and compute metrics
51+
52+
Args:
53+
extra_headers: Send extra headers
54+
55+
extra_query: Add additional query parameters to the request
56+
57+
extra_body: Add additional JSON properties to the request
58+
59+
timeout: Override the client-level default timeout for this request, in seconds
60+
"""
61+
return self._post(
62+
"/v1/save-compute-metrics",
63+
body=maybe_transform(body, analyze_create_params.AnalyzeCreateParams),
64+
options=make_request_options(
65+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
66+
),
67+
cast_to=AnalyzeCreateResponse,
68+
)
69+
70+
71+
class AsyncAnalyzeResource(AsyncAPIResource):
72+
@cached_property
73+
def with_raw_response(self) -> AsyncAnalyzeResourceWithRawResponse:
74+
return AsyncAnalyzeResourceWithRawResponse(self)
75+
76+
@cached_property
77+
def with_streaming_response(self) -> AsyncAnalyzeResourceWithStreamingResponse:
78+
return AsyncAnalyzeResourceWithStreamingResponse(self)
79+
80+
async def create(
81+
self,
82+
*,
83+
body: Iterable[analyze_create_params.Body],
84+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
85+
# The extra values given here take precedence over values defined on the client or passed to this method.
86+
extra_headers: Headers | None = None,
87+
extra_query: Query | None = None,
88+
extra_body: Body | None = None,
89+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
90+
) -> AnalyzeCreateResponse:
91+
"""
92+
Save and compute metrics
93+
94+
Args:
95+
extra_headers: Send extra headers
96+
97+
extra_query: Add additional query parameters to the request
98+
99+
extra_body: Add additional JSON properties to the request
100+
101+
timeout: Override the client-level default timeout for this request, in seconds
102+
"""
103+
return await self._post(
104+
"/v1/save-compute-metrics",
105+
body=await async_maybe_transform(body, analyze_create_params.AnalyzeCreateParams),
106+
options=make_request_options(
107+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
108+
),
109+
cast_to=AnalyzeCreateResponse,
110+
)
111+
112+
113+
class AnalyzeResourceWithRawResponse:
114+
def __init__(self, analyze: AnalyzeResource) -> None:
115+
self._analyze = analyze
116+
117+
self.create = to_raw_response_wrapper(
118+
analyze.create,
119+
)
120+
121+
122+
class AsyncAnalyzeResourceWithRawResponse:
123+
def __init__(self, analyze: AsyncAnalyzeResource) -> None:
124+
self._analyze = analyze
125+
126+
self.create = async_to_raw_response_wrapper(
127+
analyze.create,
128+
)
129+
130+
131+
class AnalyzeResourceWithStreamingResponse:
132+
def __init__(self, analyze: AnalyzeResource) -> None:
133+
self._analyze = analyze
134+
135+
self.create = to_streamed_response_wrapper(
136+
analyze.create,
137+
)
138+
139+
140+
class AsyncAnalyzeResourceWithStreamingResponse:
141+
def __init__(self, analyze: AsyncAnalyzeResource) -> None:
142+
self._analyze = analyze
143+
144+
self.create = async_to_streamed_response_wrapper(
145+
analyze.create,
146+
)

0 commit comments

Comments
 (0)