tinybird 0.0.1.dev241__py3-none-any.whl → 0.0.1.dev242__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 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.dev241'
8
- __revision__ = 'b44ab3b'
7
+ __version__ = '0.0.1.dev242'
8
+ __revision__ = '62ad714'
@@ -22,6 +22,7 @@ from tinybird.prompts import (
22
22
  sink_pipe_instructions,
23
23
  )
24
24
  from tinybird.tb.client import TinyB
25
+ from tinybird.tb.modules.agent.animations import ThinkingAnimation
25
26
  from tinybird.tb.modules.agent.banner import display_banner
26
27
  from tinybird.tb.modules.agent.memory import clear_history, load_history
27
28
  from tinybird.tb.modules.agent.models import create_model
@@ -125,7 +126,7 @@ Today is {datetime.now().strftime("%Y-%m-%d")}
125
126
  Tool(explore_data, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
126
127
  Tool(preview_datafile, docstring_format="google", require_parameter_descriptions=True, takes_ctx=False),
127
128
  Tool(create_datafile, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
128
- Tool(plan, docstring_format="google", require_parameter_descriptions=True, takes_ctx=False),
129
+ Tool(plan, docstring_format="google", require_parameter_descriptions=True, takes_ctx=True),
129
130
  ],
130
131
  )
131
132
 
@@ -135,18 +136,24 @@ Today is {datetime.now().strftime("%Y-%m-%d")}
135
136
 
136
137
  def run(self, user_prompt: str) -> None:
137
138
  client = TinyB(token=self.token, host=self.host)
139
+
140
+ thinking_animation = ThinkingAnimation(message="Chirping", delay=0.15)
141
+ thinking_animation.start()
142
+
138
143
  result = self.agent.run_sync(
139
144
  user_prompt,
140
145
  deps=TinybirdAgentContext(
141
146
  # context does not support the whole client, so we need to pass only the functions we need
142
147
  explore_data=client.explore_data,
143
148
  folder=self.folder,
149
+ thinking_animation=thinking_animation,
144
150
  ),
145
151
  message_history=self.messages,
146
152
  )
147
153
  new_messages = result.new_messages()
148
154
  self.messages.extend(new_messages)
149
- click.echo("\n")
155
+ thinking_animation.stop()
156
+
150
157
  click.echo(result.output)
151
158
  click.echo("\n")
152
159
 
