weco 0.2.0__py3-none-any.whl → 0.2.2__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.
weco/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # DO NOT EDIT
2
- __pkg_version__ = "0.2.0"
2
+ __pkg_version__ = "0.2.2"
3
3
  __api_version__ = "v1"
4
4
  __base_url__ = f"https://api.aide.weco.ai/{__api_version__}"
weco/cli.py CHANGED
@@ -185,6 +185,9 @@ def main() -> None:
185
185
  # Save next solution (.runs/<session-id>/step_<step>.py)
186
186
  write_to_path(fp=runs_dir / f"step_{step}.py", content=eval_and_next_solution_response["code"])
187
187
 
188
+ # Write the next solution to the source file
189
+ write_to_path(fp=source_fp, content=eval_and_next_solution_response["code"])
190
+
188
191
  # Get the optimization session status for
189
192
  # the best solution, its score, and the history to plot the tree
190
193
  status_response = get_optimization_session_status(console=console, session_id=session_id, include_history=True)
weco/panels.py CHANGED
@@ -5,7 +5,7 @@ from rich.layout import Layout
5
5
  from rich.panel import Panel
6
6
  from rich.syntax import Syntax
7
7
  from typing import Dict, List, Optional, Union, Tuple
8
- from .utils import format_number, truncate_text
8
+ from .utils import format_number
9
9
 
10
10
 
11
11
  class SummaryPanel:
@@ -67,7 +67,6 @@ class PlanPanel:
67
67
 
68
68
  def __init__(self):
69
69
  self.plan = ""
70
- self.max_lines = 3 # Approximate number of lines that can fit in the panel
71
70
 
72
71
  def update(self, plan: str):
73
72
  """Update the plan text."""
@@ -79,15 +78,7 @@ class PlanPanel:
79
78
 
80
79
  def get_display(self) -> Panel:
81
80
  """Create a panel displaying the plan with truncation if needed."""
82
- display_text = truncate_text(text=self.plan, max_lines=self.max_lines)
83
- return Panel(
84
- display_text,
85
- title="[bold]📝 Thinking...",
86
- border_style="cyan",
87
- expand=True,
88
- padding=(0, 1),
89
- subtitle="[cyan]↓ truncated ↓[/]" if len(self.plan) > self.max_lines else None,
90
- )
81
+ return Panel(self.plan, title="[bold]📝 Thinking...", border_style="cyan", expand=True, padding=(0, 1))
91
82
 
92
83
 
93
84
  class Node:
@@ -238,7 +229,6 @@ class EvaluationOutputPanel:
238
229
 
239
230
  def __init__(self):
240
231
  self.output = ""
241
- self.max_lines = 25 # Approximate number of lines that can fit in the panel
242
232
 
243
233
  def update(self, output: str) -> None:
244
234
  """Update the evaluation output."""
@@ -250,13 +240,7 @@ class EvaluationOutputPanel:
250
240
 
251
241
  def get_display(self) -> Panel:
252
242
  """Create a panel displaying the evaluation output with truncation if needed."""
253
- display_text = truncate_text(text=self.output, max_lines=self.max_lines)
254
-
255
- title = "[bold]📋 Evaluation Output"
256
- if len(self.output) == len(display_text):
257
- title += " (truncated)[/]"
258
-
259
- return Panel(display_text, title=title, border_style="red", expand=True, padding=(0, 1))
243
+ return Panel(self.output, title="[bold]📋 Evaluation Output", border_style="red", expand=True, padding=(0, 1))
260
244
 
261
245
 
262
246
  class SolutionPanels:
@@ -267,7 +251,6 @@ class SolutionPanels:
267
251
  self.current_node = None
268
252
  # Best solution
269
253
  self.best_node = None
270
- self.max_lines = 30 # Approximate number of lines that can fit in each panel
271
254
 
272
255
  def update(self, current_node: Union[Node, None], best_node: Union[Node, None]):
273
256
  """Update the current and best solutions."""
@@ -282,44 +265,24 @@ class SolutionPanels:
282
265
  best_code = self.best_node.code if self.best_node is not None else ""
283
266
  best_score = self.best_node.metric if self.best_node is not None else None
284
267
 
285
- # Determine if code is too long (approximate)
286
- current_lines = current_code.count("\n") + 1
287
- best_lines = best_code.count("\n") + 1
288
-
289
268
  # Current solution (without score)
290
269
  current_title = f"[bold]💡 Current Solution (Step {current_step})"
291
270
  current_panel = Panel(
292
- Syntax(
293
- str(current_code),
294
- "python",
295
- theme="monokai",
296
- line_numbers=True,
297
- word_wrap=False,
298
- line_range=(0, self.max_lines), # Only show first max_lines lines
299
- ),
271
+ Syntax(str(current_code), "python", theme="monokai", line_numbers=True, word_wrap=False),
300
272
  title=current_title,
301
273
  border_style="yellow",
302
274
  expand=True,
303
275
  padding=(0, 1),
304
- subtitle="[yellow]↓ truncated ↓[/]" if current_lines > self.max_lines else None,
305
276
  )
306
277
 
307
278
  # Best solution
308
279
  best_title = f"[bold]🏆 Best Solution ([green]Score: {f'{best_score:.4f}' if best_score is not None else 'N/A'}[/])"
