gnarly 0.0.0.dev10__tar.gz → 0.0.0.dev12__tar.gz
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 gnarly might be problematic. Click here for more details.
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/PKG-INFO +1 -1
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/pyproject.toml +3 -1
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/code/projects.py +1 -1
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/llm/interfaces.py +79 -32
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/uv.lock +1 -1
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/.gitignore +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/.python-version +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/README.md +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/Makefile +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/api/gnarly.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/api/gnarly.utils.code.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/api/gnarly.utils.llm.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/api/gnarly.utils.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/api/modules.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/make.bat +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/api/gnarly.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/api/gnarly.utils.code.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/api/gnarly.utils.llm.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/api/gnarly.utils.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/api/modules.rst +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/api.md +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/conf.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/index.md +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/docs/source/usage.md +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/__init__.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/constants.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/errors.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/types.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/__init__.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/code/__init__.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/io.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/llm/__init__.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/llm/chatgpt.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/llm/claude.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/src/gnarly/utils/llm/models.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/tests/__init__.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/tests/test_constants.py +0 -0
- {gnarly-0.0.0.dev10 → gnarly-0.0.0.dev12}/tests/test_io_utilities.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "gnarly"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.0dev12"
|
|
4
4
|
description = "A sophisticated, general-use abstraction layer for the lazy."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "K. LeBryce", email = "k.lebryce@pm.me" }]
|
|
@@ -9,6 +9,8 @@ dependencies = ["python-dotenv>=1.1.0", "starch"]
|
|
|
9
9
|
|
|
10
10
|
[project.scripts]
|
|
11
11
|
gnarly = "gnarly:main"
|
|
12
|
+
chatgpt = "gnarly.utils.llm.chatgpt:main"
|
|
13
|
+
claude = "gnarly.utils.llm.claude:main"
|
|
12
14
|
|
|
13
15
|
[build-system]
|
|
14
16
|
requires = ["hatchling"]
|
|
@@ -134,7 +134,7 @@ class Project(GnarlyNamespace):
|
|
|
134
134
|
logger.info(f"Created {p}")
|
|
135
135
|
|
|
136
136
|
core_package_dir: Path = root_path / f"src/{name}"
|
|
137
|
-
core_package_dir.
|
|
137
|
+
core_package_dir.mkdir(parents=True, exist_ok=True)
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
return Project.create(
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
LLM Interfaces
|
|
3
|
+
==============
|
|
4
|
+
|
|
5
|
+
Dependency-free interfaces for LLM interaction.
|
|
2
6
|
|
|
3
|
-
Classes for interfacing with LLMs as defined in the `models` module.
|
|
4
7
|
"""
|
|
5
8
|
# ─── import statements ───────────────────────────────────────────────── ✦✦ ──
|
|
6
9
|
|
|
@@ -12,13 +15,7 @@ import urllib.request
|
|
|
12
15
|
import urllib.parse
|
|
13
16
|
from datetime import datetime as dt
|
|
14
17
|
from pathlib import Path
|
|
15
|
-
from typing import Dict, List, Tuple,
|
|
16
|
-
if TYPE_CHECKING:
|
|
17
|
-
from _typeshed import SupportsWrite
|
|
18
|
-
|
|
19
|
-
# third-party imports
|
|
20
|
-
from dotenv import load_dotenv
|
|
21
|
-
from platformdirs import user_config_path
|
|
18
|
+
from typing import Dict, List, Tuple, Union
|
|
22
19
|
|
|
23
20
|
# local imports
|
|
24
21
|
from .models import (
|
|
@@ -30,25 +27,6 @@ from .models import (
|
|
|
30
27
|
logger = logging.getLogger(__name__)
|
|
31
28
|
logging.basicConfig(level=logging.INFO)
|
|
32
29
|
|
|
33
|
-
# ─── constants ─────────────────────────────────────────────────────────── ✦ ─
|
|
34
|
-
APP_NAME = "gnarly"
|
|
35
|
-
APP_AUTHOR = "k.lebryce"
|
|
36
|
-
APP_CONFIG_DIR: Path = user_config_path(
|
|
37
|
-
APP_NAME, APP_AUTHOR, ensure_exists=True
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
# load environment variables from .env file
|
|
41
|
-
try:
|
|
42
|
-
load_dotenv(Path(APP_CONFIG_DIR, ".env").resolve())
|
|
43
|
-
except FileNotFoundError:
|
|
44
|
-
APP_CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
|
45
|
-
Path(APP_CONFIG_DIR, ".env").touch()
|
|
46
|
-
except IOError as e:
|
|
47
|
-
raise IOError(
|
|
48
|
-
"Failed to load environment variables from .env file."
|
|
49
|
-
) from e
|
|
50
|
-
|
|
51
|
-
|
|
52
30
|
# ─── interfaces ──────────────────────────────────────────────────────── ✦✦ ──
|
|
53
31
|
class Claude(ClaudeModel):
|
|
54
32
|
"""
|
|
@@ -115,17 +93,51 @@ class Claude(ClaudeModel):
|
|
|
115
93
|
@property
|
|
116
94
|
def api_key(self) -> str:
|
|
117
95
|
"""
|
|
118
|
-
Get the API key
|
|
96
|
+
Get the full API key for actual usage.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
str
|
|
101
|
+
The complete API key.
|
|
102
|
+
"""
|
|
103
|
+
return getattr(self, '_api_key', '')
|
|
104
|
+
|
|
105
|
+
@api_key.setter
|
|
106
|
+
def api_key(self, value: str) -> None:
|
|
107
|
+
"""
|
|
108
|
+
Set the full API key for actual usage.
|
|
109
|
+
|
|
110
|
+
Returns
|
|
111
|
+
-------
|
|
112
|
+
None
|
|
113
|
+
"""
|
|
114
|
+
self._api_key = value
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def api_key_masked(self) -> str:
|
|
118
|
+
"""
|
|
119
|
+
Get the API key masked for display/documentation.
|
|
119
120
|
|
|
120
121
|
Returns
|
|
121
122
|
-------
|
|
122
123
|
str
|
|
123
|
-
Masked API key string.
|
|
124
|
+
Masked API key string showing only last 4 characters.
|
|
124
125
|
"""
|
|
125
126
|
if hasattr(self, '_api_key') and self._api_key:
|
|
126
127
|
return f"sk-...{self._api_key[-4:]}" if len(self._api_key) > 4 else "***"
|
|
127
128
|
return ""
|
|
128
129
|
|
|
130
|
+
@api_key_masked.setter
|
|
131
|
+
def api_key_masked(self, value: str) -> None:
|
|
132
|
+
"""
|
|
133
|
+
Set the masked API key for display/documentation.
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
None
|
|
138
|
+
"""
|
|
139
|
+
self._api_key_masked = value
|
|
140
|
+
|
|
129
141
|
def message(self, msg: str) -> Tuple[Dict, Dict]:
|
|
130
142
|
"""
|
|
131
143
|
Send a message to Claude and get a response.
|
|
@@ -309,17 +321,52 @@ class ChatGPT(ChatGPTModel):
|
|
|
309
321
|
@property
|
|
310
322
|
def api_key(self) -> str:
|
|
311
323
|
"""
|
|
312
|
-
Get the API key
|
|
324
|
+
Get the full API key for actual usage.
|
|
325
|
+
|
|
326
|
+
Returns
|
|
327
|
+
-------
|
|
328
|
+
str
|
|
329
|
+
The complete API key.
|
|
330
|
+
"""
|
|
331
|
+
return getattr(self, '_api_key', '')
|
|
332
|
+
|
|
333
|
+
@api_key.setter
|
|
334
|
+
def api_key(self, value: str) -> None:
|
|
335
|
+
"""
|
|
336
|
+
Set the full API key for actual usage.
|
|
337
|
+
|
|
338
|
+
Returns
|
|
339
|
+
-------
|
|
340
|
+
str
|
|
341
|
+
The complete API key.
|
|
342
|
+
"""
|
|
343
|
+
self._api_key = value
|
|
344
|
+
|
|
345
|
+
@property
|
|
346
|
+
def api_key_masked(self) -> str:
|
|
347
|
+
"""
|
|
348
|
+
Get the API key masked for display/documentation.
|
|
313
349
|
|
|
314
350
|
Returns
|
|
315
351
|
-------
|
|
316
352
|
str
|
|
317
|
-
Masked API key string.
|
|
353
|
+
Masked API key string showing only last 4 characters.
|
|
318
354
|
"""
|
|
319
355
|
if hasattr(self, '_api_key') and self._api_key:
|
|
320
356
|
return f"sk-...{self._api_key[-4:]}" if len(self._api_key) > 4 else "***"
|
|
321
357
|
return ""
|
|
322
358
|
|
|
359
|
+
@api_key_masked.setter
|
|
360
|
+
def api_key_masked(self, value: str) -> None:
|
|
361
|
+
"""
|
|
362
|
+
Set the masked API key string.
|
|
363
|
+
|
|
364
|
+
Returns
|
|
365
|
+
-------
|
|
366
|
+
None
|
|
367
|
+
"""
|
|
368
|
+
self._api_key_masked = value
|
|
369
|
+
|
|
323
370
|
def message(self, msg: str) -> str:
|
|
324
371
|
"""
|
|
325
372
|
Send a message to ChatGPT and get a response.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|