@@ -0,0 +1,86 @@
1
+ import random
2
+ import sys
3
+ import threading
4
+ from time import sleep
5
+ from typing import Optional
6
+
7
+ import click
8
+
9
+
10
+ class ThinkingAnimation:
11
+ """Thinking animation that shows changing sparkles as a prefix."""
12
+
13
+ def __init__(
14
+ self,
15
+ message: str = "Thinking",
16
+ delay: float = 0.15,
17
+ colors: bool = True,
18
+ dots: bool = True,
19
+ ):
20
+ self.message = message
21
+ self.delay = delay
22
+ self.running = False
23
+ self.thread: Optional[threading.Thread] = None
24
+ self.colors = colors and sys.stdout.isatty()
25
+ self.dots = dots
26
+
27
+ # Default sparkle characters
28
+ self.sparkle_chars = ["✧", "✦", "⋆", "✳", "✺", "✹", "*", "·"]
29
+
30
+ # ANSI color codes
31
+ self.colors_list = [
32
+ "\033[33m", # Yellow
33
+ "\033[36m", # Cyan
34
+ "\033[35m", # Magenta
35
+ "\033[93m", # Bright Yellow
36
+ "\033[96m", # Bright Cyan
37
+ ]
38
+ self.reset_color = "\033[0m"
39
+
40
+ def start(self):
41
+ """Start the animation in a separate thread."""
42
+ self.running = True
43
+ self.thread = threading.Thread(target=self._run_animation)
44
+ self.thread.daemon = True
45
+
46
+ click.echo("\n")
47
+ self.thread.start()
48
+
49
+ def stop(self):
50
+ """Stop the animation."""
51
+ self.running = False
52
+ if self.thread:
53
+ self.thread.join()
54
+ # Clear the line and reset cursor position
55
+ sys.stdout.write("\r" + " " * (len(self.message) + 10) + "\r")
56
+ sys.stdout.flush()
57
+
58
+ def _run_animation(self):
59
+ """Run the animation until stopped."""
60
+ frame_count = 0
61
+ dots_count = 0
62
+
63
+ while self.running:
64
+ # Choose a random sparkle for this frame
65
+ sparkle = random.choice(self.sparkle_chars)
66
+
67
+ if self.colors:
68
+ color = random.choice(self.colors_list)
69
+ colored_sparkle = f"{color}{sparkle}{self.reset_color}"
70
+ else:
71
+ colored_sparkle = sparkle
72
+
73
+ # Handle dots animation if enabled
74
+ if self.dots:
75
+ dots_count = (frame_count // 4) % 4 # Change dots every 4 frames
76
+ dots = "." * dots_count
77
+ display_message = f"{self.message}{dots}"
78
+ else:
79
+ display_message = self.message
80
+
81
+ # Print the message with the prefix sparkle
82
+ sys.stdout.write(f"\r{colored_sparkle} {display_message}")
83
+ sys.stdout.flush()
84
+
85
+ sleep(self.delay)
86
+ frame_count += 1
@@ -35,9 +35,11 @@ def create_datafile(ctx: RunContext[TinybirdAgentContext], resource: Datafile) -
35
35
  str: If the resource was created or not.
36
36
  """
37
37
  try:
38
+ ctx.deps.thinking_animation.stop()
38
39
  click.echo()
39
40
  click.echo(resource.content)
40
41
  confirmation = get_resource_confirmation(resource)
42
+ ctx.deps.thinking_animation.start()
41
43
 
42
44
  if not confirmation:
43
45
  return f"Resource {resource.pathname} was not created. User cancelled creation."
@@ -1,6 +1,7 @@
1
1
  import click
2
+ from pydantic_ai import RunContext
2
3
 
3
- from tinybird.tb.modules.agent.utils import show_options
4
+ from tinybird.tb.modules.agent.utils import TinybirdAgentContext, show_options
4
5
 
5
6
 
6
7
  def get_plan_confirmation() -> bool:
@@ -22,7 +23,7 @@ def get_plan_confirmation() -> bool:
22
23
  return False
23
24
 
24
25
 
25
- def plan(plan: str) -> str:
26
+ def plan(ctx: RunContext[TinybirdAgentContext], plan: str) -> str:
26
27
  """Given a plan, ask the user for confirmation to implement it
27
28
 
28
29
  Args:
@@ -32,9 +33,11 @@ def plan(plan: str) -> str:
32
33
  str: If the plan was implemented or not.
33
34
  """
34
35
  try:
36
+ ctx.deps.thinking_animation.stop()
35
37
  click.echo()
36
38
  click.echo(plan)
37
39
  confirmation = get_plan_confirmation()
40
+ ctx.deps.thinking_animation.start()
38
41
 
39
42
  if not confirmation:
40
43
  return "Plan was not implemented. User cancelled implementation."
@@ -20,6 +20,7 @@ from pydantic import BaseModel, Field
20
20
  class TinybirdAgentContext(BaseModel):
21
21
  explore_data: Callable[[str], str]
22
22
  folder: str
23
+ thinking_animation: Any
23
24
 
24
25
 
25
26
  default_style = Style.from_dict(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev241
3
+ Version: 0.0.1.dev242
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/forward/commands
6
6
  Author: Tinybird
@@ -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=QWlsNI8ondzuZlYrE_y6bh1Cfz6_5AfBIndh4z9wk60,247
20
+ tinybird/tb/__cli__.py,sha256=WaMYFAckfNWnMzyIA-CatGh7AXWIKDHBGMB-QqtF2rw,247
21
21
  tinybird/tb/check_pypi.py,sha256=Gp0HkHHDFMSDL6nxKlOY51z7z1Uv-2LRexNTZSHHGmM,552
22
22
  tinybird/tb/cli.py,sha256=FdDFEIayjmsZEVsVSSvRiVYn_FHOVg_zWQzchnzfWho,1008
23
23
  tinybird/tb/client.py,sha256=pJbdkWMXGAqKseNAvdsRRnl_c7I-DCMB0dWCQnG82nU,54146
@@ -63,16 +63,17 @@ tinybird/tb/modules/watch.py,sha256=No0bK1M1_3CYuMaIgylxf7vYFJ72lTJe3brz6xQ-mJo,
63
63
  tinybird/tb/modules/workspace.py,sha256=Q_8HcxMsNg8QG9aBlwcWS2umrDP5IkTIHqqz3sfmGuc,11341
64
64
  tinybird/tb/modules/workspace_members.py,sha256=5JdkJgfuEwbq-t6vxkBhYwgsiTDxF790wsa6Xfif9nk,8608
65
65
  tinybird/tb/modules/agent/__init__.py,sha256=i3oe3vDIWWPaicdCM0zs7D7BJ1W0k7th93ooskHAV00,54
66
- tinybird/tb/modules/agent/agent.py,sha256=nUvSfgi7OdrWXRxLjLHzepsrICiduAZcW7iFE0x5Q5A,10323
66
+ tinybird/tb/modules/agent/agent.py,sha256=TWHU9gEPH7EZQguno1P_HZ5jO7v6QLj9UE1btgaAOxg,10570
67
+ tinybird/tb/modules/agent/animations.py,sha256=z0MNLf8TnUO8qAjgYvth_wc9a9283pNVz1Z4jl15Ggs,2558
67
68
  tinybird/tb/modules/agent/banner.py,sha256=KX_e467uiy1gWOZ4ofTZt0GCFGQqHQ_8Ob27XLQqda0,3053
68
69
  tinybird/tb/modules/agent/memory.py,sha256=H6SJK--2L5C87B7AJd_jMqsq3sCvFvZwZXmajuT0GBE,1171
69
70
  tinybird/tb/modules/agent/models.py,sha256=mf8dRCdof6uEFZWh5xQ_D_FStk7eDds7qWRNSbDklUM,589
70
71
  tinybird/tb/modules/agent/prompts.py,sha256=j7nkx1E2BnPP6Ra718FvSDGRWucyFgSX07V9QAiaiGg,4864
71
- tinybird/tb/modules/agent/utils.py,sha256=BWbS8m8HYrbbm1OnH7kLYLxL37-q1yVKa1ObWw7klfc,13041
72
+ tinybird/tb/modules/agent/utils.py,sha256=brW-2StkAy-X1LGDbjQYhOXMSifGwWJCSkPDDmo7SUk,13069
72
73
  tinybird/tb/modules/agent/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
- tinybird/tb/modules/agent/tools/create_datafile.py,sha256=06HK33h86T1d54zvnJXJz_1su3zIS7UJDPyBqhgo81c,1771
74
+ tinybird/tb/modules/agent/tools/create_datafile.py,sha256=V5VMFvpne-LW1XzQY7AnSMiOkMALSRspEjtBqK1Glnk,1858
74
75
  tinybird/tb/modules/agent/tools/explore.py,sha256=ihALc_kBcsjrKT3hZyicqyIowB0g_K3AtNNi-5uz9-8,412
75
- tinybird/tb/modules/agent/tools/plan.py,sha256=acMbyjqI6cN7IwmMAC8-MPNSg0PEZVKGEk2NOY4gMi8,1162
76
+ tinybird/tb/modules/agent/tools/plan.py,sha256=K9mXqCgLXbwXtyFFjPvrrwRwEm2rNnIMn73qazDTQts,1345
76
77
  tinybird/tb/modules/agent/tools/preview_datafile.py,sha256=e9q5fR0afApcrntzFrnuHmd10ex7MG_GM6T0Pwc9bRI,850
77
78
  tinybird/tb/modules/datafile/build.py,sha256=NFKBrusFLU0WJNCXePAFWiEDuTaXpwc0lHlOQWEJ43s,51117
78
79
  tinybird/tb/modules/datafile/build_common.py,sha256=2yNdxe49IMA9wNvl25NemY2Iaz8L66snjOdT64dm1is,4511
@@ -94,8 +95,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
94
95
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
95
96
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
96
97
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
97
- tinybird-0.0.1.dev241.dist-info/METADATA,sha256=urGByLwa4s7Sstte1j0r7UZ6iYFUmnpX4ujKWztx9II,1733
98
- tinybird-0.0.1.dev241.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
99
- tinybird-0.0.1.dev241.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
100
- tinybird-0.0.1.dev241.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
101
- tinybird-0.0.1.dev241.dist-info/RECORD,,
98
+ tinybird-0.0.1.dev242.dist-info/METADATA,sha256=jcAeg7hLOB_0X5tNRd6Jchij6S62DjqZ3I4vHblBchk,1733
99
+ tinybird-0.0.1.dev242.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
100
+ tinybird-0.0.1.dev242.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
101
+ tinybird-0.0.1.dev242.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
102
+ tinybird-0.0.1.dev242.dist-info/RECORD,,