309
280
  best_panel = Panel(
310
- Syntax(
311
- str(best_code),
312
- "python",
313
- theme="monokai",
314
- line_numbers=True,
315
- word_wrap=False,
316
- line_range=(0, self.max_lines), # Only show first max_lines lines
317
- ),
281
+ Syntax(str(best_code), "python", theme="monokai", line_numbers=True, word_wrap=False),
318
282
  title=best_title,
319
283
  border_style="green",
320
284
  expand=True,
321
285
  padding=(0, 1),
322
- subtitle="[yellow]↓ truncated ↓[/]" if best_lines > self.max_lines else None,
323
286
  )
324
287
 
325
288
  return current_panel, best_panel
weco/utils.py CHANGED
@@ -13,12 +13,11 @@ import pathlib
13
13
  def read_api_keys_from_env() -> Dict[str, Any]:
14
14
  """Read API keys from environment variables."""
15
15
  keys = {}
16
- openai_api_key = os.getenv("OPENAI_API_KEY")
17
- anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
18
- if openai_api_key is not None and len(openai_api_key) > 0:
19
- keys["OPENAI_API_KEY"] = openai_api_key
20
- if anthropic_api_key is not None and len(anthropic_api_key) > 0:
21
- keys["ANTHROPIC_API_KEY"] = anthropic_api_key
16
+ keys_to_check = ["OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GEMINI_API_KEY"]
17
+ for key in keys_to_check:
18
+ value = os.getenv(key)
19
+ if value is not None and len(value) > 0:
20
+ keys[key] = value
22
21
  return keys
23
22
 
24
23
 
@@ -106,14 +105,3 @@ def run_evaluation(eval_command: str) -> str:
106
105
  output += "\n"
107
106
  output += result.stdout
108
107
  return output
109
-
110
-
111
- def truncate_text(text: str, max_lines: int) -> str:
112
- """Truncate text to a maximum number of lines."""
113
- lines = text.split("\n")
114
- if len(lines) > max_lines:
115
- display_lines = lines[:max_lines]
116
- display_text = "\n".join(display_lines)
117
- else:
118
- display_text = text
119
- return display_text
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weco
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
5
5
  Author-email: Weco AI Team <dhruv@weco.ai>
6
6
  License: MIT
@@ -49,6 +49,7 @@ The `weco` CLI leverages advanced optimization techniques and language model str
49
49
 
50
50
  - **OpenAI:** `export OPENAI_API_KEY="your_key_here"`
51
51
  - **Anthropic:** `export ANTHROPIC_API_KEY="your_key_here"`
52
+ - **Google DeepMind:** `export GEMINI_API_KEY="your_key_here"`
52
53
 
53
54
  ---
54
55
 
@@ -99,6 +100,7 @@ The CLI supports the following model providers:
99
100
 
100
101
  - **OpenAI:** Set your API key using `OPENAI_API_KEY`.
101
102
  - **Anthropic:** Set your API key using `ANTHROPIC_API_KEY`.
103
+ - **Google DeepMind:** Set your API key using `GEMINI_API_KEY`.
102
104
 
103
105
  ---
104
106
 
@@ -0,0 +1,11 @@
1
+ weco/__init__.py,sha256=piNl2k8gLYD32s0kA8QqBDe7vANYnzN_QN9bWtfRsks,124
2
+ weco/api.py,sha256=JHAm60sO51Y2tzLnyAAFv9OLm75o_RNWeoK-gYF4VHE,3342
3
+ weco/cli.py,sha256=OneQ8a7ySgtzrNGo0l53Ij_I_p0RTVQ8GV2n66wIJv0,16050
4
+ weco/panels.py,sha256=iUZWtZfohaWeI6-x6pf2kKN1c8IL7U_AhpBBeFhtFhk,11642
5
+ weco/utils.py,sha256=g1Lchd3_L-eGRNkqr2IyRZ5FJfZTrFf9aTmmpMtdhko,3761
6
+ weco-0.2.2.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
+ weco-0.2.2.dist-info/METADATA,sha256=jy-GYv-J4qga01Ic2HtzkG1P3MDlgNjq_aas4EukZ0o,5270
8
+ weco-0.2.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
+ weco-0.2.2.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
+ weco-0.2.2.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
+ weco-0.2.2.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- weco/__init__.py,sha256=J-pJsj20yEXYYCDJyhKJBFWQUzb4bhww0ynqxNBA5Z4,124
2
- weco/api.py,sha256=JHAm60sO51Y2tzLnyAAFv9OLm75o_RNWeoK-gYF4VHE,3342
3
- weco/cli.py,sha256=q1UuQ8xe2R5dpLhxPGJEW9mOFozH0oRlTbyyVD70XlU,15895
4
- weco/panels.py,sha256=Cu249CAlpczrseBjqvERlo_wlg4RLbO0ylx1JPZGjRA,13058
5
- weco/utils.py,sha256=yCVlQyCP0P7t-864xuw55qEUVmyXXGin-a1Y5TDFHE4,4202
6
- weco-0.2.0.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
- weco-0.2.0.dist-info/METADATA,sha256=piZk0o15yLjq6qpKKFQqT4vRcGR3unNC2LzZOIdJAro,5140
8
- weco-0.2.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
- weco-0.2.0.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
- weco-0.2.0.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
- weco-0.2.0.dist-info/RECORD,,
File without changes