Repository navigation
feat(api): update API spec from langfuse/langfuse 306cdfb #2143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
langfuse-bot
wants to merge
1
commit into
main
Choose a base branch
from
api-spec-bot-306cdfb-44893410249-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # This file was auto-generated by Fern from our API Definition. | ||
|
|
||
| # isort: skip_file | ||
|
|
||
| import typing | ||
| from importlib import import_module | ||
|
|
||
| if typing.TYPE_CHECKING: | ||
| from .types import BillableUnitsGranularity, BillableUnitsResponse, BillableUnitsRow | ||
| _dynamic_imports: typing.Dict[str, str] = { | ||
| "BillableUnitsGranularity": ".types", | ||
| "BillableUnitsResponse": ".types", | ||
| "BillableUnitsRow": ".types", | ||
| } | ||
|
|
||
|
|
||
| def __getattr__(attr_name: str) -> typing.Any: | ||
| module_name = _dynamic_imports.get(attr_name) | ||
| if module_name is None: | ||
| raise AttributeError( | ||
| f"No {attr_name} found in _dynamic_imports for module name -> {__name__}" | ||
| ) | ||
| try: | ||
| module = import_module(module_name, __package__) | ||
| if module_name == f".{attr_name}": | ||
| return module | ||
| else: | ||
| return getattr(module, attr_name) | ||
| except ImportError as e: | ||
| raise ImportError( | ||
| f"Failed to import {attr_name} from {module_name}: {e}" | ||
| ) from e | ||
| except AttributeError as e: | ||
| raise AttributeError( | ||
| f"Failed to get {attr_name} from {module_name}: {e}" | ||
| ) from e | ||
|
|
||
|
|
||
| def __dir__(): | ||
| lazy_attrs = list(_dynamic_imports.keys()) | ||
| return sorted(lazy_attrs) | ||
|
|
||
|
|
||
| __all__ = ["BillableUnitsGranularity", "BillableUnitsResponse", "BillableUnitsRow"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| # This file was auto-generated by Fern from our API Definition. | ||
|
|
||
| import datetime as dt | ||
| import typing | ||
|
|
||
| from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper | ||
| from ...core.request_options import RequestOptions | ||
| from .raw_client import AsyncRawBillableUnitsClient, RawBillableUnitsClient | ||
| from .types.billable_units_granularity import BillableUnitsGranularity | ||
| from .types.billable_units_response import BillableUnitsResponse | ||
|
|
||
|
|
||
| class BillableUnitsClient: | ||
| def __init__(self, *, client_wrapper: SyncClientWrapper): | ||
| self._raw_client = RawBillableUnitsClient(client_wrapper=client_wrapper) | ||
|
|
||
| @property | ||
| def with_raw_response(self) -> RawBillableUnitsClient: | ||
| """ | ||
| Retrieves a raw implementation of this client that returns raw responses. | ||
|
|
||
| Returns | ||
| ------- | ||
| RawBillableUnitsClient | ||
| """ | ||
| return self._raw_client | ||
|
|
||
| def get( | ||
| self, | ||
| *, | ||
| from_timestamp: dt.datetime, | ||
| to_timestamp: dt.datetime, | ||
| granularity: typing.Optional[BillableUnitsGranularity] = None, | ||
| request_options: typing.Optional[RequestOptions] = None, | ||
| ) -> BillableUnitsResponse: | ||
| """ | ||
| Unstable: the shape may change without notice. | ||
|
|
||
| Billable units of the organization's projects, per UTC time bucket and | ||
| project. These are the numbers of the organization's Usage settings | ||
| tab. Requires an organization-scoped API key. | ||
|
|
||
| Units are counted by ingestion time in `[fromTimestamp, toTimestamp)` | ||
| as approximate distinct units per bucket (about 0.3% error on large | ||
| counts, small counts are exact). A unit counts once in every bucket it | ||
| appears in, so the counts stay close to, but are not exactly, what is | ||
| billed. Deployments still in the v3 `legacy` write mode count the rows | ||
| of the traces, observations and scores tables instead. | ||
|
|
||
| Buckets start at UTC hour, day, Monday or month boundaries. The first | ||
| and last bucket cover only the part inside the range, and a | ||
| `toTimestamp` in the future is cut off at now. Buckets and projects | ||
| without usage are left out, and so are deleted projects. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| from_timestamp : dt.datetime | ||
| Start of the range (inclusive), ISO 8601 with a time zone. | ||
|
|
||
| to_timestamp : dt.datetime | ||
| End of the range (exclusive), ISO 8601 with a time zone. At most 31 days after `fromTimestamp` for `hour` granularity, 366 days otherwise. | ||
|
|
||
| granularity : typing.Optional[BillableUnitsGranularity] | ||
| Bucket size. Defaults to `day`. | ||
|
|
||
| request_options : typing.Optional[RequestOptions] | ||
| Request-specific configuration. | ||
|
|
||
| Returns | ||
| ------- | ||
| BillableUnitsResponse | ||
|
|
||
| Examples | ||
| -------- | ||
| import datetime | ||
|
|
||
| from langfuse import LangfuseAPI | ||
|
|
||
| client = LangfuseAPI( | ||
| x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", | ||
| x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", | ||
| x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", | ||
| username="YOUR_USERNAME", | ||
| password="YOUR_PASSWORD", | ||
| base_url="https://yourhost.com/path/to/api", | ||
| ) | ||
| client.unstable.billable_units.get( | ||
| from_timestamp=datetime.datetime.fromisoformat( | ||
| "2024-01-15 09:30:00+00:00", | ||
| ), | ||
| to_timestamp=datetime.datetime.fromisoformat( | ||
| "2024-01-15 09:30:00+00:00", | ||
| ), | ||
| ) | ||
| """ | ||
| _response = self._raw_client.get( | ||
| from_timestamp=from_timestamp, | ||
| to_timestamp=to_timestamp, | ||
| granularity=granularity, | ||
| request_options=request_options, | ||
| ) | ||
| return _response.data | ||
|
|
||
|
|
||
| class AsyncBillableUnitsClient: | ||
| def __init__(self, *, client_wrapper: AsyncClientWrapper): | ||
| self._raw_client = AsyncRawBillableUnitsClient(client_wrapper=client_wrapper) | ||
|
|
||
| @property | ||
| def with_raw_response(self) -> AsyncRawBillableUnitsClient: | ||
| """ | ||
| Retrieves a raw implementation of this client that returns raw responses. | ||
|
|
||
| Returns | ||
| ------- | ||
| AsyncRawBillableUnitsClient | ||
| """ | ||
| return self._raw_client | ||
|
|
||
| async def get( | ||
| self, | ||
| *, | ||
| from_timestamp: dt.datetime, | ||
| to_timestamp: dt.datetime, | ||
| granularity: typing.Optional[BillableUnitsGranularity] = None, | ||
| request_options: typing.Optional[RequestOptions] = None, | ||
| ) -> BillableUnitsResponse: | ||
| """ | ||
| Unstable: the shape may change without notice. | ||
|
|
||
| Billable units of the organization's projects, per UTC time bucket and | ||
| project. These are the numbers of the organization's Usage settings | ||
| tab. Requires an organization-scoped API key. | ||
|
|
||
| Units are counted by ingestion time in `[fromTimestamp, toTimestamp)` | ||
| as approximate distinct units per bucket (about 0.3% error on large | ||
| counts, small counts are exact). A unit counts once in every bucket it | ||
| appears in, so the counts stay close to, but are not exactly, what is | ||
| billed. Deployments still in the v3 `legacy` write mode count the rows | ||
| of the traces, observations and scores tables instead. | ||
|
|
||
| Buckets start at UTC hour, day, Monday or month boundaries. The first | ||
| and last bucket cover only the part inside the range, and a | ||
| `toTimestamp` in the future is cut off at now. Buckets and projects | ||
| without usage are left out, and so are deleted projects. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| from_timestamp : dt.datetime | ||
| Start of the range (inclusive), ISO 8601 with a time zone. | ||
|
|
||
| to_timestamp : dt.datetime | ||
| End of the range (exclusive), ISO 8601 with a time zone. At most 31 days after `fromTimestamp` for `hour` granularity, 366 days otherwise. | ||
|
|
||
| granularity : typing.Optional[BillableUnitsGranularity] | ||
| Bucket size. Defaults to `day`. | ||
|
|
||
| request_options : typing.Optional[RequestOptions] | ||
| Request-specific configuration. | ||
|
|
||
| Returns | ||
| ------- | ||
| BillableUnitsResponse | ||
|
|
||
| Examples | ||
| -------- | ||
| import asyncio | ||
| import datetime | ||
|
|
||
| from langfuse import AsyncLangfuseAPI | ||
|
|
||
| client = AsyncLangfuseAPI( | ||
| x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", | ||
| x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", | ||
| x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", | ||
| username="YOUR_USERNAME", | ||
| password="YOUR_PASSWORD", | ||
| base_url="https://yourhost.com/path/to/api", | ||
| ) | ||
|
|
||
|
|
||
| async def main() -> None: | ||
| await client.unstable.billable_units.get( | ||
| from_timestamp=datetime.datetime.fromisoformat( | ||
| "2024-01-15 09:30:00+00:00", | ||
| ), | ||
| to_timestamp=datetime.datetime.fromisoformat( | ||
| "2024-01-15 09:30:00+00:00", | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| asyncio.run(main()) | ||
| """ | ||
| _response = await self._raw_client.get( | ||
| from_timestamp=from_timestamp, | ||
| to_timestamp=to_timestamp, | ||
| granularity=granularity, | ||
| request_options=request_options, | ||
| ) | ||
| return _response.data | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
getexamples pass identicalfrom_timestampandto_timestampvalues. The documented range excludes its end, so users copying either example request no time span rather than a useful usage report. Setto_timestamplater thanfrom_timestampin both examples.Prompt To Fix With AI