weco 0.2.25__py3-none-any.whl → 0.2.26__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/api.py +11 -13
- weco/chatbot.py +6 -2
- weco/cli.py +1 -1
- weco/optimizer.py +4 -0
- {weco-0.2.25.dist-info → weco-0.2.26.dist-info}/METADATA +2 -1
- weco-0.2.26.dist-info/RECORD +15 -0
- weco-0.2.25.dist-info/RECORD +0 -15
- {weco-0.2.25.dist-info → weco-0.2.26.dist-info}/WHEEL +0 -0
- {weco-0.2.25.dist-info → weco-0.2.26.dist-info}/entry_points.txt +0 -0
- {weco-0.2.25.dist-info → weco-0.2.26.dist-info}/licenses/LICENSE +0 -0
- {weco-0.2.25.dist-info → weco-0.2.26.dist-info}/top_level.txt +0 -0
weco/api.py
CHANGED
|
@@ -14,8 +14,6 @@ def handle_api_error(e: requests.exceptions.HTTPError, console: Console) -> None
|
|
|
14
14
|
except (ValueError, KeyError): # Handle cases where response is not JSON or detail key is missing
|
|
15
15
|
detail = f"HTTP {e.response.status_code} Error: {e.response.text}"
|
|
16
16
|
console.print(f"[bold red]{detail}[/]")
|
|
17
|
-
# Avoid exiting here, let the caller decide if the error is fatal
|
|
18
|
-
# sys.exit(1)
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
def start_optimization_run(
|
|
@@ -32,7 +30,7 @@ def start_optimization_run(
|
|
|
32
30
|
api_keys: Dict[str, Any] = {},
|
|
33
31
|
auth_headers: dict = {},
|
|
34
32
|
timeout: Union[int, Tuple[int, int]] = DEFAULT_API_TIMEOUT,
|
|
35
|
-
) -> Dict[str, Any]:
|
|
33
|
+
) -> Optional[Dict[str, Any]]:
|
|
36
34
|
"""Start the optimization run."""
|
|
37
35
|
with console.status("[bold green]Starting Optimization..."):
|
|
38
36
|
try:
|
|
@@ -63,10 +61,10 @@ def start_optimization_run(
|
|
|
63
61
|
return result
|
|
64
62
|
except requests.exceptions.HTTPError as e:
|
|
65
63
|
handle_api_error(e, console)
|
|
66
|
-
|
|
64
|
+
return None
|
|
67
65
|
except Exception as e:
|
|
68
66
|
console.print(f"[bold red]Error starting run: {e}[/]")
|
|
69
|
-
|
|
67
|
+
return None
|
|
70
68
|
|
|
71
69
|
|
|
72
70
|
def evaluate_feedback_then_suggest_next_solution(
|
|
@@ -101,11 +99,11 @@ def evaluate_feedback_then_suggest_next_solution(
|
|
|
101
99
|
return result
|
|
102
100
|
except requests.exceptions.HTTPError as e:
|
|
103
101
|
# Allow caller to handle suggest errors, maybe retry or terminate
|
|
104
|
-
handle_api_error(e, console)
|
|
105
|
-
raise
|
|
102
|
+
handle_api_error(e, console)
|
|
103
|
+
raise
|
|
106
104
|
except Exception as e:
|
|
107
|
-
print(f"Error: {e}")
|
|
108
|
-
raise
|
|
105
|
+
console.print(f"[bold red]Error: {e}[/]")
|
|
106
|
+
raise
|
|
109
107
|
|
|
110
108
|
|
|
111
109
|
def get_optimization_run_status(
|
|
@@ -137,11 +135,11 @@ def get_optimization_run_status(
|
|
|
137
135
|
result["nodes"][i]["code"] = ""
|
|
138
136
|
return result
|
|
139
137
|
except requests.exceptions.HTTPError as e:
|
|
140
|
-
handle_api_error(e, console)
|
|
141
|
-
raise
|
|
138
|
+
handle_api_error(e, console)
|
|
139
|
+
raise
|
|
142
140
|
except Exception as e:
|
|
143
|
-
print(f"Error getting run status: {e}")
|
|
144
|
-
raise
|
|
141
|
+
console.print(f"[bold red]Error getting run status: {e}[/]")
|
|
142
|
+
raise
|
|
145
143
|
|
|
146
144
|
|
|
147
145
|
def send_heartbeat(run_id: str, auth_headers: dict = {}, timeout: Union[int, Tuple[int, int]] = (10, 10)) -> bool:
|
weco/chatbot.py
CHANGED
|
@@ -2,6 +2,7 @@ import pathlib
|
|
|
2
2
|
import shlex
|
|
3
3
|
import argparse
|
|
4
4
|
from typing import List, Optional, Dict, Any, Tuple
|
|
5
|
+
import sys
|
|
5
6
|
|
|
6
7
|
from rich.console import Console
|
|
7
8
|
from rich.prompt import Prompt
|
|
@@ -682,9 +683,9 @@ class Chatbot:
|
|
|
682
683
|
|
|
683
684
|
# Import and execute the actual optimization function
|
|
684
685
|
# (Import here to avoid circular imports)
|
|
685
|
-
from .optimizer import execute_optimization as
|
|
686
|
+
from .optimizer import execute_optimization as execute_optimization_run
|
|
686
687
|
|
|
687
|
-
success =
|
|
688
|
+
success = execute_optimization_run(
|
|
688
689
|
source=target_file,
|
|
689
690
|
eval_command=eval_config["eval_command"],
|
|
690
691
|
metric=eval_config["metric_name"],
|
|
@@ -702,6 +703,9 @@ class Chatbot:
|
|
|
702
703
|
else:
|
|
703
704
|
self.console.print("\n[bold yellow]⚠️ Optimization ended early or encountered issues.[/]")
|
|
704
705
|
|
|
706
|
+
exit_code = 0 if success else 1
|
|
707
|
+
sys.exit(exit_code)
|
|
708
|
+
|
|
705
709
|
def show_and_copy_command(self, command: str) -> None:
|
|
706
710
|
"""Show the command and copy it to clipboard."""
|
|
707
711
|
import subprocess
|
weco/cli.py
CHANGED
|
@@ -71,7 +71,7 @@ def configure_run_parser(run_parser: argparse.ArgumentParser) -> None:
|
|
|
71
71
|
|
|
72
72
|
def execute_run_command(args: argparse.Namespace) -> None:
|
|
73
73
|
"""Execute the 'weco run' command with all its logic."""
|
|
74
|
-
from .optimizer import execute_optimization
|
|
74
|
+
from .optimizer import execute_optimization
|
|
75
75
|
|
|
76
76
|
success = execute_optimization(
|
|
77
77
|
source=args.source,
|
weco/optimizer.py
CHANGED
|
@@ -183,6 +183,10 @@ def execute_optimization(
|
|
|
183
183
|
auth_headers=auth_headers,
|
|
184
184
|
timeout=api_timeout,
|
|
185
185
|
)
|
|
186
|
+
# Indicate the endpoint failed to return a response and the optimization was unsuccessful
|
|
187
|
+
if run_response is None:
|
|
188
|
+
return False
|
|
189
|
+
|
|
186
190
|
run_id = run_response["run_id"]
|
|
187
191
|
run_name = run_response["run_name"]
|
|
188
192
|
current_run_id_for_heartbeat = run_id
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: weco
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.26
|
|
4
4
|
Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
|
|
5
5
|
Author-email: Weco AI Team <contact@weco.ai>
|
|
6
6
|
License: MIT
|
|
@@ -268,6 +268,7 @@ Weco supports the following LLM models:
|
|
|
268
268
|
- `gpt-4o-mini`
|
|
269
269
|
|
|
270
270
|
### Anthropic Models
|
|
271
|
+
- `claude-opus-4-1`
|
|
271
272
|
- `claude-opus-4-0`
|
|
272
273
|
- `claude-sonnet-4-0`
|
|
273
274
|
- `claude-3-7-sonnet-latest`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
weco/__init__.py,sha256=ClO0uT6GKOA0iSptvP0xbtdycf0VpoPTq37jHtvlhtw,303
|
|
2
|
+
weco/api.py,sha256=sz97FI0cMm4ku6bMnXsY9Jqgu-lUNELpF6L6vqIaSDE,12997
|
|
3
|
+
weco/auth.py,sha256=KMSAsN1V5wx7KUsYL1cEOOiG29Pqf4Exb3EPW4mAWC0,10003
|
|
4
|
+
weco/chatbot.py,sha256=EkzKd5Q_IlcobBbY3gsbgN0jxbJMfP5eYtzxQaNQ3fg,37747
|
|
5
|
+
weco/cli.py,sha256=jasJpAwibp2rfZflE1LebyQz1dh55Y32G6qDINw4B_U,8161
|
|
6
|
+
weco/constants.py,sha256=vfQGDf9_kzlN9BzEFvMsd0EeXOsRyzpvSWyxOJgRauE,168
|
|
7
|
+
weco/optimizer.py,sha256=iFI1h2HlKFYMiIxVoTFS5aulUIuNjMbsOQw3MGfXIwI,23819
|
|
8
|
+
weco/panels.py,sha256=jwAV_uoa0ZI9vjyey-hSY3rx4pfNNkZvPzqt-iz-RXo,16808
|
|
9
|
+
weco/utils.py,sha256=HecbOqD5rBuVhUkLixVrTWBMJ-ZMAhK-889N-lCk3dQ,7335
|
|
10
|
+
weco-0.2.26.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
|
|
11
|
+
weco-0.2.26.dist-info/METADATA,sha256=liTaJZxAI_4Xe21aZ-1YKUzHEvtn1vzyu0liTayEb98,16089
|
|
12
|
+
weco-0.2.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
weco-0.2.26.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
|
|
14
|
+
weco-0.2.26.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
15
|
+
weco-0.2.26.dist-info/RECORD,,
|
weco-0.2.25.dist-info/RECORD
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
weco/__init__.py,sha256=ClO0uT6GKOA0iSptvP0xbtdycf0VpoPTq37jHtvlhtw,303
|
|
2
|
-
weco/api.py,sha256=saGYG-DEgexw-ykpc86h6_b-FvC0vES4QwnJaUt3dwc,13205
|
|
3
|
-
weco/auth.py,sha256=KMSAsN1V5wx7KUsYL1cEOOiG29Pqf4Exb3EPW4mAWC0,10003
|
|
4
|
-
weco/chatbot.py,sha256=MSG3yybZ0fHTpwW3If9TpOWOAE4EqrcUWpe3q16AjZE,37673
|
|
5
|
-
weco/cli.py,sha256=75JdYpUf0qdJW5pjycZoHUKA2n2MYj33qYM9WQwLT2s,8184
|
|
6
|
-
weco/constants.py,sha256=vfQGDf9_kzlN9BzEFvMsd0EeXOsRyzpvSWyxOJgRauE,168
|
|
7
|
-
weco/optimizer.py,sha256=E5Jii0rTdI9pxkstaM7ipjF4viX5XnSy5w71gdps4Ws,23662
|
|
8
|
-
weco/panels.py,sha256=jwAV_uoa0ZI9vjyey-hSY3rx4pfNNkZvPzqt-iz-RXo,16808
|
|
9
|
-
weco/utils.py,sha256=HecbOqD5rBuVhUkLixVrTWBMJ-ZMAhK-889N-lCk3dQ,7335
|
|
10
|
-
weco-0.2.25.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
|
|
11
|
-
weco-0.2.25.dist-info/METADATA,sha256=Sf4up2AoxvFs0ByA00vKacOxEHm8peZaSdtGdKLgHn8,16069
|
|
12
|
-
weco-0.2.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
-
weco-0.2.25.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
|
|
14
|
-
weco-0.2.25.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
15
|
-
weco-0.2.25.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|