tinybird 0.0.1.dev20__py3-none-any.whl → 0.0.1.dev21__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/prompts.py +2 -2
- tinybird/tb/__cli__.py +2 -2
- tinybird/tb/modules/create.py +8 -6
- tinybird/tb/modules/llm.py +12 -25
- tinybird/tb/modules/local.py +8 -12
- tinybird/tb/modules/mock.py +1 -2
- tinybird/tb/modules/test.py +5 -4
- {tinybird-0.0.1.dev20.dist-info → tinybird-0.0.1.dev21.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev20.dist-info → tinybird-0.0.1.dev21.dist-info}/RECORD +12 -12
- {tinybird-0.0.1.dev20.dist-info → tinybird-0.0.1.dev21.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev20.dist-info → tinybird-0.0.1.dev21.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev20.dist-info → tinybird-0.0.1.dev21.dist-info}/top_level.txt +0 -0
tinybird/prompts.py
CHANGED
|
@@ -122,7 +122,7 @@ FROM numbers({rows})
|
|
|
122
122
|
|
|
123
123
|
"""
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
create_test_prompt = """
|
|
126
126
|
You are a Tinybird expert. You will be given a pipe endpoint containing different nodes with SQL and Tinybird templating syntax. You will generate URLs to test it with different parameters combinations.
|
|
127
127
|
|
|
128
128
|
<test>
|
|
@@ -141,6 +141,6 @@ You are a Tinybird expert. You will be given a pipe endpoint containing differen
|
|
|
141
141
|
- The test command can have as many parameters as are needed to test the pipe.
|
|
142
142
|
- The parameter within Tinybird templating syntax looks like this one {{String(my_param_name, default_value)}}.
|
|
143
143
|
- If there are no parameters in the , you can omit parametrs and generate a single test command.
|
|
144
|
-
- Extra context: {
|
|
144
|
+
- Extra context: {prompt}
|
|
145
145
|
</instructions>
|
|
146
146
|
"""
|
tinybird/tb/__cli__.py
CHANGED
|
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
|
|
|
4
4
|
__url__ = 'https://www.tinybird.co/docs/cli/introduction.html'
|
|
5
5
|
__author__ = 'Tinybird'
|
|
6
6
|
__author_email__ = 'support@tinybird.co'
|
|
7
|
-
__version__ = '0.0.1.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev21'
|
|
8
|
+
__revision__ = '523adc6'
|
tinybird/tb/modules/create.py
CHANGED
|
@@ -56,10 +56,11 @@ async def create(
|
|
|
56
56
|
folder = folder or getcwd()
|
|
57
57
|
try:
|
|
58
58
|
config = CLIConfig.get_project_config(folder)
|
|
59
|
+
user_token: Optional[str] = None
|
|
59
60
|
|
|
60
61
|
if prompt:
|
|
61
|
-
user_token = config.get_user_token()
|
|
62
62
|
try:
|
|
63
|
+
user_token = config.get_user_token()
|
|
63
64
|
if not user_token:
|
|
64
65
|
raise CLIException("No user token found")
|
|
65
66
|
await check_user_token(ctx, token=user_token)
|
|
@@ -69,7 +70,7 @@ async def create(
|
|
|
69
70
|
|
|
70
71
|
tb_client = config.get_client()
|
|
71
72
|
click.echo(FeedbackManager.gray(message="Creating new project structure..."))
|
|
72
|
-
await project_create(tb_client, data, prompt, folder)
|
|
73
|
+
await project_create(tb_client, user_token, data, prompt, folder)
|
|
73
74
|
click.echo(FeedbackManager.success(message="✓ Scaffolding completed!\n"))
|
|
74
75
|
|
|
75
76
|
click.echo(FeedbackManager.gray(message="\nCreating CI/CD files for GitHub and GitLab..."))
|
|
@@ -145,11 +146,11 @@ async def create(
|
|
|
145
146
|
)
|
|
146
147
|
click.echo(FeedbackManager.info(message=f"✓ /fixtures/{ds_name}"))
|
|
147
148
|
persist_fixture(fixture_name, data_content)
|
|
148
|
-
elif prompt:
|
|
149
|
+
elif prompt and user_token:
|
|
149
150
|
datasource_files = [f for f in os.listdir(Path(folder) / "datasources") if f.endswith(".datasource")]
|
|
150
151
|
for datasource_file in datasource_files:
|
|
151
152
|
datasource_path = Path(folder) / "datasources" / datasource_file
|
|
152
|
-
llm = LLM(client=tb_client)
|
|
153
|
+
llm = LLM(user_token=user_token, client=tb_client)
|
|
153
154
|
datasource_name = datasource_path.stem
|
|
154
155
|
datasource_content = datasource_path.read_text()
|
|
155
156
|
has_json_path = "`json:" in datasource_content
|
|
@@ -171,6 +172,7 @@ async def create(
|
|
|
171
172
|
|
|
172
173
|
async def project_create(
|
|
173
174
|
client: TinyB,
|
|
175
|
+
user_token: Optional[str],
|
|
174
176
|
data: Optional[str],
|
|
175
177
|
prompt: Optional[str],
|
|
176
178
|
folder: str,
|
|
@@ -203,9 +205,9 @@ TYPE ENDPOINT
|
|
|
203
205
|
""",
|
|
204
206
|
folder,
|
|
205
207
|
)
|
|
206
|
-
elif prompt:
|
|
208
|
+
elif prompt and user_token:
|
|
207
209
|
try:
|
|
208
|
-
llm = LLM(client=client)
|
|
210
|
+
llm = LLM(user_token=user_token, client=client)
|
|
209
211
|
result = await llm.create_project(prompt)
|
|
210
212
|
for ds in result.datasources:
|
|
211
213
|
content = ds.content.replace("```", "")
|
tinybird/tb/modules/llm.py
CHANGED
|
@@ -8,8 +8,6 @@ from openai import OpenAI
|
|
|
8
8
|
from pydantic import BaseModel
|
|
9
9
|
|
|
10
10
|
from tinybird.client import TinyB
|
|
11
|
-
from tinybird.prompts import create_test_calls_prompt
|
|
12
|
-
from tinybird.tb.modules.config import CLIConfig
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
class DataFile(BaseModel):
|
|
@@ -33,13 +31,10 @@ class TestExpectations(BaseModel):
|
|
|
33
31
|
|
|
34
32
|
|
|
35
33
|
class LLM:
|
|
36
|
-
def __init__(self, client: TinyB, api_key: Optional[str] = None):
|
|
37
|
-
self.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if user_token:
|
|
41
|
-
user_client.token = user_token
|
|
42
|
-
self.user_client = user_client
|
|
34
|
+
def __init__(self, user_token: str, client: TinyB, api_key: Optional[str] = None):
|
|
35
|
+
self.user_client = deepcopy(client)
|
|
36
|
+
self.user_client.token = user_token
|
|
37
|
+
|
|
43
38
|
self.openai = OpenAI(api_key=api_key) if api_key else None
|
|
44
39
|
|
|
45
40
|
async def _execute(self, action_fn: Callable[[], Awaitable[str]], checker_fn: Callable[[str], bool]):
|
|
@@ -79,20 +74,12 @@ class LLM:
|
|
|
79
74
|
result = response.get("result", "")
|
|
80
75
|
return result.replace("elementAt", "arrayElement")
|
|
81
76
|
|
|
82
|
-
async def
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
completion = self.openai.beta.chat.completions.parse(
|
|
89
|
-
model="gpt-4o",
|
|
90
|
-
messages=[
|
|
91
|
-
{"role": "system", "content": create_test_calls_prompt.format(context=context or "")},
|
|
92
|
-
{"role": "user", "content": f"Pipe content: {pipe_content}\nPipe params: {pipe_params}"},
|
|
93
|
-
],
|
|
94
|
-
temperature=0.2,
|
|
95
|
-
seed=42,
|
|
96
|
-
response_format=TestExpectations,
|
|
77
|
+
async def create_tests(self, pipe_content: str, pipe_params: set[str], prompt: str = "") -> TestExpectations:
|
|
78
|
+
response = await self.user_client._req(
|
|
79
|
+
"/v0/llm/create/tests",
|
|
80
|
+
method="POST",
|
|
81
|
+
data=json.dumps({"pipe_content": pipe_content, "pipe_params": list(pipe_params), "prompt": prompt}),
|
|
82
|
+
headers={"Content-Type": "application/json"},
|
|
97
83
|
)
|
|
98
|
-
|
|
84
|
+
result = response.get("result", "")
|
|
85
|
+
return TestExpectations.model_validate(result)
|
tinybird/tb/modules/local.py
CHANGED
|
@@ -59,18 +59,14 @@ def start_tinybird_local(
|
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
click.echo(FeedbackManager.info(message="* Waiting for Tinybird Local to be ready..."))
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
except Exception:
|
|
71
|
-
if attempt == 9: # Last attempt
|
|
72
|
-
raise CLIException("Tinybird Local not ready yet. Please try again in a few seconds.")
|
|
73
|
-
time.sleep(5) # Wait 5 seconds before retrying
|
|
62
|
+
while True:
|
|
63
|
+
health = container.attrs.get("State", {}).get("Health", {}).get("Status")
|
|
64
|
+
if health == "healthy":
|
|
65
|
+
break
|
|
66
|
+
if health == "unhealthy":
|
|
67
|
+
raise CLIException("Tinybird Local is unhealthy. Please try running `tb local restart` in a few seconds.")
|
|
68
|
+
|
|
69
|
+
time.sleep(5)
|
|
74
70
|
|
|
75
71
|
# Remove tinybird-local dangling images to avoid running out of disk space
|
|
76
72
|
images = docker_client.images.list(name=re.sub(r":.*$", "", TB_IMAGE_NAME), all=True, filters={"dangling": True})
|
tinybird/tb/modules/mock.py
CHANGED
|
@@ -41,7 +41,6 @@ async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str, fold
|
|
|
41
41
|
if not prompt:
|
|
42
42
|
# load the prompt from the fixture.prompt file if it exists
|
|
43
43
|
if prompt_path.exists():
|
|
44
|
-
click.echo(FeedbackManager.gray(message=f"Using prompt for {prompt_path}..."))
|
|
45
44
|
prompt = prompt_path.read_text()
|
|
46
45
|
else:
|
|
47
46
|
click.echo(FeedbackManager.gray(message=f"Overriding prompt for {datasource_name}..."))
|
|
@@ -61,7 +60,7 @@ async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str, fold
|
|
|
61
60
|
click.echo(FeedbackManager.error(message="This action requires authentication. Run 'tb login' first."))
|
|
62
61
|
return
|
|
63
62
|
|
|
64
|
-
llm = LLM(client=user_client)
|
|
63
|
+
llm = LLM(user_token=user_token, client=user_client)
|
|
65
64
|
tb_client = await get_tinybird_local_client(os.path.abspath(folder))
|
|
66
65
|
sql = await llm.generate_sql_sample_data(datasource_content, rows=rows, prompt=prompt)
|
|
67
66
|
if os.environ.get("TB_DEBUG", "") != "":
|
tinybird/tb/modules/test.py
CHANGED
|
@@ -89,11 +89,12 @@ async def test_create(pipe: str, prompt: Optional[str], folder: str) -> None:
|
|
|
89
89
|
pipe_nodes = await client._req(f"/v0/pipes/{pipe_name}")
|
|
90
90
|
pipe_params = set([param["name"] for node in pipe_nodes["nodes"] for param in node["params"]])
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
config = CLIConfig.get_project_config(folder)
|
|
93
|
+
user_token = config.get_user_token()
|
|
94
|
+
llm = LLM(user_token=user_token, client=config.get_client())
|
|
94
95
|
|
|
95
|
-
test_expectations = await llm.
|
|
96
|
-
pipe_content=pipe_content, pipe_params=pipe_params,
|
|
96
|
+
test_expectations = await llm.create_tests(
|
|
97
|
+
pipe_content=pipe_content, pipe_params=pipe_params, prompt=prompt or ""
|
|
97
98
|
)
|
|
98
99
|
valid_test_expectations = []
|
|
99
100
|
for test in test_expectations.tests:
|
|
@@ -6,7 +6,7 @@ tinybird/context.py,sha256=kutUQ0kCwparowI74_YLXx6wtTzGLRouJ6oGHVBPzBo,1291
|
|
|
6
6
|
tinybird/datatypes.py,sha256=IHyhZ86ib54Vnd1pbod9y2aS8DDvDKZm1HJGlThdbuQ,10460
|
|
7
7
|
tinybird/feedback_manager.py,sha256=cNUbt0Jxim02UiIdlyP12DJfXfFFzxDCfJK9XRWZ9A0,67488
|
|
8
8
|
tinybird/git_settings.py,sha256=XUL9ZUj59-ZVQJDYmMEq4UpnuuOuQOHGlNcX3JgQHjQ,3954
|
|
9
|
-
tinybird/prompts.py,sha256=
|
|
9
|
+
tinybird/prompts.py,sha256=t2AuOlyBy7dEOuZcUVZzTXExP7VnK337u7z-GftSY-Q,6410
|
|
10
10
|
tinybird/sql.py,sha256=gfRKjdqEygcE1WOTeQ1QV2Jal8Jzl4RSX8fftu1KSEs,45825
|
|
11
11
|
tinybird/sql_template.py,sha256=IqYRfUxDYBCoOYjqqvn--_8QXLv9FSRnJ0bInx7q1Xs,93051
|
|
12
12
|
tinybird/sql_template_fmt.py,sha256=1z-PuqSZXtzso8Z_mPqUc-NxIxUrNUcVIPezNieZk-M,10196
|
|
@@ -15,7 +15,7 @@ tinybird/syncasync.py,sha256=fAvq0qkRgqXqXMKwbY2iJNYqLT_r6mDsh1MRpGKrdRU,27763
|
|
|
15
15
|
tinybird/tornado_template.py,sha256=o2HguxrL1Evnt8o3IvrsI8Zm6JtRQ3zhLJKf1XyR3SQ,41965
|
|
16
16
|
tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
|
|
17
17
|
tinybird/ch_utils/engine.py,sha256=OXkBhlzGjZotjD0vaT-rFIbSGV4tpiHxE8qO_ip0SyQ,40454
|
|
18
|
-
tinybird/tb/__cli__.py,sha256=
|
|
18
|
+
tinybird/tb/__cli__.py,sha256=1VxxptKXBoOejwGSsyZYVR5OdTVsLgpfAiAB6C5DI3c,251
|
|
19
19
|
tinybird/tb/cli.py,sha256=onCxcKvTV4RuokC5V3t82OXWAIwgU6pMWs8rpWOUi_o,815
|
|
20
20
|
tinybird/tb/modules/auth.py,sha256=EzRWFmwRkXNhUmRaruEVFLdkbUg8xMSix0cAWl5D4Jg,9029
|
|
21
21
|
tinybird/tb/modules/build.py,sha256=qJsmJCphanQitSnv86dqeoThM7mOg9Yg9JJLQjQ56ws,7074
|
|
@@ -24,24 +24,24 @@ tinybird/tb/modules/cli.py,sha256=rHfc93DFFSQfWrAX-JBFrcZF43ttk7lYtYTBTn9TdMU,20
|
|
|
24
24
|
tinybird/tb/modules/common.py,sha256=shaF6GIl2L9e3Rm8aFsIIollSNSBsb2ozBklpnsmRTc,70560
|
|
25
25
|
tinybird/tb/modules/config.py,sha256=ri4Gwyzqol6-NofTjHnWquuDzJOjHbkaAnboO8JNENY,11499
|
|
26
26
|
tinybird/tb/modules/connection.py,sha256=FhDM-OAnLN2epbO2YonpjJQhHqBjyuanBsZmKlDXrqg,28679
|
|
27
|
-
tinybird/tb/modules/create.py,sha256=
|
|
27
|
+
tinybird/tb/modules/create.py,sha256=kHmHoPIXh7V1opRzKKDm0q4UbZ6rz9tJwWMsUroA3I8,10371
|
|
28
28
|
tinybird/tb/modules/datasource.py,sha256=3ySFOTXVnuqwQQNJBYhD8Sq41S2BJO2ymZRsFmEvHqY,32899
|
|
29
29
|
tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw04mY,3363
|
|
30
30
|
tinybird/tb/modules/feedback_manager.py,sha256=a76KSrIdtNT5cs56jMYUfpqoXMwEPq_SErRGlX0i4hc,68384
|
|
31
31
|
tinybird/tb/modules/fmt.py,sha256=poh6_cwVGSf-sBu6LKWuO2TANL_J8Sgm25sPpwxa3Aw,3558
|
|
32
32
|
tinybird/tb/modules/job.py,sha256=956Pj8BEEsiD2GZsV9RKKVM3I_CveOLgS82lykO5ukk,2963
|
|
33
|
-
tinybird/tb/modules/llm.py,sha256=
|
|
34
|
-
tinybird/tb/modules/local.py,sha256=
|
|
33
|
+
tinybird/tb/modules/llm.py,sha256=9oJzI213eFv68Ttcfl3XNgEetaxfr6m56s2-IyBhNZ8,2713
|
|
34
|
+
tinybird/tb/modules/local.py,sha256=xWUVQzGw2bdWrezJd2Qa3YmXnpg4VdGtQduJpPfKMck,5194
|
|
35
35
|
tinybird/tb/modules/local_common.py,sha256=oemeKBCdEkNHXuGv1p6I9vhjkSXvqDsV5kT-rPN3mvk,2145
|
|
36
36
|
tinybird/tb/modules/login.py,sha256=KYGpM35fsjIVkp04Xm1kHvlEOXysRSvLfBUNTxNx26A,6044
|
|
37
|
-
tinybird/tb/modules/mock.py,sha256=
|
|
37
|
+
tinybird/tb/modules/mock.py,sha256=BbDe60Qdlxg5-WewxFYRPETNBExj1qqBn5Ngz5T8G2Q,3231
|
|
38
38
|
tinybird/tb/modules/pipe.py,sha256=eYmMBiSj1Ur_hXUs74YZ9mCSAyiICDmkuKuTemlxPUY,27018
|
|
39
39
|
tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
40
40
|
tinybird/tb/modules/shell.py,sha256=OfFQ4lx3v_XSTr5cm_mTDG6CLc3zFdikM2pOamifG84,13469
|
|
41
41
|
tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
|
|
42
42
|
tinybird/tb/modules/tag.py,sha256=anPmMUBc-TbFovlpFi8GPkKA18y7Y0GczMsMms5TZsU,3502
|
|
43
43
|
tinybird/tb/modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
|
|
44
|
-
tinybird/tb/modules/test.py,sha256=
|
|
44
|
+
tinybird/tb/modules/test.py,sha256=loB9lNbtHuHcF9TwBJJLEkSyQakxnyUTHmCFYVsMnDA,8833
|
|
45
45
|
tinybird/tb/modules/token.py,sha256=AePr-QMv_vtWwZDWQ92Zp0kPrCjze61i4npiPhoLMZg,12717
|
|
46
46
|
tinybird/tb/modules/watch.py,sha256=xCIUvqTgeb2s63CYw26czgUGV3zzJpdmuyHGH2TLp1E,2349
|
|
47
47
|
tinybird/tb/modules/workspace.py,sha256=6icAgnTvfL3d1kx4L1Z1cGXCD_2Yx0fNRjbZHNxRbYc,10927
|
|
@@ -69,8 +69,8 @@ tinybird/tb_cli_modules/config.py,sha256=6NTgIdwf0X132A1j6G_YrdPep87ymZ9b5pABabK
|
|
|
69
69
|
tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
|
|
70
70
|
tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
71
71
|
tinybird/tb_cli_modules/telemetry.py,sha256=iEGnMuCuNhvF6ln__j6X9MSTwL_0Hm-GgFHHHvhfknk,10466
|
|
72
|
-
tinybird-0.0.1.
|
|
73
|
-
tinybird-0.0.1.
|
|
74
|
-
tinybird-0.0.1.
|
|
75
|
-
tinybird-0.0.1.
|
|
76
|
-
tinybird-0.0.1.
|
|
72
|
+
tinybird-0.0.1.dev21.dist-info/METADATA,sha256=FMzNtUcWW-VbxL1Fvu5zVrBsEJb0mDEowNSDKibTL0U,2446
|
|
73
|
+
tinybird-0.0.1.dev21.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
74
|
+
tinybird-0.0.1.dev21.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
75
|
+
tinybird-0.0.1.dev21.dist-info/top_level.txt,sha256=pgw6AzERHBcW3YTi2PW4arjxLkulk2msOz_SomfOEuc,45
|
|
76
|
+
tinybird-0.0.1.dev21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|