wcgw 0.0.7__py3-none-any.whl → 0.0.9__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 wcgw might be problematic. Click here for more details.
- wcgw/basic.py +29 -4
- wcgw/common.py +8 -28
- wcgw/openai_adapters.py +0 -0
- {wcgw-0.0.7.dist-info → wcgw-0.0.9.dist-info}/METADATA +2 -3
- wcgw-0.0.9.dist-info/RECORD +11 -0
- wcgw-0.0.7.dist-info/RECORD +0 -10
- {wcgw-0.0.7.dist-info → wcgw-0.0.9.dist-info}/WHEEL +0 -0
- {wcgw-0.0.7.dist-info → wcgw-0.0.9.dist-info}/entry_points.txt +0 -0
wcgw/basic.py
CHANGED
|
@@ -20,9 +20,8 @@ import petname
|
|
|
20
20
|
from typer import Typer
|
|
21
21
|
import uuid
|
|
22
22
|
|
|
23
|
-
from
|
|
24
|
-
|
|
25
|
-
from .common import Models
|
|
23
|
+
from .common import Models, discard_input
|
|
24
|
+
from .common import CostData, History
|
|
26
25
|
from .openai_utils import get_input_cost, get_output_cost
|
|
27
26
|
from .tools import ExecuteBash, ReadImage, ImageData
|
|
28
27
|
|
|
@@ -40,14 +39,40 @@ from .tools import (
|
|
|
40
39
|
import tiktoken
|
|
41
40
|
|
|
42
41
|
from urllib import parse
|
|
42
|
+
import subprocess
|
|
43
43
|
import os
|
|
44
|
+
import tempfile
|
|
44
45
|
|
|
45
46
|
import toml
|
|
47
|
+
from pydantic import BaseModel
|
|
46
48
|
|
|
47
49
|
|
|
48
50
|
from dotenv import load_dotenv
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
|
|
53
|
+
class Config(BaseModel):
|
|
54
|
+
model: Models
|
|
55
|
+
secondary_model: Models
|
|
56
|
+
cost_limit: float
|
|
57
|
+
cost_file: dict[Models, CostData]
|
|
58
|
+
cost_unit: str = "$"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def text_from_editor(console: rich.console.Console) -> str:
|
|
62
|
+
# First consume all the input till now
|
|
63
|
+
discard_input()
|
|
64
|
+
console.print("\n---------------------------------------\n# User message")
|
|
65
|
+
data = input()
|
|
66
|
+
if data:
|
|
67
|
+
return data
|
|
68
|
+
editor = os.environ.get("EDITOR", "vim")
|
|
69
|
+
with tempfile.NamedTemporaryFile(suffix=".tmp") as tf:
|
|
70
|
+
subprocess.run([editor, tf.name], check=True)
|
|
71
|
+
with open(tf.name, "r") as f:
|
|
72
|
+
data = f.read()
|
|
73
|
+
console.print(data)
|
|
74
|
+
return data
|
|
75
|
+
|
|
51
76
|
|
|
52
77
|
def save_history(history: History, session_id: str) -> None:
|
|
53
78
|
myid = str(history[1]["content"]).replace("/", "_").replace(" ", "_").lower()[:60]
|
wcgw/common.py
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import select
|
|
3
|
-
import subprocess
|
|
4
2
|
import sys
|
|
5
|
-
import tempfile
|
|
6
3
|
import termios
|
|
7
4
|
import tty
|
|
8
5
|
from typing import Literal
|
|
9
6
|
from pydantic import BaseModel
|
|
10
|
-
import rich
|
|
11
7
|
|
|
12
8
|
|
|
13
9
|
class CostData(BaseModel):
|
|
@@ -15,6 +11,14 @@ class CostData(BaseModel):
|
|
|
15
11
|
cost_per_1m_output_tokens: float
|
|
16
12
|
|
|
17
13
|
|
|
14
|
+
from openai.types.chat import (
|
|
15
|
+
ChatCompletionMessageParam,
|
|
16
|
+
ChatCompletionAssistantMessageParam,
|
|
17
|
+
ChatCompletionMessage,
|
|
18
|
+
ParsedChatCompletionMessage,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
History = list[ChatCompletionMessageParam]
|
|
18
22
|
Models = Literal["gpt-4o-2024-08-06", "gpt-4o-mini"]
|
|
19
23
|
|
|
20
24
|
|
|
@@ -41,27 +45,3 @@ def discard_input() -> None:
|
|
|
41
45
|
finally:
|
|
42
46
|
# Restore old terminal settings
|
|
43
47
|
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class Config(BaseModel):
|
|
47
|
-
model: Models
|
|
48
|
-
secondary_model: Models
|
|
49
|
-
cost_limit: float
|
|
50
|
-
cost_file: dict[Models, CostData]
|
|
51
|
-
cost_unit: str = "$"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def text_from_editor(console: rich.console.Console) -> str:
|
|
55
|
-
# First consume all the input till now
|
|
56
|
-
discard_input()
|
|
57
|
-
console.print("\n---------------------------------------\n# User message")
|
|
58
|
-
data = input()
|
|
59
|
-
if data:
|
|
60
|
-
return data
|
|
61
|
-
editor = os.environ.get("EDITOR", "vim")
|
|
62
|
-
with tempfile.NamedTemporaryFile(suffix=".tmp") as tf:
|
|
63
|
-
subprocess.run([editor, tf.name], check=True)
|
|
64
|
-
with open(tf.name, "r") as f:
|
|
65
|
-
data = f.read()
|
|
66
|
-
console.print(data)
|
|
67
|
-
return data
|
wcgw/openai_adapters.py
ADDED
|
File without changes
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: wcgw
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.9
|
|
4
4
|
Summary: What could go wrong giving full shell access to chatgpt?
|
|
5
5
|
Project-URL: Homepage, https://github.com/rusiaaman/wcgw
|
|
6
6
|
Author-email: Aman Rusia <gapypi@arcfu.com>
|
|
7
|
-
Requires-Python:
|
|
8
|
-
Requires-Dist: anthropic>=0.36.2
|
|
7
|
+
Requires-Python: <3.13,>=3.8
|
|
9
8
|
Requires-Dist: fastapi>=0.115.0
|
|
10
9
|
Requires-Dist: mypy>=1.11.2
|
|
11
10
|
Requires-Dist: openai>=1.46.0
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
wcgw/__init__.py,sha256=okSsOWpTKDjEQzgOin3Kdpx4Mc3MFX1RunjopHQSIWE,62
|
|
2
|
+
wcgw/__main__.py,sha256=MjJnFwfYzA1rW47xuSP1EVsi53DTHeEGqESkQwsELFQ,34
|
|
3
|
+
wcgw/basic.py,sha256=BosCItWh4SpRNygEvCtf59Gm9xto3jof6SkPecjExHE,15804
|
|
4
|
+
wcgw/common.py,sha256=jn39zTpaFUO1PWof_z7qBmklaZH5G1blzjlBvez0cg4,1225
|
|
5
|
+
wcgw/openai_adapters.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
wcgw/openai_utils.py,sha256=YNwCsA-Wqq7jWrxP0rfQmBTb1dI0s7dWXzQqyTzOZT4,2629
|
|
7
|
+
wcgw/tools.py,sha256=ozJtcuOlMrdGoDmSv4UpolnStdY7Xz8Z7JyrRllKA7s,17088
|
|
8
|
+
wcgw-0.0.9.dist-info/METADATA,sha256=meAGr9uOuxltYth3XyRHe2RNOU--BIEQcE_26So-K5Q,1995
|
|
9
|
+
wcgw-0.0.9.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
10
|
+
wcgw-0.0.9.dist-info/entry_points.txt,sha256=T-IH7w6Vc650hr8xksC8kJfbJR4uwN8HDudejwDwrNM,59
|
|
11
|
+
wcgw-0.0.9.dist-info/RECORD,,
|
wcgw-0.0.7.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
wcgw/__init__.py,sha256=okSsOWpTKDjEQzgOin3Kdpx4Mc3MFX1RunjopHQSIWE,62
|
|
2
|
-
wcgw/__main__.py,sha256=MjJnFwfYzA1rW47xuSP1EVsi53DTHeEGqESkQwsELFQ,34
|
|
3
|
-
wcgw/basic.py,sha256=o_iyg3Rmqz08LTWzgO7JIA0u_5l6GGaXyJe0zw73v8w,15085
|
|
4
|
-
wcgw/common.py,sha256=gHiP1RVHkvp10jPc1Xzg5DtUqhGbgQ7pTJK7OvUXfZQ,1764
|
|
5
|
-
wcgw/openai_utils.py,sha256=YNwCsA-Wqq7jWrxP0rfQmBTb1dI0s7dWXzQqyTzOZT4,2629
|
|
6
|
-
wcgw/tools.py,sha256=ozJtcuOlMrdGoDmSv4UpolnStdY7Xz8Z7JyrRllKA7s,17088
|
|
7
|
-
wcgw-0.0.7.dist-info/METADATA,sha256=Ei676pDMqOXetAPPmxU5wAXZ6mWRJfLq8eJHyhfKSTY,2022
|
|
8
|
-
wcgw-0.0.7.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
9
|
-
wcgw-0.0.7.dist-info/entry_points.txt,sha256=T-IH7w6Vc650hr8xksC8kJfbJR4uwN8HDudejwDwrNM,59
|
|
10
|
-
wcgw-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|