tinybird 0.0.1.dev101__py3-none-any.whl → 0.0.1.dev102__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 CHANGED
@@ -448,16 +448,13 @@ Use the following format to generate the response and do not wrap it in any othe
448
448
  )
449
449
 
450
450
 
451
- def mock_prompt(rows: int, feedback: str = "", history: str = "") -> str:
452
- feedback_history = ""
453
- if feedback and history:
454
- feedback_history = f"""In case the <feedback> and <history> tags are present and not empty,
455
- it means there was a previous attempt to generate the resources and the user provided feedback and history about previous responses.
456
- Use the following feedback and history to regenerate the response:
457
- Feedback to improve the response:
458
- {feedback}
459
- History of previous results:
460
- {history}"""
451
+ def mock_prompt(rows: int, feedback: str = "") -> str:
452
+ if feedback:
453
+ feedback = f"""In case the <feedback> tag is present and not empty,
454
+ it means there was a previous attempt to generate the resources and the system provided feedback about the previous response.
455
+ Use the following feedback to regenerate the response:
456
+ <feedback>{feedback}</feedback>
457
+ """
461
458
 
462
459
  return f"""
463
460
  Given the schema for a Tinybird datasource, return a can you create a clickhouse sql query to generate some random data that matches that schema.
@@ -600,7 +597,7 @@ Follow the instructions and generate the following response with no additional t
600
597
  <sql>[raw sql query here]</sql>
601
598
  </response>
602
599
 
603
- {feedback_history}
600
+ {feedback}
604
601
 
605
602
  """
606
603
 
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.dev101'
8
- __revision__ = '5dc0d4b'
7
+ __version__ = '0.0.1.dev102'
8
+ __revision__ = '627c8ef'
@@ -70,15 +70,31 @@ async def mock(ctx: click.Context, datasource: str, rows: int, prompt: str) -> N
70
70
  llm = LLM(user_token=user_token, host=user_client.host)
71
71
  prompt = f"<datasource_schema>{datasource_content}</datasource_schema>\n<user_input>{prompt}</user_input>"
72
72
  sql = ""
73
- response = llm.ask(system_prompt=mock_prompt(rows), prompt=prompt)
74
- sql = extract_xml(response, "sql")
75
- result = await tb_client.query(f"{sql} FORMAT JSON")
76
- data = result.get("data", [])[:rows]
77
- if env in ("build", "local"):
78
- persist_fixture_sql(datasource_name, sql, folder)
73
+ attempts = 0
74
+ data = []
75
+ error = ""
76
+ sql_path = None
77
+ while True:
78
+ try:
79
+ response = llm.ask(system_prompt=mock_prompt(rows, error), prompt=prompt)
80
+ sql = extract_xml(response, "sql")
81
+ sql_path = persist_fixture_sql(datasource_name, sql, folder)
82
+ result = await tb_client.query(f"{sql} FORMAT JSON")
83
+ data = result.get("data", [])[:rows]
84
+ error_response = result.get("error", None)
85
+ if error_response:
86
+ raise CLIException(error_response)
87
+ else:
88
+ break
89
+ except Exception as e:
90
+ error = str(e)
91
+ attempts += 1
92
+ if attempts > 5:
93
+ raise Exception(f"Failed to generate a valid solution. Check {str(sql_path)} and try again.")
94
+ else:
95
+ continue
79
96
 
80
97
  fixture_path = persist_fixture(datasource_name, data, folder)
81
-
82
98
  click.echo(FeedbackManager.info(message=f"✓ /fixtures/{datasource_name}.ndjson created"))
83
99
  if env == "cloud":
84
100
  await append_fixture(tb_client, datasource_name, str(fixture_path))
@@ -357,7 +357,7 @@ def print_table_formatted(res: dict, name: str):
357
357
  bytes_read = humanfriendly.format_size(stats.get("bytes_read", 0))
358
358
  elapsed = humanfriendly.format_timespan(elapsed) if elapsed >= 1 else f"{elapsed * 1000:.2f}ms"
359
359
  stats_message = f"» {bytes_read} ({rows_read} rows x {cols} cols) in {elapsed}"
360
- rows_message = f"» Showing {limit} first rows" if row_count > limit else "» Showing all rows"
360
+ rows_message = f"» Showing first {limit} rows" if row_count > limit else "» Showing all rows"
361
361
  click.echo(FeedbackManager.success(message=stats_message))
362
362
  click.echo(FeedbackManager.gray(message=rows_message))
363
363
  except ValueError as exc:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev101
3
+ Version: 0.0.1.dev102
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -6,7 +6,7 @@ tinybird/context.py,sha256=FfqYfrGX_I7PKGTQo93utaKPDNVYWelg4Hsp3evX5wM,1291
6
6
  tinybird/datatypes.py,sha256=XNypumfqNjsvLJ5iNXnbVHRvAJe0aQwI3lS6Cxox-e0,10979
7
7
  tinybird/feedback_manager.py,sha256=YSjtFDJvc8y66j2J0iIkb3SVzDdYAJbzFL-JPQ26pak,68761
8
8
  tinybird/git_settings.py,sha256=Sw_8rGmribEFJ4Z_6idrVytxpFYk7ez8ei0qHULzs3E,3934
