pdd-cli 0.0.39__py3-none-any.whl → 0.0.40__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 pdd-cli might be problematic. Click here for more details.
- pdd/__init__.py +5 -4
- pdd/auto_deps_main.py +10 -6
- pdd/auto_include.py +143 -101
- pdd/auto_update.py +24 -11
- pdd/cmd_test_main.py +4 -3
- pdd/get_extension.py +23 -9
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.40.dist-info}/METADATA +3 -3
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.40.dist-info}/RECORD +12 -12
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.40.dist-info}/WHEEL +0 -0
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.40.dist-info}/entry_points.txt +0 -0
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.40.dist-info}/licenses/LICENSE +0 -0
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.40.dist-info}/top_level.txt +0 -0
pdd/__init__.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"""PDD - Prompt Driven Development"""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.0.40"
|
|
2
4
|
|
|
3
5
|
# Strength parameter used for LLM extraction across the codebase
|
|
4
|
-
# Used in postprocessing, XML tagging, code generation, and other extraction
|
|
6
|
+
# Used in postprocessing, XML tagging, code generation, and other extraction
|
|
7
|
+
# operations. The module should have a large context window and be affordable.
|
|
5
8
|
EXTRACTION_STRENGTH = 0.9
|
|
6
9
|
|
|
7
10
|
DEFAULT_STRENGTH = 0.9
|
|
@@ -10,8 +13,6 @@ DEFAULT_TEMPERATURE = 0.0
|
|
|
10
13
|
|
|
11
14
|
DEFAULT_TIME = 0.25
|
|
12
15
|
|
|
13
|
-
"""PDD - Prompt Driven Development"""
|
|
14
|
-
|
|
15
16
|
# Define constants used across the package
|
|
16
17
|
DEFAULT_LLM_MODEL = "gpt-4.1-nano"
|
|
17
18
|
# When going to production, set the following constants:
|
pdd/auto_deps_main.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"""Main function for the auto-deps command."""
|
|
1
2
|
import sys
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
from typing import Tuple, Optional
|
|
@@ -8,7 +9,7 @@ from . import DEFAULT_STRENGTH, DEFAULT_TIME
|
|
|
8
9
|
from .construct_paths import construct_paths
|
|
9
10
|
from .insert_includes import insert_includes
|
|
10
11
|
|
|
11
|
-
def auto_deps_main(
|
|
12
|
+
def auto_deps_main( # pylint: disable=too-many-arguments, too-many-locals
|
|
12
13
|
ctx: click.Context,
|
|
13
14
|
prompt_file: str,
|
|
14
15
|
directory_path: str,
|
|
@@ -57,7 +58,10 @@ def auto_deps_main(
|
|
|
57
58
|
# Handle force_scan option
|
|
58
59
|
if force_scan and Path(csv_path).exists():
|
|
59
60
|
if not ctx.obj.get('quiet', False):
|
|
60
|
-
rprint(
|
|
61
|
+
rprint(
|
|
62
|
+
"[yellow]Removing existing CSV file due to "
|
|
63
|
+
f"--force-scan option: {csv_path}[/yellow]"
|
|
64
|
+
)
|
|
61
65
|
Path(csv_path).unlink()
|
|
62
66
|
|
|
63
67
|
# Get strength and temperature from context
|
|
@@ -78,11 +82,11 @@ def auto_deps_main(
|
|
|
78
82
|
|
|
79
83
|
# Save the modified prompt to the output file
|
|
80
84
|
output_path = output_file_paths["output"]
|
|
81
|
-
Path(output_path).write_text(modified_prompt)
|
|
85
|
+
Path(output_path).write_text(modified_prompt, encoding="utf-8")
|
|
82
86
|
|
|
83
87
|
# Save the CSV output if it was generated
|
|
84
88
|
if csv_output:
|
|
85
|
-
Path(csv_path).write_text(csv_output)
|
|
89
|
+
Path(csv_path).write_text(csv_output, encoding="utf-8")
|
|
86
90
|
|
|
87
91
|
# Provide user feedback
|
|
88
92
|
if not ctx.obj.get('quiet', False):
|
|
@@ -94,7 +98,7 @@ def auto_deps_main(
|
|
|
94
98
|
|
|
95
99
|
return modified_prompt, total_cost, model_name
|
|
96
100
|
|
|
97
|
-
except Exception as
|
|
101
|
+
except Exception as exc:
|
|
98
102
|
if not ctx.obj.get('quiet', False):
|
|
99
|
-
rprint(f"[bold red]Error:[/bold red] {str(
|
|
103
|
+
rprint(f"[bold red]Error:[/bold red] {str(exc)}")
|
|
100
104
|
sys.exit(1)
|
pdd/auto_include.py
CHANGED
|
@@ -1,20 +1,113 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides the `auto_include` function to automatically find and
|
|
3
|
+
insert dependencies into a prompt.
|
|
4
|
+
"""
|
|
5
|
+
from io import StringIO
|
|
1
6
|
from typing import Tuple, Optional
|
|
7
|
+
|
|
8
|
+
import pandas as pd
|
|
2
9
|
from pydantic import BaseModel, Field
|
|
3
|
-
from rich import print
|
|
4
10
|
from rich.console import Console
|
|
5
11
|
from rich.panel import Panel
|
|
6
|
-
|
|
12
|
+
|
|
13
|
+
from . import DEFAULT_TIME, DEFAULT_STRENGTH
|
|
7
14
|
from .llm_invoke import llm_invoke
|
|
15
|
+
from .load_prompt_template import load_prompt_template
|
|
8
16
|
from .summarize_directory import summarize_directory
|
|
9
|
-
import pandas as pd
|
|
10
|
-
from io import StringIO
|
|
11
|
-
from . import DEFAULT_TIME, DEFAULT_STRENGTH
|
|
12
17
|
|
|
13
18
|
console = Console()
|
|
14
19
|
|
|
15
20
|
class AutoIncludeOutput(BaseModel):
|
|
21
|
+
"""
|
|
22
|
+
Pydantic model for the output of the auto_include extraction.
|
|
23
|
+
"""
|
|
16
24
|
string_of_includes: str = Field(description="The string of includes to be added to the prompt")
|
|
17
25
|
|
|
26
|
+
|
|
27
|
+
def _validate_input(input_prompt: str, directory_path: str, strength: float, temperature: float):
|
|
28
|
+
"""Validate the inputs for the auto_include function."""
|
|
29
|
+
if not input_prompt:
|
|
30
|
+
raise ValueError("Input prompt cannot be empty")
|
|
31
|
+
if not directory_path:
|
|
32
|
+
raise ValueError("Invalid 'directory_path'.")
|
|
33
|
+
if not 0 <= strength <= 1:
|
|
34
|
+
raise ValueError("Strength must be between 0 and 1")
|
|
35
|
+
if not 0 <= temperature <= 1:
|
|
36
|
+
raise ValueError("Temperature must be between 0 and 1")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _get_available_includes_from_csv(csv_output: str) -> list[str]:
|
|
40
|
+
"""Parse the CSV output and return a list of available includes."""
|
|
41
|
+
if not csv_output:
|
|
42
|
+
return []
|
|
43
|
+
try:
|
|
44
|
+
# pylint: disable=invalid-name
|
|
45
|
+
dataframe = pd.read_csv(StringIO(csv_output))
|
|
46
|
+
return dataframe.apply(
|
|
47
|
+
lambda row: f"File: {row['full_path']}\nSummary: {row['file_summary']}",
|
|
48
|
+
axis=1
|
|
49
|
+
).tolist()
|
|
50
|
+
except Exception as ex:
|
|
51
|
+
console.print(f"[red]Error parsing CSV: {str(ex)}[/red]")
|
|
52
|
+
return []
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _load_prompts() -> tuple[str, str]:
|
|
56
|
+
"""Load the prompt templates."""
|
|
57
|
+
auto_include_prompt = load_prompt_template("auto_include_LLM")
|
|
58
|
+
extract_prompt = load_prompt_template("extract_auto_include_LLM")
|
|
59
|
+
if not auto_include_prompt or not extract_prompt:
|
|
60
|
+
raise ValueError("Failed to load prompt templates")
|
|
61
|
+
return auto_include_prompt, extract_prompt
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _summarize(directory_path: str, csv_file: Optional[str], llm_kwargs: dict) -> tuple[str, float, str]:
|
|
65
|
+
"""Summarize the directory."""
|
|
66
|
+
return summarize_directory(
|
|
67
|
+
directory_path=directory_path,
|
|
68
|
+
csv_file=csv_file,
|
|
69
|
+
**llm_kwargs
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _run_llm_and_extract(
|
|
74
|
+
auto_include_prompt: str,
|
|
75
|
+
extract_prompt: str,
|
|
76
|
+
input_prompt: str,
|
|
77
|
+
available_includes: list[str],
|
|
78
|
+
llm_kwargs: dict,
|
|
79
|
+
) -> tuple[str, float, str]:
|
|
80
|
+
"""Run the LLM prompts and extract the dependencies."""
|
|
81
|
+
# pylint: disable=broad-except
|
|
82
|
+
# Run auto_include_LLM prompt
|
|
83
|
+
auto_include_response = llm_invoke(
|
|
84
|
+
prompt=auto_include_prompt,
|
|
85
|
+
input_json={
|
|
86
|
+
"input_prompt": input_prompt,
|
|
87
|
+
"available_includes": "\n".join(available_includes)
|
|
88
|
+
},
|
|
89
|
+
**llm_kwargs
|
|
90
|
+
)
|
|
91
|
+
total_cost = auto_include_response["cost"]
|
|
92
|
+
model_name = auto_include_response["model_name"]
|
|
93
|
+
|
|
94
|
+
# Run extract_auto_include_LLM prompt
|
|
95
|
+
try:
|
|
96
|
+
extract_response = llm_invoke(
|
|
97
|
+
prompt=extract_prompt,
|
|
98
|
+
input_json={"llm_output": auto_include_response["result"]},
|
|
99
|
+
output_pydantic=AutoIncludeOutput,
|
|
100
|
+
**llm_kwargs
|
|
101
|
+
)
|
|
102
|
+
total_cost += extract_response["cost"]
|
|
103
|
+
model_name = extract_response["model_name"]
|
|
104
|
+
dependencies = extract_response["result"].string_of_includes
|
|
105
|
+
except Exception as ex:
|
|
106
|
+
console.print(f"[red]Error extracting dependencies: {str(ex)}[/red]")
|
|
107
|
+
dependencies = ""
|
|
108
|
+
return dependencies, total_cost, model_name
|
|
109
|
+
|
|
110
|
+
|
|
18
111
|
def auto_include(
|
|
19
112
|
input_prompt: str,
|
|
20
113
|
directory_path: str,
|
|
@@ -39,128 +132,77 @@ def auto_include(
|
|
|
39
132
|
Returns:
|
|
40
133
|
Tuple[str, str, float, str]: (dependencies, csv_output, total_cost, model_name)
|
|
41
134
|
"""
|
|
135
|
+
# pylint: disable=broad-except
|
|
42
136
|
try:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
raise ValueError("Temperature must be between 0 and 1")
|
|
52
|
-
|
|
53
|
-
total_cost = 0.0
|
|
54
|
-
model_name = ""
|
|
137
|
+
_validate_input(input_prompt, directory_path, strength, temperature)
|
|
138
|
+
|
|
139
|
+
llm_kwargs = {
|
|
140
|
+
"strength": strength,
|
|
141
|
+
"temperature": temperature,
|
|
142
|
+
"time": time,
|
|
143
|
+
"verbose": verbose
|
|
144
|
+
}
|
|
55
145
|
|
|
56
146
|
if verbose:
|
|
57
147
|
console.print(Panel("Step 1: Loading prompt templates", style="blue"))
|
|
58
148
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
extract_prompt = load_prompt_template("extract_auto_include_LLM")
|
|
62
|
-
|
|
63
|
-
if not auto_include_prompt or not extract_prompt:
|
|
64
|
-
raise ValueError("Failed to load prompt templates")
|
|
65
|
-
|
|
149
|
+
auto_include_prompt, extract_prompt = _load_prompts()
|
|
150
|
+
|
|
66
151
|
if verbose:
|
|
67
152
|
console.print(Panel("Step 2: Running summarize_directory", style="blue"))
|
|
68
153
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
directory_path=directory_path,
|
|
72
|
-
strength=strength,
|
|
73
|
-
temperature=temperature,
|
|
74
|
-
time=time,
|
|
75
|
-
verbose=verbose,
|
|
76
|
-
csv_file=csv_file
|
|
154
|
+
csv_output, summary_cost, summary_model = _summarize(
|
|
155
|
+
directory_path, csv_file, llm_kwargs
|
|
77
156
|
)
|
|
78
|
-
total_cost += summary_cost
|
|
79
|
-
model_name = summary_model
|
|
80
|
-
|
|
81
|
-
# Parse CSV to get available includes
|
|
82
|
-
if not csv_output:
|
|
83
|
-
available_includes = []
|
|
84
|
-
else:
|
|
85
|
-
try:
|
|
86
|
-
df = pd.read_csv(StringIO(csv_output))
|
|
87
|
-
available_includes = df.apply(
|
|
88
|
-
lambda row: f"File: {row['full_path']}\nSummary: {row['file_summary']}",
|
|
89
|
-
axis=1
|
|
90
|
-
).tolist()
|
|
91
|
-
except Exception as e:
|
|
92
|
-
console.print(f"[red]Error parsing CSV: {str(e)}[/red]")
|
|
93
|
-
available_includes = []
|
|
94
157
|
|
|
158
|
+
available_includes = _get_available_includes_from_csv(csv_output)
|
|
159
|
+
|
|
95
160
|
if verbose:
|
|
96
161
|
console.print(Panel("Step 3: Running auto_include_LLM prompt", style="blue"))
|
|
97
162
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
strength=strength,
|
|
106
|
-
temperature=temperature,
|
|
107
|
-
time=time,
|
|
108
|
-
verbose=verbose
|
|
163
|
+
dependencies, llm_cost, llm_model_name = _run_llm_and_extract(
|
|
164
|
+
auto_include_prompt=auto_include_prompt,
|
|
165
|
+
extract_prompt=extract_prompt,
|
|
166
|
+
input_prompt=input_prompt,
|
|
167
|
+
available_includes=available_includes,
|
|
168
|
+
llm_kwargs=llm_kwargs,
|
|
109
169
|
)
|
|
110
|
-
|
|
111
|
-
|
|
170
|
+
|
|
171
|
+
total_cost = summary_cost + llm_cost
|
|
172
|
+
model_name = llm_model_name or summary_model
|
|
112
173
|
|
|
113
174
|
if verbose:
|
|
114
|
-
console.print(Panel(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
verbose=verbose,
|
|
125
|
-
output_pydantic=AutoIncludeOutput
|
|
126
|
-
)
|
|
127
|
-
total_cost += extract_response["cost"]
|
|
128
|
-
model_name = extract_response["model_name"]
|
|
129
|
-
|
|
130
|
-
if verbose:
|
|
131
|
-
console.print(Panel("Step 5: Extracting dependencies", style="blue"))
|
|
132
|
-
|
|
133
|
-
# Extract dependencies
|
|
134
|
-
dependencies = extract_response["result"].string_of_includes
|
|
135
|
-
except Exception as e:
|
|
136
|
-
console.print(f"[red]Error extracting dependencies: {str(e)}[/red]")
|
|
137
|
-
dependencies = ""
|
|
138
|
-
|
|
139
|
-
if verbose:
|
|
140
|
-
console.print(Panel(f"""
|
|
141
|
-
Results:
|
|
142
|
-
Dependencies: {dependencies}
|
|
143
|
-
CSV Output: {csv_output}
|
|
144
|
-
Total Cost: ${total_cost:.6f}
|
|
145
|
-
Model Used: {model_name}
|
|
146
|
-
""", style="green"))
|
|
175
|
+
console.print(Panel(
|
|
176
|
+
(
|
|
177
|
+
f"Results:\n"
|
|
178
|
+
f"Dependencies: {dependencies}\n"
|
|
179
|
+
f"CSV Output: {csv_output}\n"
|
|
180
|
+
f"Total Cost: ${total_cost:.6f}\n"
|
|
181
|
+
f"Model Used: {model_name}"
|
|
182
|
+
),
|
|
183
|
+
style="green"
|
|
184
|
+
))
|
|
147
185
|
|
|
148
186
|
return dependencies, csv_output, total_cost, model_name
|
|
149
187
|
|
|
150
|
-
except Exception as
|
|
151
|
-
console.print(f"[red]Error in auto_include: {str(
|
|
188
|
+
except Exception as ex:
|
|
189
|
+
console.print(f"[red]Error in auto_include: {str(ex)}[/red]")
|
|
152
190
|
raise
|
|
153
191
|
|
|
192
|
+
|
|
154
193
|
def main():
|
|
155
194
|
"""Example usage of auto_include function"""
|
|
156
195
|
try:
|
|
157
196
|
# Example inputs
|
|
158
197
|
input_prompt = "Write a function to process image data"
|
|
159
198
|
directory_path = "context/c*.py"
|
|
160
|
-
csv_file =
|
|
161
|
-
|
|
199
|
+
csv_file = (
|
|
200
|
+
"full_path,file_summary,date\n"
|
|
201
|
+
"context/image_utils.py,"
|
|
202
|
+
"\"Image processing utilities\",2023-01-01T10:00:00"
|
|
203
|
+
)
|
|
162
204
|
|
|
163
|
-
dependencies,
|
|
205
|
+
dependencies, _, total_cost, model_name = auto_include(
|
|
164
206
|
input_prompt=input_prompt,
|
|
165
207
|
directory_path=directory_path,
|
|
166
208
|
csv_file=csv_file,
|
|
@@ -175,8 +217,8 @@ context/image_utils.py,"Image processing utilities",2023-01-01T10:00:00"""
|
|
|
175
217
|
console.print(f"Total Cost: ${total_cost:.6f}")
|
|
176
218
|
console.print(f"Model Used: {model_name}")
|
|
177
219
|
|
|
178
|
-
except Exception as
|
|
179
|
-
console.print(f"[red]Error in main: {str(
|
|
220
|
+
except Exception as ex:
|
|
221
|
+
console.print(f"[red]Error in main: {str(ex)}[/red]")
|
|
180
222
|
|
|
181
223
|
if __name__ == "__main__":
|
|
182
224
|
main()
|
pdd/auto_update.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"""This module provides a function to automatically update the package."""
|
|
1
2
|
import importlib.metadata
|
|
2
3
|
import requests
|
|
3
4
|
import semver
|
|
@@ -63,11 +64,11 @@ def auto_update(package_name: str = "pdd-cli", latest_version: str = None) -> No
|
|
|
63
64
|
if latest_version is None:
|
|
64
65
|
try:
|
|
65
66
|
pypi_url = f"https://pypi.org/pypi/{package_name}/json"
|
|
66
|
-
response = requests.get(pypi_url)
|
|
67
|
+
response = requests.get(pypi_url, timeout=10)
|
|
67
68
|
response.raise_for_status()
|
|
68
69
|
latest_version = response.json()['info']['version']
|
|
69
|
-
except Exception as
|
|
70
|
-
print(f"Failed to fetch latest version from PyPI: {str(
|
|
70
|
+
except Exception as ex:
|
|
71
|
+
print(f"Failed to fetch latest version from PyPI: {str(ex)}")
|
|
71
72
|
return
|
|
72
73
|
|
|
73
74
|
# Compare versions using semantic versioning
|
|
@@ -99,7 +100,13 @@ def auto_update(package_name: str = "pdd-cli", latest_version: str = None) -> No
|
|
|
99
100
|
print(f"Upgrading with command: {cmd_str}")
|
|
100
101
|
|
|
101
102
|
try:
|
|
102
|
-
result = subprocess.run(
|
|
103
|
+
result = subprocess.run(
|
|
104
|
+
cmd,
|
|
105
|
+
shell=use_shell,
|
|
106
|
+
capture_output=True,
|
|
107
|
+
text=True,
|
|
108
|
+
check=False
|
|
109
|
+
)
|
|
103
110
|
|
|
104
111
|
if result.returncode == 0:
|
|
105
112
|
print(f"\nSuccessfully upgraded {package_name} to version {latest_version}")
|
|
@@ -114,15 +121,21 @@ def auto_update(package_name: str = "pdd-cli", latest_version: str = None) -> No
|
|
|
114
121
|
print(f"Fallback command: {fallback_str}")
|
|
115
122
|
|
|
116
123
|
try:
|
|
117
|
-
fallback_result = subprocess.run(
|
|
124
|
+
fallback_result = subprocess.run(
|
|
125
|
+
fallback_cmd,
|
|
126
|
+
shell=fallback_shell,
|
|
127
|
+
capture_output=True,
|
|
128
|
+
text=True,
|
|
129
|
+
check=False
|
|
130
|
+
)
|
|
118
131
|
if fallback_result.returncode == 0:
|
|
119
132
|
print(f"\nSuccessfully upgraded {package_name} using fallback method")
|
|
120
133
|
else:
|
|
121
134
|
print(f"\nFallback upgrade failed: {fallback_result.stderr}")
|
|
122
|
-
except Exception as
|
|
123
|
-
print(f"\nError during fallback upgrade: {str(
|
|
124
|
-
except Exception as
|
|
125
|
-
print(f"\nError during upgrade: {str(
|
|
135
|
+
except Exception as fallback_ex:
|
|
136
|
+
print(f"\nError during fallback upgrade: {str(fallback_ex)}")
|
|
137
|
+
except Exception as ex:
|
|
138
|
+
print(f"\nError during upgrade: {str(ex)}")
|
|
126
139
|
break
|
|
127
140
|
elif response in ['n', 'no', '']:
|
|
128
141
|
print("\nUpgrade cancelled")
|
|
@@ -132,8 +145,8 @@ def auto_update(package_name: str = "pdd-cli", latest_version: str = None) -> No
|
|
|
132
145
|
|
|
133
146
|
except importlib.metadata.PackageNotFoundError:
|
|
134
147
|
print(f"Package {package_name} is not installed")
|
|
135
|
-
except Exception as
|
|
136
|
-
print(f"Error checking for updates: {str(
|
|
148
|
+
except Exception as ex:
|
|
149
|
+
print(f"Error checking for updates: {str(ex)}")
|
|
137
150
|
|
|
138
151
|
|
|
139
152
|
if __name__ == "__main__":
|
pdd/cmd_test_main.py
CHANGED
|
@@ -98,10 +98,11 @@ def cmd_test_main(
|
|
|
98
98
|
unit_test, total_cost, model_name = generate_test(
|
|
99
99
|
input_strings["prompt_file"],
|
|
100
100
|
input_strings["code_file"],
|
|
101
|
-
strength,
|
|
102
|
-
temperature,
|
|
103
|
-
language,
|
|
101
|
+
strength=strength,
|
|
102
|
+
temperature=temperature,
|
|
104
103
|
time=time,
|
|
104
|
+
language=language,
|
|
105
|
+
verbose=verbose
|
|
105
106
|
)
|
|
106
107
|
except Exception as e:
|
|
107
108
|
print(f"[bold red]Error generating tests: {e}[/bold red]")
|
pdd/get_extension.py
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
"""Module to retrieve file extensions for programming languages."""
|
|
2
2
|
|
|
3
|
-
# ```python
|
|
4
3
|
import os
|
|
5
4
|
import pandas as pd
|
|
6
5
|
|
|
7
|
-
def get_extension(language):
|
|
6
|
+
def get_extension(language: str) -> str:
|
|
7
|
+
"""
|
|
8
|
+
Retrieves the file extension for a given programming language.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
language: The name of the programming language.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
The file extension (e.g., ".py") or an empty string if not found
|
|
15
|
+
or if the extension is invalid.
|
|
16
|
+
|
|
17
|
+
Raises:
|
|
18
|
+
ValueError: If the PDD_PATH environment variable is not set.
|
|
19
|
+
FileNotFoundError: If the language_format.csv file is not found.
|
|
20
|
+
"""
|
|
8
21
|
# Step 1: Load the environment variable PDD_PATH
|
|
9
22
|
pdd_path = os.getenv('PDD_PATH')
|
|
10
23
|
if not pdd_path:
|
|
@@ -18,24 +31,25 @@ def get_extension(language):
|
|
|
18
31
|
|
|
19
32
|
# Step 3: Load the CSV file and look up the file extension
|
|
20
33
|
try:
|
|
21
|
-
|
|
22
|
-
except FileNotFoundError:
|
|
23
|
-
raise FileNotFoundError(
|
|
34
|
+
dataframe = pd.read_csv(csv_file_path)
|
|
35
|
+
except FileNotFoundError as exc:
|
|
36
|
+
raise FileNotFoundError(
|
|
37
|
+
f"The file {csv_file_path} does not exist."
|
|
38
|
+
) from exc
|
|
24
39
|
|
|
25
40
|
# Check if the language exists in the DataFrame
|
|
26
|
-
row =
|
|
41
|
+
row = dataframe[dataframe['language'].str.lower() == language_lower]
|
|
27
42
|
|
|
28
43
|
# Step 4: Return the file extension or an empty string if not found
|
|
29
44
|
if not row.empty:
|
|
30
45
|
extension = row['extension'].values[0]
|
|
31
46
|
return extension if isinstance(extension, str) and extension else ''
|
|
32
|
-
|
|
47
|
+
|
|
33
48
|
return ''
|
|
34
49
|
|
|
35
50
|
# Example usage:
|
|
36
51
|
# Assuming the environment variable PDD_PATH is set correctly
|
|
37
52
|
# print(get_extension('Python')) # Output: .py
|
|
38
|
-
# ```
|
|
39
53
|
|
|
40
54
|
# ### Explanation of the Code:
|
|
41
55
|
# 1. **Environment Variable**: We use `os.getenv` to retrieve the `PDD_PATH` environment variable. If it's not set, we raise a `ValueError`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pdd-cli
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.40
|
|
4
4
|
Summary: PDD (Prompt-Driven Development) Command Line Interface
|
|
5
5
|
Author: Greg Tanaka
|
|
6
6
|
Author-email: glt@alumni.caltech.edu
|
|
@@ -46,7 +46,7 @@ Requires-Dist: pytest-asyncio; extra == "dev"
|
|
|
46
46
|
Requires-Dist: z3-solver; extra == "dev"
|
|
47
47
|
Dynamic: license-file
|
|
48
48
|
|
|
49
|
-
.. image:: https://img.shields.io/badge/pdd--cli-v0.0.
|
|
49
|
+
.. image:: https://img.shields.io/badge/pdd--cli-v0.0.40-blue
|
|
50
50
|
:alt: PDD-CLI Version
|
|
51
51
|
|
|
52
52
|
.. image:: https://img.shields.io/badge/Discord-join%20chat-7289DA.svg?logo=discord&logoColor=white&link=https://discord.gg/Yp4RTh8bG7
|
|
@@ -134,7 +134,7 @@ After installation, verify:
|
|
|
134
134
|
|
|
135
135
|
pdd --version
|
|
136
136
|
|
|
137
|
-
You'll see the current PDD version (e.g., 0.0.
|
|
137
|
+
You'll see the current PDD version (e.g., 0.0.40).
|
|
138
138
|
|
|
139
139
|
Advanced Installation Tips
|
|
140
140
|
--------------------------
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
pdd/__init__.py,sha256=
|
|
2
|
-
pdd/auto_deps_main.py,sha256=
|
|
3
|
-
pdd/auto_include.py,sha256=
|
|
4
|
-
pdd/auto_update.py,sha256=
|
|
1
|
+
pdd/__init__.py,sha256=3z8Rvrnfpp6Nq9xOkec13pyns9KipcsDyT5lIp67Yvs,634
|
|
2
|
+
pdd/auto_deps_main.py,sha256=Ds6w9H6qD5vAqm7XEj_AZ135qPnwdvgw5k7iQpJFEdw,3899
|
|
3
|
+
pdd/auto_include.py,sha256=OJcdcwTwJNqHPHKG9P4m9Ij-PiLex0EbuwJP0uiQi_Y,7484
|
|
4
|
+
pdd/auto_update.py,sha256=5i6a_cpbJgwy0wGCHnlxyFXPqusqp0hDFj6Q1zLoOww,6432
|
|
5
5
|
pdd/bug_main.py,sha256=--LsMu5pkPbuj2aacTyOe9e8hwNLl8DGmrvXo9Ao5Ws,4770
|
|
6
6
|
pdd/bug_to_unit_test.py,sha256=38ov-xy5dxgClx4WpuzF7kF9yyljkDwcBUiMbCK0YmM,6569
|
|
7
7
|
pdd/change.py,sha256=Gn-JpkzUB-0n-sxvZCarbi020v2iC8M1iXSBnZ5z3Zc,5681
|
|
8
8
|
pdd/change_main.py,sha256=NvncNg0xfkW084U3BqZ0aMDpw_kT3gtK4zmYie9cnyg,25670
|
|
9
9
|
pdd/cli.py,sha256=AyDFfsN6lJ9T39Mb6r-drFfU3REnxryYmDVvYiEiW-U,39454
|
|
10
|
-
pdd/cmd_test_main.py,sha256=
|
|
10
|
+
pdd/cmd_test_main.py,sha256=eakbDjYZElghVun_SJTuCSB1nJpyPHJxfv6n4eUYxD0,5448
|
|
11
11
|
pdd/code_generator.py,sha256=KwbLgMfEER-qebGJdk5i25Qj3XdnHkVttjBlEeDasHs,4651
|
|
12
12
|
pdd/code_generator_main.py,sha256=Uo__Rs6JDJx0NR02VmTFlW5_lpEYHcFpN1f2isLqfEc,25300
|
|
13
13
|
pdd/comment_line.py,sha256=sX2hf4bG1fILi_rvI9MkkwCZ2IitgKkW7nOiw8aQKPY,1845
|
|
@@ -33,7 +33,7 @@ pdd/fix_verification_main.py,sha256=gCCfdSEFFK3SJ4j-XFjg7v5zWJcRyW0bl7mRnVJbSHc,
|
|
|
33
33
|
pdd/generate_output_paths.py,sha256=o8Sjx0zLeBXXxEirGewcla40RinjTfnkrxBldRQ6HvI,20237
|
|
34
34
|
pdd/generate_test.py,sha256=2tmCQcvWa_hCXDmfjRrk0IDX2SIevAu8dEL9SPnM2ew,5122
|
|
35
35
|
pdd/get_comment.py,sha256=yuRtk68-SDkMaGzOSyIFdldRoymJBRSKjOYkr0narVc,2627
|
|
36
|
-
pdd/get_extension.py,sha256=
|
|
36
|
+
pdd/get_extension.py,sha256=IwpnwGLKMkVcEtQWHeGriphq2g5r8mGLftXir48vrjQ,2675
|
|
37
37
|
pdd/get_jwt_token.py,sha256=BGxqMh7qf2mG-TFw7JlV941O9XtrW22L_dRoS_UZNjM,11560
|
|
38
38
|
pdd/get_language.py,sha256=yxyQqVEb5H3ep3Hc6XgAl3vMLTHD5OIs8ZSekB493GA,1438
|
|
39
39
|
pdd/git_update.py,sha256=ZpU_uqUx1Or_zmqP307y_6EMk4ruqpDcXumDX_KHQZU,2936
|
|
@@ -101,9 +101,9 @@ pdd/prompts/trim_results_start_LLM.prompt,sha256=OKz8fAf1cYWKWgslFOHEkUpfaUDARh3
|
|
|
101
101
|
pdd/prompts/unfinished_prompt_LLM.prompt,sha256=-JgBpiPTQZdWOAwOG1XpfpD9waynFTAT3Jo84eQ4bTw,1543
|
|
102
102
|
pdd/prompts/update_prompt_LLM.prompt,sha256=prIc8uLp2jqnLTHt6JvWDZGanPZipivhhYeXe0lVaYw,1328
|
|
103
103
|
pdd/prompts/xml_convertor_LLM.prompt,sha256=YGRGXJeg6EhM9690f-SKqQrKqSJjLFD51UrPOlO0Frg,2786
|
|
104
|
-
pdd_cli-0.0.
|
|
105
|
-
pdd_cli-0.0.
|
|
106
|
-
pdd_cli-0.0.
|
|
107
|
-
pdd_cli-0.0.
|
|
108
|
-
pdd_cli-0.0.
|
|
109
|
-
pdd_cli-0.0.
|
|
104
|
+
pdd_cli-0.0.40.dist-info/licenses/LICENSE,sha256=-1bjYH-CEjGEQ8VixtnRYuu37kN6F9NxmZSDkBuUQ9o,1062
|
|
105
|
+
pdd_cli-0.0.40.dist-info/METADATA,sha256=a1pWYgKaF9cGJrqans0uKyOFI7EKA0Q21KAJLfEOU4E,7968
|
|
106
|
+
pdd_cli-0.0.40.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
107
|
+
pdd_cli-0.0.40.dist-info/entry_points.txt,sha256=Kr8HtNVb8uHZtQJNH4DnF8j7WNgWQbb7_Pw5hECSR-I,36
|
|
108
|
+
pdd_cli-0.0.40.dist-info/top_level.txt,sha256=xjnhIACeMcMeDfVNREgQZl4EbTni2T11QkL5r7E-sbE,4
|
|
109
|
+
pdd_cli-0.0.40.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|