Skip to content

Commit

Permalink
feat(media): broaden content type support
Browse files Browse the repository at this point in the history
  • Loading branch information
hassiebp committed Nov 26, 2024
1 parent dd25492 commit d02dc1b
Show file tree
Hide file tree
Showing 109 changed files with 3,084 additions and 1,061 deletions.
9 changes: 5 additions & 4 deletions langfuse/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Instantiate and use the client with the following:

```python
from finto import CreateCommentRequest
from finto.client import FernLangfuse
from langfuse.api.client import FernLangfuse

client = FernLangfuse(
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
Expand Down Expand Up @@ -46,7 +46,7 @@ The SDK also exports an `async` client so that you can make non-blocking calls t
import asyncio

from finto import CreateCommentRequest
from finto.client import AsyncFernLangfuse
from langfuse.api.client import AsyncFernLangfuse

client = AsyncFernLangfuse(
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
Expand Down Expand Up @@ -116,7 +116,7 @@ The SDK defaults to a 60 second timeout. You can configure this with a timeout o

```python

from finto.client import FernLangfuse
from langfuse.api.client import FernLangfuse

client = FernLangfuse(..., { timeout=20.0 }, )

Expand All @@ -131,9 +131,10 @@ client.comments.create(...,{

You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
and transports.

```python
import httpx
from finto.client import FernLangfuse
from langfuse.api.client import FernLangfuse

client = FernLangfuse(
...,
Expand Down
4 changes: 2 additions & 2 deletions langfuse/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FernLangfuse:
Examples
--------
from finto.client import FernLangfuse
from langfuse.api.client import FernLangfuse
client = FernLangfuse(
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
Expand Down Expand Up @@ -140,7 +140,7 @@ class AsyncFernLangfuse:
Examples
--------
from finto.client import AsyncFernLangfuse
from langfuse.api.client import AsyncFernLangfuse
client = AsyncFernLangfuse(
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
Expand Down
4 changes: 3 additions & 1 deletion langfuse/api/core/api_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class ApiError(Exception):
status_code: typing.Optional[int]
body: typing.Any

def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None):
def __init__(
self, *, status_code: typing.Optional[int] = None, body: typing.Any = None
):
self.status_code = status_code
self.body = body

Expand Down
6 changes: 3 additions & 3 deletions langfuse/api/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(
username: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
base_url: str,
timeout: typing.Optional[float] = None
timeout: typing.Optional[float] = None,
):
self._x_langfuse_sdk_name = x_langfuse_sdk_name
self._x_langfuse_sdk_version = x_langfuse_sdk_version
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(
password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
base_url: str,
timeout: typing.Optional[float] = None,
httpx_client: httpx.Client
httpx_client: httpx.Client,
):
super().__init__(
x_langfuse_sdk_name=x_langfuse_sdk_name,
Expand Down Expand Up @@ -101,7 +101,7 @@ def __init__(
password: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
base_url: str,
timeout: typing.Optional[float] = None,
httpx_client: httpx.AsyncClient
httpx_client: httpx.AsyncClient,
):
super().__init__(
x_langfuse_sdk_name=x_langfuse_sdk_name,
Expand Down
4 changes: 3 additions & 1 deletion langfuse/api/core/datetime_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def serialize_datetime(v: dt.datetime) -> str:
"""

def _serialize_zoned_datetime(v: dt.datetime) -> str:
if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(
None
):
# UTC is a special case where we use "Z" at the end instead of "+00:00"
return v.isoformat().replace("+00:00", "Z")
else:
Expand Down
9 changes: 7 additions & 2 deletions langfuse/api/core/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
# (filename, file (or bytes), content_type)
typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]],
# (filename, file (or bytes), content_type, headers)
typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str], typing.Mapping[str, str]],
typing.Tuple[
typing.Optional[str],
FileContent,
typing.Optional[str],
typing.Mapping[str, str],
],
]


def convert_file_dict_to_httpx_tuples(
d: typing.Dict[str, typing.Union[File, typing.List[File]]]
d: typing.Dict[str, typing.Union[File, typing.List[File]]],
) -> typing.List[typing.Tuple[str, File]]:
"""
The format we use is a list of tuples, where the first element is the
Expand Down
Loading

0 comments on commit d02dc1b

Please sign in to comment.