Skip to content

Commit 2e3cf13

Browse files
committed
remove validation
1 parent d070cf9 commit 2e3cf13

5 files changed

Lines changed: 16 additions & 18 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,18 @@ litellm.callbacks = [customHandler]
127127
response = await acompletion(
128128
model="gpt-3.5-turbo",
129129
messages=[{"role": "user", "content": "Hi 👋 - i'm openai"}],
130-
stream=True
130+
stream=True,
131+
metadata={
132+
"organization": "tinybird",
133+
"environment": "dev",
134+
"project": "litellm_test",
135+
"chat_id": "1234567890",
136+
},
131137
)
132138
```
133139

140+
Track custom metadata using the `metadata` dictionary.
141+
134142
This is the schema for the `litellm` data source:
135143

136144
```sql

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "tinybird-python-sdk"
7-
version = "0.3.2"
7+
version = "0.3.3"
88
description = "Python SDK for Tinybird"
99
readme = "README.md"
1010
authors = [

tb/a/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def __init__(
2525
TOKEN_ERROR = f"Token must be a valid Tinybird token for {self.api_url}. Check the `api_url` param is correct and the token has the right permissions. {self.ui_url()}/tokens"
2626
if not token:
2727
logging.critical(TOKEN_ERROR)
28-
sys.exit(-1)
2928
self.token = token
3029
self._session: Optional[aiohttp.ClientSession] = None
3130

tb/api.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def __init__(
2121
TOKEN_ERROR = f"Token must be a valid Tinybird token for {self.api_url}. Check the `api_url` param is correct and the token has the right permissions. {self.ui_url()}/tokens"
2222
if not token:
2323
logging.critical(TOKEN_ERROR)
24-
sys.exit(-1)
2524
self.token = token
2625
retry = Retry(total=retry_total, backoff_factor=backoff_factor)
2726
adapter = HTTPAdapter(max_retries=retry)
@@ -35,14 +34,6 @@ def __init__(
3534
self.rate_limit_reset = 0
3635
self.retry_after = 1
3736

38-
# check the token is valid
39-
try:
40-
self.get("/datasources")
41-
except requests.HTTPError as e:
42-
if e.response.status_code == 403:
43-
logging.error(TOKEN_ERROR)
44-
sys.exit(-1)
45-
4637
def ui_url(self):
4738
return self.api_url.replace("api", "ui")
4839

tb/litellm/handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ def __init__(
4040
self.api_url = api_url
4141
self.datasource_name = datasource_name
4242
self.api_version = api_version
43-
self.api = Tinybird(
44-
token=self.token, api_url=self.api_url, version=self.api_version
45-
)
46-
self.async_api = AsyncTinybird(
47-
token=self.token, api_url=self.api_url, version=self.api_version
48-
)
4943

5044
def _extract_data(self, kwargs, response_obj, start_time, end_time):
5145
api_key = kwargs.get("api_key")
@@ -108,6 +102,9 @@ def _extract_data(self, kwargs, response_obj, start_time, end_time):
108102
class TinybirdLitellmSyncHandler(TinybirdLitellmHandler):
109103
def __init__(self, *args, **kwargs):
110104
super().__init__(*args, **kwargs)
105+
self.api = Tinybird(
106+
token=self.token, api_url=self.api_url, version=self.api_version
107+
)
111108

112109
def log_success_event(self, kwargs, response_obj, start_time, end_time):
113110
try:
@@ -127,6 +124,9 @@ def log_failure_event(self, kwargs, response_obj, start_time, end_time):
127124
class TinybirdLitellmAsyncHandler(TinybirdLitellmHandler):
128125
def __init__(self, *args, **kwargs):
129126
super().__init__(*args, **kwargs)
127+
self.async_api = AsyncTinybird(
128+
token=self.token, api_url=self.api_url, version=self.api_version
129+
)
130130

131131
async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):
132132
try:

0 commit comments

Comments
 (0)