9
- tinybird/prompts.py,sha256=syxUvbdkzxIrIK8pkS-Y7nzBx7DMS2Z9HaiXx7AjvnQ,33912
9
+ tinybird/prompts.py,sha256=RgV1B7-b6-1xXStNlhKikYSCG1WNaddDVeSp8hSgBlE,33753
10
10
  tinybird/sql.py,sha256=J35bhdpuu84HW2tiLp-cs_nzkRwPhiy1yPcFhcWMCR4,46248
11
11
  tinybird/sql_template.py,sha256=VH8io4n5eP2z6TEw111d8hcA9FKQerFjprKKCW2MODw,99127
12
12
  tinybird/sql_template_fmt.py,sha256=KUHdj5rYCYm_rKKdXYSJAE9vIyXUQLB0YSZnUXHeBlY,10196
@@ -15,7 +15,7 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
15
15
  tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
16
16
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
17
17
  tinybird/ch_utils/engine.py,sha256=BZuPM7MFS7vaEKK5tOMR2bwSAgJudPrJt27uVEwZmTY,40512
18
- tinybird/tb/__cli__.py,sha256=9fN3V2hgGADGGvafwXcIrRciQG80C2cmQs_OlsP8u-A,252
18
+ tinybird/tb/__cli__.py,sha256=wj1R7TGTdVnIOEJgofqjYqrfWRx9JGWFQnBLQy53RqQ,252
19
19
  tinybird/tb/cli.py,sha256=H_HaZhkimKgkryYXpBjHfY9Qtg-ZORiONU3psDNpzDk,1135
20
20
  tinybird/tb/modules/auth.py,sha256=L1IatO2arRSzys3t8px8xVt8uPWUL5EVD0sFzAV_uVU,9022
21
21
  tinybird/tb/modules/build.py,sha256=h5drdmDFX8NHts9dA2Zepao7KSgMAl3DZGyFufVZP78,11085
@@ -41,14 +41,14 @@ tinybird/tb/modules/local_common.py,sha256=RN5OEncHdq7ua4AZ--WgKtaFuEsLvIhq_ROHJ
41
41
  tinybird/tb/modules/login.py,sha256=dAaBBn_ZIQRm9BFl6Uw_HgZa2qoLuAO6mBOxob_17ms,6253
42
42
  tinybird/tb/modules/logout.py,sha256=ULooy1cDBD02-r7voZmhV7udA0ML5tVuflJyShrh56Y,1022
43
43
  tinybird/tb/modules/materialization.py,sha256=r8Q9HXcYEmfrEzP4WpiasCKDJdSkTPaAKJtZMoJKhi8,5749
44
- tinybird/tb/modules/mock.py,sha256=9VKlp2bO2NsRgqF03SrFv_8OvAoHeRcOU89TiBRFfqY,3891
44
+ tinybird/tb/modules/mock.py,sha256=2E26N8TMK1sP7eRc9N1nODdc_vU1jBeGRs8e-fbQ5Dc,4516
45
45
  tinybird/tb/modules/open.py,sha256=s3eJLFtF6OnXX5OLZzBz58dYaG-TGDCYFSJHttm919g,1317
46
46
  tinybird/tb/modules/pipe.py,sha256=gcLz0qHgwKDLsWFY3yFLO9a0ETAV1dFbI8YeLHi9460,2429
47
47
  tinybird/tb/modules/playground.py,sha256=bN0whphoSO6p1_u3b6OAUoc3ieG5Cl3qNXwt2HcUOp8,4834
48
48
  tinybird/tb/modules/project.py,sha256=Jpoi-3ybIixN8bHCqOMnuaKByXjrdN_Gvlpa24L-e4U,3124
49
49
  tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
50
50
  tinybird/tb/modules/secret.py,sha256=xxzfKxfFN7GORib1WslCaFDHt_dgnjmfOewyptPU_VM,2820
51
- tinybird/tb/modules/shell.py,sha256=a98W4L4gfrmxEyybtu6S4ENXrBYtgNASB5e_evuXQvI,13936
51
+ tinybird/tb/modules/shell.py,sha256=7BX9fhqq2tAvdhd1Ig1e35ePYcPH3Eh7ivZDAVwrQCk,13936
52
52
  tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
53
53
  tinybird/tb/modules/tag.py,sha256=anPmMUBc-TbFovlpFi8GPkKA18y7Y0GczMsMms5TZsU,3502
54
54
  tinybird/tb/modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
@@ -81,8 +81,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
81
81
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
82
82
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
83
83
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
84
- tinybird-0.0.1.dev101.dist-info/METADATA,sha256=73sj_cIfixFVZVrtmkn_MwEYvtkMLO4GYeJCjJQ1KA0,2586
85
- tinybird-0.0.1.dev101.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
86
- tinybird-0.0.1.dev101.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
87
- tinybird-0.0.1.dev101.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
88
- tinybird-0.0.1.dev101.dist-info/RECORD,,
84
+ tinybird-0.0.1.dev102.dist-info/METADATA,sha256=b33GgOxL3oZcglnCCC5gDCW-o6CQY67vZ1NalxV2QvQ,2586
85
+ tinybird-0.0.1.dev102.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
86
+ tinybird-0.0.1.dev102.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
87
+ tinybird-0.0.1.dev102.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
88
+ tinybird-0.0.1.dev102.dist-info/RECORD,,