tinybird 0.0.1.dev226__py3-none-any.whl → 0.0.1.dev227__py3-none-any.whl
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.
Potentially problematic release.
This version of tinybird might be problematic. Click here for more details.
- tinybird/tb/__cli__.py +2 -2
- tinybird/tb/modules/create.py +3 -1
- tinybird/tb/modules/datasource.py +2 -1
- tinybird/tb/modules/llm.py +17 -4
- tinybird/tb/modules/mock.py +4 -2
- tinybird/tb/modules/test.py +1 -1
- {tinybird-0.0.1.dev226.dist-info → tinybird-0.0.1.dev227.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev226.dist-info → tinybird-0.0.1.dev227.dist-info}/RECORD +11 -11
- {tinybird-0.0.1.dev226.dist-info → tinybird-0.0.1.dev227.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev226.dist-info → tinybird-0.0.1.dev227.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev226.dist-info → tinybird-0.0.1.dev227.dist-info}/top_level.txt +0 -0
tinybird/tb/__cli__.py
CHANGED
|
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
|
|
|
4
4
|
__url__ = 'https://www.tinybird.co/docs/forward/commands'
|
|
5
5
|
__author__ = 'Tinybird'
|
|
6
6
|
__author_email__ = 'support@tinybird.co'
|
|
7
|
-
__version__ = '0.0.1.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev227'
|
|
8
|
+
__revision__ = 'fb681ea'
|
tinybird/tb/modules/create.py
CHANGED
|
@@ -116,6 +116,7 @@ async def create(
|
|
|
116
116
|
readme_path.read_text(), tb_client.host, "$TB_ADMIN_TOKEN", all_resources_xml
|
|
117
117
|
),
|
|
118
118
|
prompt=readme_user_prompt,
|
|
119
|
+
feature="tb_create_readme",
|
|
119
120
|
)
|
|
120
121
|
readme_result = extract_xml(readme_response, "readme")
|
|
121
122
|
readme_path.write_text(readme_result)
|
|
@@ -295,6 +296,7 @@ async def create_resources_from_prompt(
|
|
|
295
296
|
user_token: str,
|
|
296
297
|
prompt: str,
|
|
297
298
|
project: Project,
|
|
299
|
+
feature: str = "tb_create_resources",
|
|
298
300
|
) -> List[Path]:
|
|
299
301
|
result: List[Path] = []
|
|
300
302
|
datasource_paths = [Path(ds_file) for ds_file in project.get_datasource_files()]
|
|
@@ -325,7 +327,7 @@ async def create_resources_from_prompt(
|
|
|
325
327
|
]
|
|
326
328
|
)
|
|
327
329
|
llm = LLM(user_token=user_token, host=tb_client.host)
|
|
328
|
-
prompt_result = llm.ask(system_prompt=create_prompt(resources_xml), prompt=prompt)
|
|
330
|
+
prompt_result = llm.ask(system_prompt=create_prompt(resources_xml), prompt=prompt, feature=feature)
|
|
329
331
|
prompt_result = extract_xml(prompt_result, "response")
|
|
330
332
|
resources = parse_xml(prompt_result, "resource")
|
|
331
333
|
datasources = []
|
|
@@ -781,7 +781,7 @@ async def datasource_create(
|
|
|
781
781
|
raise Exception("This action requires authentication. Run 'tb login' first.")
|
|
782
782
|
project_config = CLIConfig.get_project_config()
|
|
783
783
|
tb_client: TinyB = project_config.get_client(token=config.get("token"), host=config.get("host"))
|
|
784
|
-
await create_resources_from_prompt(tb_client, user_token, prompt, project)
|
|
784
|
+
await create_resources_from_prompt(tb_client, user_token, prompt, project, feature="tb_datasource_create")
|
|
785
785
|
click.echo(FeedbackManager.success(message="✓ .datasource created!"))
|
|
786
786
|
return
|
|
787
787
|
|
|
@@ -1023,6 +1023,7 @@ async def analyze_quarantine(datasource_name: str, project: Project, client: Tin
|
|
|
1023
1023
|
response_llm = llm.ask(
|
|
1024
1024
|
system_prompt=quarantine_prompt(datasource_definition),
|
|
1025
1025
|
prompt=f"The quarantine errors are:\n{json.dumps(quarantine_data)}",
|
|
1026
|
+
feature="tb_datasource_append_analyze_quarantine",
|
|
1026
1027
|
)
|
|
1027
1028
|
response = extract_xml(response_llm, "quarantine_errors")
|
|
1028
1029
|
error_message += "\n" + response
|
tinybird/tb/modules/llm.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import urllib.parse
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
1
4
|
import requests
|
|
2
5
|
|
|
6
|
+
from tinybird.tb.modules.cli import CLIConfig
|
|
3
7
|
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
4
8
|
|
|
5
9
|
|
|
@@ -16,7 +20,7 @@ class LLM:
|
|
|
16
20
|
self.host = host
|
|
17
21
|
self.user_token = user_token
|
|
18
22
|
|
|
19
|
-
def ask(self, system_prompt: str, prompt: str) -> str:
|
|
23
|
+
def ask(self, system_prompt: str, prompt: str, feature: Optional[str] = None) -> str:
|
|
20
24
|
"""
|
|
21
25
|
Calls the model with the given prompt and returns the response.
|
|
22
26
|
|
|
@@ -29,14 +33,23 @@ class LLM:
|
|
|
29
33
|
"""
|
|
30
34
|
|
|
31
35
|
data = {"system": system_prompt, "prompt": prompt}
|
|
32
|
-
|
|
36
|
+
params = {"origin": "cli"}
|
|
37
|
+
if feature:
|
|
38
|
+
params["feature"] = feature
|
|
39
|
+
cli_config = CLIConfig.get_project_config()
|
|
40
|
+
workspace_id = cli_config.get("id")
|
|
41
|
+
params_str = urllib.parse.urlencode(params)
|
|
42
|
+
if workspace_id:
|
|
43
|
+
llm_url = f"{self.host}/v0/llm/{workspace_id}?{params_str}"
|
|
44
|
+
else:
|
|
45
|
+
llm_url = f"{self.host}/v0/llm?{params_str}"
|
|
33
46
|
response = requests.post(
|
|
34
|
-
|
|
47
|
+
llm_url,
|
|
35
48
|
headers={"Authorization": f"Bearer {self.user_token}"},
|
|
36
49
|
data=data,
|
|
37
50
|
)
|
|
38
51
|
|
|
39
52
|
if not response.ok:
|
|
40
|
-
raise LLMException(FeedbackManager.
|
|
53
|
+
raise LLMException(FeedbackManager.error(message=response.text))
|
|
41
54
|
|
|
42
55
|
return response.json().get("result", "")
|
tinybird/tb/modules/mock.py
CHANGED
|
@@ -132,7 +132,7 @@ async def create_mock_data(
|
|
|
132
132
|
sql_path = None
|
|
133
133
|
while True:
|
|
134
134
|
try:
|
|
135
|
-
response = llm.ask(system_prompt=mock_prompt(rows, error), prompt=prompt)
|
|
135
|
+
response = llm.ask(system_prompt=mock_prompt(rows, error), prompt=prompt, feature="tb_mock")
|
|
136
136
|
sql = extract_xml(response, "sql")
|
|
137
137
|
sql_path = persist_fixture_sql(datasource_name, sql, folder)
|
|
138
138
|
sql_format = "JSON" if format_ == "ndjson" else "CSV"
|
|
@@ -149,7 +149,9 @@ async def create_mock_data(
|
|
|
149
149
|
error = str(e)
|
|
150
150
|
attempts += 1
|
|
151
151
|
if attempts > 5:
|
|
152
|
-
raise Exception(
|
|
152
|
+
raise Exception(
|
|
153
|
+
f"Failed to generate a valid solution. Check {str(sql_path or '.sql path')} and try again."
|
|
154
|
+
)
|
|
153
155
|
else:
|
|
154
156
|
continue
|
|
155
157
|
return data
|
tinybird/tb/modules/test.py
CHANGED
|
@@ -102,7 +102,7 @@ def test_create(ctx: click.Context, name_or_filename: str, prompt: str) -> None:
|
|
|
102
102
|
raise Exception("No user token found")
|
|
103
103
|
|
|
104
104
|
llm = LLM(user_token=user_token, host=config.get_client().host)
|
|
105
|
-
response_llm = llm.ask(system_prompt=system_prompt, prompt=prompt)
|
|
105
|
+
response_llm = llm.ask(system_prompt=system_prompt, prompt=prompt, feature="tb_test_create")
|
|
106
106
|
response_xml = extract_xml(response_llm, "response")
|
|
107
107
|
tests_content = parse_xml(response_xml, "test")
|
|
108
108
|
|
|
@@ -17,7 +17,7 @@ tinybird/datafile/exceptions.py,sha256=8rw2umdZjtby85QbuRKFO5ETz_eRHwUY5l7eHsy1w
|
|
|
17
17
|
tinybird/datafile/parse_connection.py,sha256=tRyn2Rpr1TeWet5BXmMoQgaotbGdYep1qiTak_OqC5E,1825
|
|
18
18
|
tinybird/datafile/parse_datasource.py,sha256=ssW8QeFSgglVFi3sDZj_HgkJiTJ2069v2JgqnH3CkDE,1825
|
|
19
19
|
tinybird/datafile/parse_pipe.py,sha256=xf4m0Tw44QWJzHzAm7Z7FwUoUUtr7noMYjU1NiWnX0k,3880
|
|
20
|
-
tinybird/tb/__cli__.py,sha256=
|
|
20
|
+
tinybird/tb/__cli__.py,sha256=bdwbydz09zd69DBetuXj8DqeYT9D9ltPTGrpVsC4rT8,247
|
|
21
21
|
tinybird/tb/check_pypi.py,sha256=i3l2L8IajeB7sreikR7oPlYJki9MtS3c_M4crnmbByc,760
|
|
22
22
|
tinybird/tb/cli.py,sha256=0xYk2Ip4vb3nNFbxfTdG3VoIgdRvUKVbUVU_mviErPA,1107
|
|
23
23
|
tinybird/tb/client.py,sha256=FKj61vY9STPW03kfVcxYuY1_csI-kP-mc1ERQfqJtg8,56505
|
|
@@ -29,8 +29,8 @@ tinybird/tb/modules/common.py,sha256=F6oaoFZ3aBxEMjiDKYhthsEIUqSFPkcdlMJ7h7A49Ac
|
|
|
29
29
|
tinybird/tb/modules/config.py,sha256=VnzYVUo4q1RBEEMMce4_OCrKp4erhgkRPHElydVlKj0,11488
|
|
30
30
|
tinybird/tb/modules/connection.py,sha256=dAOv8z3ym9Tt62j7AI8R9PgFwgiCIFdgIMpUiMdtxaQ,18906
|
|
31
31
|
tinybird/tb/modules/copy.py,sha256=zHN1d5NA-MFsgbk2kKJq2P9qA8dNOnIsIa60QpVnSwc,4458
|
|
32
|
-
tinybird/tb/modules/create.py,sha256=
|
|
33
|
-
tinybird/tb/modules/datasource.py,sha256=
|
|
32
|
+
tinybird/tb/modules/create.py,sha256=Ht8Ze-iVqgpVUIVWyGcXnkuh9D5D4Bg_dXK_-XH200U,23317
|
|
33
|
+
tinybird/tb/modules/datasource.py,sha256=UiQXDkSEmQIPj4NcUD_I4bAJe9IGVmlVW07yGgSu6kY,40941
|
|
34
34
|
tinybird/tb/modules/deployment.py,sha256=ByXIgEvwxB49pJEKKj0EJIfORWyflCYr04k8961nBkA,28391
|
|
35
35
|
tinybird/tb/modules/deprecations.py,sha256=rrszC1f_JJeJ8mUxGoCxckQTJFBCR8wREf4XXXN-PRc,4507
|
|
36
36
|
tinybird/tb/modules/dev_server.py,sha256=57FCKuWpErwYUYgHspYDkLWEm9F4pbvVOtMrFXX1fVU,10129
|
|
@@ -40,14 +40,14 @@ tinybird/tb/modules/feedback_manager.py,sha256=SMaoDjz-JGfh6hUxRiaGf2JOYZa_afDL8
|
|
|
40
40
|
tinybird/tb/modules/info.py,sha256=NqSsoyzFqbtUEGH_tSowNOI_jSsNuixibln6-plsfOY,6810
|
|
41
41
|
tinybird/tb/modules/infra.py,sha256=fve30Gj3mG9zbquGxS2e4ipcOYOxviWQCpNFfEzJN_Q,33195
|
|
42
42
|
tinybird/tb/modules/job.py,sha256=AsUCRNzy7HG5oJ4fyk9NpIm5NtNJgBZSy8MtJdXBe5A,3167
|
|
43
|
-
tinybird/tb/modules/llm.py,sha256=
|
|
43
|
+
tinybird/tb/modules/llm.py,sha256=QbHRcMLgFmLKEh4zVb2ctR_5tIGUGdFJrAiRCDtMxDw,1572
|
|
44
44
|
tinybird/tb/modules/llm_utils.py,sha256=nS9r4FAElJw8yXtmdYrx-rtI2zXR8qXfi1QqUDCfxvg,3469
|
|
45
45
|
tinybird/tb/modules/local.py,sha256=TWT7pGXQ3cOy0M_piyw7WhrzoxZE18PmfOLzHD5CoEc,6096
|
|
46
46
|
tinybird/tb/modules/local_common.py,sha256=8CSEVygFi0fIISatYxCStcHizugXCA9WNTLO_zDKmXw,17195
|
|
47
47
|
tinybird/tb/modules/login.py,sha256=VxxCzyjG5dpFm1lmlNPVcM-0-jqURAFp4HEkMMBdiGo,12617
|
|
48
48
|
tinybird/tb/modules/logout.py,sha256=sniI4JNxpTrVeRCp0oGJuQ3yRerG4hH5uz6oBmjv724,1009
|
|
49
49
|
tinybird/tb/modules/materialization.py,sha256=neugOziGfh50GSOgfZJX8giVPKgauoE313LUw6kXowo,5467
|
|
50
|
-
tinybird/tb/modules/mock.py,sha256=
|
|
50
|
+
tinybird/tb/modules/mock.py,sha256=pp7NN79chzStHua4FKVMejI6NLYvzXjP6P7nzf6nSxM,5375
|
|
51
51
|
tinybird/tb/modules/open.py,sha256=OuctINN77oexpSjth9uoIZPCelKO4Li-yyVxeSnk1io,1371
|
|
52
52
|
tinybird/tb/modules/pipe.py,sha256=ExDOk3ze76JacNEVrN4DbIopNvSurDCSR7QR9ii2xGQ,2421
|
|
53
53
|
tinybird/tb/modules/project.py,sha256=pOcvtgsR0ibPi0sNu-6GuAI4WS2DORRALezisjN3xY8,5662
|
|
@@ -57,7 +57,7 @@ tinybird/tb/modules/shell.py,sha256=Zd_4Ak_5tKVX-cw6B4ag36xZeEGHeh-jZpAsIXkoMoE,
|
|
|
57
57
|
tinybird/tb/modules/sink.py,sha256=bIjLjog4XH42yfp944cMnaE4il7Kl7Wn7F-nLKfH2Bc,3913
|
|
58
58
|
tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
|
|
59
59
|
tinybird/tb/modules/telemetry.py,sha256=T9gtsQffWqG_4hRBaUJPzOfMkPwz7mH-R6Bn1XRYViA,11482
|
|
60
|
-
tinybird/tb/modules/test.py,sha256=
|
|
60
|
+
tinybird/tb/modules/test.py,sha256=ZRWzrYcoaUB16pAEAxtCaE0rgc1srMx7VuOTqvrpsjk,13318
|
|
61
61
|
tinybird/tb/modules/token.py,sha256=pSlDed5RzcadJlvIKQh22Y49gt1Rfw-0rCTko6x4y3g,12879
|
|
62
62
|
tinybird/tb/modules/watch.py,sha256=HhruZoUrehlxL_nFIK3BlpHp2uyzKAM9cmNXBCa4Zgs,8965
|
|
63
63
|
tinybird/tb/modules/workspace.py,sha256=ngn5yGG9K9sFaUzm0W42j_vQnm3pQS2Jh38GNgbMtP0,11607
|
|
@@ -82,8 +82,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
|
|
|
82
82
|
tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
|
|
83
83
|
tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
84
84
|
tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
|
|
85
|
-
tinybird-0.0.1.
|
|
86
|
-
tinybird-0.0.1.
|
|
87
|
-
tinybird-0.0.1.
|
|
88
|
-
tinybird-0.0.1.
|
|
89
|
-
tinybird-0.0.1.
|
|
85
|
+
tinybird-0.0.1.dev227.dist-info/METADATA,sha256=ATySV79DRVsR1RBCe2jBBvtCvhieE6I4n25hd5K0XqU,1682
|
|
86
|
+
tinybird-0.0.1.dev227.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
87
|
+
tinybird-0.0.1.dev227.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
88
|
+
tinybird-0.0.1.dev227.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
|
|
89
|
+
tinybird-0.0.1.dev227.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|