pdd-cli 0.0.38__py3-none-any.whl → 0.0.39__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.

Files changed (48) hide show
  1. pdd/__init__.py +1 -1
  2. pdd/auto_deps_main.py +4 -1
  3. pdd/auto_include.py +8 -1
  4. pdd/bug_main.py +5 -2
  5. pdd/bug_to_unit_test.py +9 -2
  6. pdd/change.py +32 -22
  7. pdd/change_main.py +14 -10
  8. pdd/cli.py +11 -1
  9. pdd/cmd_test_main.py +3 -0
  10. pdd/code_generator.py +7 -1
  11. pdd/code_generator_main.py +9 -3
  12. pdd/conflicts_in_prompts.py +7 -2
  13. pdd/conflicts_main.py +6 -2
  14. pdd/context_generator.py +20 -3
  15. pdd/context_generator_main.py +2 -0
  16. pdd/continue_generation.py +8 -2
  17. pdd/crash_main.py +51 -31
  18. pdd/detect_change.py +8 -4
  19. pdd/detect_change_main.py +3 -0
  20. pdd/fix_code_loop.py +7 -2
  21. pdd/fix_code_module_errors.py +5 -2
  22. pdd/fix_error_loop.py +6 -2
  23. pdd/fix_errors_from_unit_tests.py +11 -6
  24. pdd/fix_main.py +4 -0
  25. pdd/fix_verification_errors.py +8 -3
  26. pdd/fix_verification_errors_loop.py +9 -3
  27. pdd/fix_verification_main.py +37 -31
  28. pdd/generate_test.py +10 -4
  29. pdd/git_update.py +5 -3
  30. pdd/increase_tests.py +5 -2
  31. pdd/insert_includes.py +8 -2
  32. pdd/preprocess_main.py +10 -3
  33. pdd/process_csv_change.py +8 -2
  34. pdd/split.py +15 -7
  35. pdd/split_main.py +2 -0
  36. pdd/summarize_directory.py +4 -0
  37. pdd/trace.py +9 -5
  38. pdd/trace_main.py +5 -4
  39. pdd/unfinished_prompt.py +6 -1
  40. pdd/update_main.py +6 -3
  41. pdd/update_prompt.py +8 -4
  42. pdd/xml_tagger.py +10 -5
  43. {pdd_cli-0.0.38.dist-info → pdd_cli-0.0.39.dist-info}/METADATA +4 -4
  44. {pdd_cli-0.0.38.dist-info → pdd_cli-0.0.39.dist-info}/RECORD +48 -48
  45. {pdd_cli-0.0.38.dist-info → pdd_cli-0.0.39.dist-info}/WHEEL +0 -0
  46. {pdd_cli-0.0.38.dist-info → pdd_cli-0.0.39.dist-info}/entry_points.txt +0 -0
  47. {pdd_cli-0.0.38.dist-info → pdd_cli-0.0.39.dist-info}/licenses/LICENSE +0 -0
  48. {pdd_cli-0.0.38.dist-info → pdd_cli-0.0.39.dist-info}/top_level.txt +0 -0
pdd/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.38"
1
+ __version__ = "0.0.39"
2
2
 
3
3
  # Strength parameter used for LLM extraction across the codebase
4
4
  # Used in postprocessing, XML tagging, code generation, and other extraction operations. The module should have a large context window and be affordable.
pdd/auto_deps_main.py CHANGED
@@ -4,6 +4,7 @@ from typing import Tuple, Optional
4
4
  import click
5
5
  from rich import print as rprint
6
6
 
7
+ from . import DEFAULT_STRENGTH, DEFAULT_TIME
7
8
  from .construct_paths import construct_paths
8
9
  from .insert_includes import insert_includes
9
10
 
@@ -60,8 +61,9 @@ def auto_deps_main(
60
61
  Path(csv_path).unlink()
61
62
 
62
63
  # Get strength and temperature from context
63
- strength = ctx.obj.get('strength', 0.9)
64
+ strength = ctx.obj.get('strength', DEFAULT_STRENGTH)
64
65
  temperature = ctx.obj.get('temperature', 0)
66
+ time_budget = ctx.obj.get('time', DEFAULT_TIME)
65
67
 
66
68
  # Call insert_includes with the prompt content and directory path
67
69
  modified_prompt, csv_output, total_cost, model_name = insert_includes(
@@ -70,6 +72,7 @@ def auto_deps_main(
70
72
  csv_filename=csv_path,
71
73
  strength=strength,
72
74
  temperature=temperature,
75
+ time=time_budget,
73
76
  verbose=not ctx.obj.get('quiet', False)
74
77
  )
75
78
 
pdd/auto_include.py CHANGED
@@ -8,6 +8,7 @@ from .llm_invoke import llm_invoke
8
8
  from .summarize_directory import summarize_directory
9
9
  import pandas as pd
10
10
  from io import StringIO
11
+ from . import DEFAULT_TIME, DEFAULT_STRENGTH
11
12
 
12
13
  console = Console()
13
14
 
@@ -18,8 +19,9 @@ def auto_include(
18
19
  input_prompt: str,
19
20
  directory_path: str,
20
21
  csv_file: Optional[str] = None,
21
- strength: float = 0.7,
22
+ strength: float = DEFAULT_STRENGTH,
22
23
  temperature: float = 0.0,
24
+ time: float = DEFAULT_TIME,
23
25
  verbose: bool = False
24
26
  ) -> Tuple[str, str, float, str]:
25
27
  """
@@ -31,6 +33,7 @@ def auto_include(
31
33
  csv_file (Optional[str]): Contents of existing CSV file
32
34
  strength (float): Strength of LLM model (0-1)
33
35
  temperature (float): Temperature of LLM model (0-1)
36
+ time (float): Time budget for LLM calls
34
37
  verbose (bool): Whether to print detailed information
35
38
 
36
39
  Returns:
@@ -68,6 +71,7 @@ def auto_include(
68
71
  directory_path=directory_path,
69
72
  strength=strength,
70
73
  temperature=temperature,
74
+ time=time,
71
75
  verbose=verbose,
72
76
  csv_file=csv_file
73
77
  )
@@ -100,6 +104,7 @@ def auto_include(
100
104
  },
101
105
  strength=strength,
102
106
  temperature=temperature,
107
+ time=time,
103
108
  verbose=verbose
104
109
  )
105
110
  total_cost += auto_include_response["cost"]
@@ -115,6 +120,7 @@ def auto_include(
115
120
  input_json={"llm_output": auto_include_response["result"]},
116
121
  strength=strength,
117
122
  temperature=temperature,
123
+ time=time,
118
124
  verbose=verbose,
119
125
  output_pydantic=AutoIncludeOutput
120
126
  )
@@ -160,6 +166,7 @@ context/image_utils.py,"Image processing utilities",2023-01-01T10:00:00"""
160
166
  csv_file=csv_file,
161
167
  strength=0.7,
162
168
  temperature=0.0,
169
+ time=DEFAULT_TIME,
163
170
  verbose=True
164
171
  )
165
172
 
pdd/bug_main.py CHANGED
@@ -5,6 +5,7 @@ import click
5
5
  from rich import print as rprint
6
6
  from pathlib import Path
7
7
 
8
+ from . import DEFAULT_STRENGTH, DEFAULT_TIME
8
9
  from .construct_paths import construct_paths
9
10
  from .bug_to_unit_test import bug_to_unit_test
10
11
 
@@ -64,8 +65,9 @@ def bug_main(
64
65
  desired_output_content = input_strings["desired_output"]
65
66
 
66
67
  # Generate unit test
67
- strength = ctx.obj.get('strength', 0.9)
68
+ strength = ctx.obj.get('strength', DEFAULT_STRENGTH)
68
69
  temperature = ctx.obj.get('temperature', 0)
70
+ time_budget = ctx.obj.get('time', DEFAULT_TIME)
69
71
  unit_test, total_cost, model_name = bug_to_unit_test(
70
72
  current_output_content,
71
73
  desired_output_content,
@@ -74,7 +76,8 @@ def bug_main(
74
76
  program_content,
75
77
  strength,
76
78
  temperature,
77
- language
79
+ language,
80
+ time_budget
78
81
  )
79
82
 
80
83
  # Save results if output path is provided
pdd/bug_to_unit_test.py CHANGED
@@ -2,7 +2,7 @@ from typing import Tuple, Optional
2
2
  from rich import print
3
3
  from rich.markdown import Markdown
4
4
  from rich.console import Console
5
- from . import EXTRACTION_STRENGTH, DEFAULT_STRENGTH
5
+ from . import EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME
6
6
  from .load_prompt_template import load_prompt_template
7
7
  from .llm_invoke import llm_invoke
8
8
  from .unfinished_prompt import unfinished_prompt
@@ -20,6 +20,7 @@ def bug_to_unit_test(
20
20
  program_used_to_run_code_under_test: str,
21
21
  strength: float = DEFAULT_STRENGTH,
22
22
  temperature: float = 0.0,
23
+ time: float = DEFAULT_TIME,
23
24
  language: str = "python"
24
25
  ) -> Tuple[str, float, str]:
25
26
  """
@@ -33,6 +34,7 @@ def bug_to_unit_test(
33
34
  program_used_to_run_code_under_test (str): Program used to run the code
34
35
  strength (float, optional): Strength of the LLM model. Must be between 0 and 1. Defaults to DEFAULT_STRENGTH.
35
36
  temperature (float, optional): Temperature of the LLM model. Defaults to 0.0.
37
+ time (float, optional): Time budget for LLM calls. Defaults to DEFAULT_TIME.
36
38
  language (str, optional): Programming language. Defaults to "python".
37
39
 
38
40
  Returns:
@@ -77,6 +79,7 @@ def bug_to_unit_test(
77
79
  input_json=input_json,
78
80
  strength=strength,
79
81
  temperature=temperature,
82
+ time=time,
80
83
  verbose=True
81
84
  )
82
85
 
@@ -93,6 +96,7 @@ def bug_to_unit_test(
93
96
  prompt_text=last_600_chars,
94
97
  strength=0.75,
95
98
  temperature=temperature,
99
+ time=time,
96
100
  verbose=False
97
101
  )
98
102
 
@@ -105,6 +109,7 @@ def bug_to_unit_test(
105
109
  llm_output=response['result'],
106
110
  strength=strength,
107
111
  temperature=temperature,
112
+ time=time,
108
113
  verbose=True
109
114
  )
110
115
  total_cost += continued_cost
@@ -124,6 +129,7 @@ def bug_to_unit_test(
124
129
  language,
125
130
  strength=EXTRACTION_STRENGTH,
126
131
  temperature=temperature,
132
+ time=time,
127
133
  verbose=True
128
134
  )
129
135
  total_cost += postprocess_cost
@@ -154,7 +160,8 @@ def add_numbers(a, b):
154
160
  desired_output=desired_output,
155
161
  prompt_used_to_generate_the_code=prompt,
156
162
  code_under_test=code,
157
- program_used_to_run_code_under_test=program
163
+ program_used_to_run_code_under_test=program,
164
+ time=DEFAULT_TIME
158
165
  )
159
166
 
160
167
  if unit_test:
pdd/change.py CHANGED
@@ -6,7 +6,7 @@ from pydantic import BaseModel, Field
6
6
  from .preprocess import preprocess
7
7
  from .load_prompt_template import load_prompt_template
8
8
  from .llm_invoke import llm_invoke
9
- from . import EXTRACTION_STRENGTH
9
+ from . import EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME
10
10
 
11
11
  console = Console()
12
12
 
@@ -17,8 +17,10 @@ def change(
17
17
  input_prompt: str,
18
18
  input_code: str,
19
19
  change_prompt: str,
20
- strength: float,
21
- temperature: float,
20
+ strength: float = DEFAULT_STRENGTH,
21
+ temperature: float = 0.0,
22
+ time: float = DEFAULT_TIME,
23
+ budget: float = 5.0, # Note: budget is in the spec but not used. Keeping for now.
22
24
  verbose: bool = False
23
25
  ) -> Tuple[str, float, str]:
24
26
  """
@@ -30,26 +32,28 @@ def change(
30
32
  change_prompt (str): Instructions for modifying the input prompt
31
33
  strength (float): The strength parameter for the LLM model (0-1)
32
34
  temperature (float): The temperature parameter for the LLM model
33
- verbose (bool): Whether to print detailed information
35
+ time (float): The time budget for LLM calls.
36
+ budget (float): The budget for the operation (currently unused directly by llm_invoke).
37
+ verbose (bool): Whether to print out detailed information.
34
38
 
35
39
  Returns:
36
40
  Tuple[str, float, str]: (modified prompt, total cost, model name)
37
41
  """
38
42
  try:
39
43
  # Step 1: Load prompt templates
40
- change_llm_prompt = load_prompt_template("change_LLM")
41
- extract_prompt = load_prompt_template("extract_prompt_change_LLM")
44
+ change_llm_prompt_template = load_prompt_template("change_LLM")
45
+ extract_prompt_template = load_prompt_template("extract_prompt_change_LLM")
42
46
 
43
- if not all([change_llm_prompt, extract_prompt]):
47
+ if not all([change_llm_prompt_template, extract_prompt_template]):
44
48
  raise ValueError("Failed to load prompt templates")
45
49
 
46
50
  # Step 2: Preprocess the change_LLM prompt
47
- processed_change_llm = preprocess(change_llm_prompt, recursive=False, double_curly_brackets=False)
48
- processed_change_prompt = preprocess(change_prompt, recursive=False, double_curly_brackets=False)
51
+ processed_change_llm_template = preprocess(change_llm_prompt_template, recursive=False, double_curly_brackets=False)
52
+ processed_change_prompt_content = preprocess(change_prompt, recursive=False, double_curly_brackets=False)
49
53
 
50
54
  # Input validation
51
- if not all([input_prompt, input_code, change_prompt]):
52
- raise ValueError("Missing required input parameters")
55
+ if not all([input_prompt, input_code, processed_change_prompt_content]):
56
+ raise ValueError("Missing required input parameters after preprocessing")
53
57
  if not (0 <= strength <= 1):
54
58
  raise ValueError("Strength must be between 0 and 1")
55
59
 
@@ -61,14 +65,15 @@ def change(
61
65
  console.print(Panel("Running change prompt through LLM...", style="blue"))
62
66
 
63
67
  change_response = llm_invoke(
64
- prompt=processed_change_llm,
68
+ prompt=processed_change_llm_template,
65
69
  input_json={
66
70
  "input_prompt": input_prompt,
67
71
  "input_code": input_code,
68
- "change_prompt": processed_change_prompt
72
+ "change_prompt": processed_change_prompt_content
69
73
  },
70
74
  strength=strength,
71
75
  temperature=temperature,
76
+ time=time,
72
77
  verbose=verbose
73
78
  )
74
79
 
@@ -85,10 +90,11 @@ def change(
85
90
  console.print(Panel("Extracting modified prompt...", style="blue"))
86
91
 
87
92
  extract_response = llm_invoke(
88
- prompt=extract_prompt,
93
+ prompt=extract_prompt_template,
89
94
  input_json={"llm_output": change_response["result"]},
90
- strength=EXTRACTION_STRENGTH, # Fixed strength for extraction
95
+ strength=EXTRACTION_STRENGTH,
91
96
  temperature=temperature,
97
+ time=time,
92
98
  verbose=verbose,
93
99
  output_pydantic=ExtractedPrompt
94
100
  )
@@ -110,23 +116,27 @@ def change(
110
116
  return modified_prompt, total_cost, final_model_name
111
117
 
112
118
  except Exception as e:
113
- console.print(f"[red]Error in change function: {str(e)}[/red]")
119
+ # Conditionally print error if verbose
120
+ if verbose:
121
+ console.print(f"[red]Error in change function: {str(e)}[/red]")
114
122
  raise
115
123
 
116
124
  def main():
117
125
  """Example usage of the change function"""
118
126
  try:
119
127
  # Example inputs
120
- input_prompt = "Write a function that adds two numbers"
121
- input_code = "def add(a, b):\n return a + b"
122
- change_prompt = "Make the function handle negative numbers explicitly"
128
+ input_prompt_content = "Write a function that adds two numbers"
129
+ input_code_content = "def add(a, b):\n return a + b"
130
+ change_prompt_content = "Make the function handle negative numbers explicitly"
123
131
 
124
132
  modified_prompt, cost, model = change(
125
- input_prompt=input_prompt,
126
- input_code=input_code,
127
- change_prompt=change_prompt,
133
+ input_prompt=input_prompt_content,
134
+ input_code=input_code_content,
135
+ change_prompt=change_prompt_content,
128
136
  strength=0.7,
129
137
  temperature=0.7,
138
+ time=DEFAULT_TIME,
139
+ budget=10.0,
130
140
  verbose=True
131
141
  )
132
142
 
pdd/change_main.py CHANGED
@@ -10,7 +10,7 @@ from .construct_paths import construct_paths
10
10
  from .change import change as change_func
11
11
  from .process_csv_change import process_csv_change
12
12
  from .get_extension import get_extension
13
- from . import DEFAULT_STRENGTH # Assuming DEFAULT_STRENGTH is defined in __init__.py
13
+ from . import DEFAULT_STRENGTH, DEFAULT_TIME # Added DEFAULT_TIME
14
14
 
15
15
  # Import Rich for pretty printing
16
16
  from rich import print as rprint
@@ -66,6 +66,7 @@ def change_main(
66
66
  quiet: bool = ctx.obj.get("quiet", False)
67
67
  strength: float = ctx.obj.get("strength", DEFAULT_STRENGTH)
68
68
  temperature: float = ctx.obj.get("temperature", 0.0)
69
+ time_budget: float = ctx.obj.get("time", DEFAULT_TIME) # Added time_budget
69
70
  # --- Get language and extension from context ---
70
71
  # These are crucial for knowing the target code file types, especially in CSV mode
71
72
  target_language: str = ctx.obj.get("language", "") # Get from context
@@ -215,6 +216,7 @@ def change_main(
215
216
  csv_file=change_prompt_file,
216
217
  strength=strength,
217
218
  temperature=temperature,
219
+ time=time_budget, # Pass time_budget
218
220
  code_directory=input_code, # Pass the directory path
219
221
  language=csv_target_language,
220
222
  extension=extension,
@@ -254,16 +256,18 @@ def change_main(
254
256
  return msg, 0.0, ""
255
257
 
256
258
  try:
257
- modified_prompt, total_cost, model_name = change_func(
258
- input_prompt=input_prompt_content,
259
- input_code=input_code_content,
260
- change_prompt=change_prompt_content,
261
- strength=strength,
262
- temperature=temperature,
263
- verbose=ctx.obj.get("verbose", False),
259
+ # Call the imported change function
260
+ result_message, total_cost, model_name = change_func(
261
+ change_prompt_content,
262
+ input_code_content,
263
+ input_prompt_content,
264
+ strength,
265
+ temperature,
266
+ time_budget, # Pass time_budget
267
+ budget=budget,
268
+ quiet=quiet
264
269
  )
265
- result_message = modified_prompt # Store the content for saving
266
- success = True # Assume success if no exception
270
+ success = True # Assume success if no exception
267
271
  logger.info("Single prompt change successful.")
268
272
  except Exception as e:
269
273
  msg = f"Error during prompt modification: {e}"
pdd/cli.py CHANGED
@@ -11,7 +11,7 @@ from rich.theme import Theme
11
11
  from rich.markup import MarkupError, escape
12
12
 
13
13
  # --- Relative Imports for Internal Modules ---
14
- from . import DEFAULT_STRENGTH, __version__
14
+ from . import DEFAULT_STRENGTH, __version__, DEFAULT_TIME
15
15
  from .auto_deps_main import auto_deps_main
16
16
  from .auto_update import auto_update
17
17
  from .bug_main import bug_main
@@ -89,6 +89,13 @@ def handle_error(e: Exception, command_name: str, quiet: bool):
89
89
  show_default=True,
90
90
  help="Set the temperature of the AI model.",
91
91
  )
92
+ @click.option(
93
+ "--time",
94
+ type=click.FloatRange(0.0, 1.0),
95
+ default=None,
96
+ show_default=True,
97
+ help="Controls reasoning allocation for LLMs (0.0-1.0). Uses DEFAULT_TIME if None.",
98
+ )
92
99
  @click.option(
93
100
  "--verbose",
94
101
  is_flag=True,
@@ -131,6 +138,7 @@ def cli(
131
138
  output_cost: Optional[str],
132
139
  review_examples: bool,
133
140
  local: bool,
141
+ time: Optional[float], # Type hint is Optional[float]
134
142
  ):
135
143
  """
136
144
  Main entry point for the PDD CLI. Handles global options and initializes context.
@@ -148,6 +156,8 @@ def cli(
148
156
  ctx.obj["output_cost"] = output_cost
149
157
  ctx.obj["review_examples"] = review_examples
150
158
  ctx.obj["local"] = local
159
+ # Use DEFAULT_TIME if time is not provided
160
+ ctx.obj["time"] = time if time is not None else DEFAULT_TIME
151
161
 
152
162
  # Suppress verbose if quiet is enabled
153
163
  if quiet:
pdd/cmd_test_main.py CHANGED
@@ -49,6 +49,7 @@ def cmd_test_main(
49
49
  verbose = ctx.obj["verbose"]
50
50
  strength = ctx.obj["strength"]
51
51
  temperature = ctx.obj["temperature"]
52
+ time = ctx.obj.get("time")
52
53
 
53
54
  if verbose:
54
55
  print(f"[bold blue]Prompt file:[/bold blue] {prompt_file}")
@@ -100,6 +101,7 @@ def cmd_test_main(
100
101
  strength,
101
102
  temperature,
102
103
  language,
104
+ time=time,
103
105
  )
104
106
  except Exception as e:
105
107
  print(f"[bold red]Error generating tests: {e}[/bold red]")
@@ -121,6 +123,7 @@ def cmd_test_main(
121
123
  language=language,
122
124
  strength=strength,
123
125
  temperature=temperature,
126
+ time=time,
124
127
  verbose=verbose,
125
128
  )
126
129
  except Exception as e:
pdd/code_generator.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Tuple
1
+ from typing import Tuple, Optional
2
2
  from rich.console import Console
3
3
  from . import EXTRACTION_STRENGTH
4
4
  from .preprocess import preprocess
@@ -14,6 +14,7 @@ def code_generator(
14
14
  language: str,
15
15
  strength: float,
16
16
  temperature: float = 0.0,
17
+ time: Optional[float] = None,
17
18
  verbose: bool = False,
18
19
  preprocess_prompt: bool = True,
19
20
  ) -> Tuple[str, float, str]:
@@ -25,6 +26,7 @@ def code_generator(
25
26
  language (str): The target programming language
26
27
  strength (float): The strength of the LLM model (0 to 1)
27
28
  temperature (float, optional): The temperature for the LLM model. Defaults to 0.0
29
+ time (Optional[float], optional): The time for the LLM model. Defaults to None
28
30
  verbose (bool, optional): Whether to print detailed information. Defaults to False
29
31
 
30
32
  Returns:
@@ -65,6 +67,7 @@ def code_generator(
65
67
  input_json={},
66
68
  strength=strength,
67
69
  temperature=temperature,
70
+ time=time,
68
71
  verbose=verbose
69
72
  )
70
73
  initial_output = response['result']
@@ -79,6 +82,7 @@ def code_generator(
79
82
  prompt_text=last_chunk,
80
83
  strength=0.5,
81
84
  temperature=0.0,
85
+ time=time,
82
86
  verbose=verbose
83
87
  )
84
88
  total_cost += check_cost
@@ -92,6 +96,7 @@ def code_generator(
92
96
  llm_output=initial_output,
93
97
  strength=strength,
94
98
  temperature=temperature,
99
+ time=time,
95
100
  verbose=verbose
96
101
  )
97
102
  total_cost += continue_cost
@@ -107,6 +112,7 @@ def code_generator(
107
112
  language=language,
108
113
  strength=EXTRACTION_STRENGTH,
109
114
  temperature=0.0,
115
+ time=time,
110
116
  verbose=verbose
111
117
  )
112
118
  total_cost += postprocess_cost
@@ -410,11 +410,17 @@ def code_generator_main(
410
410
  if current_execution_is_local:
411
411
  if verbose: console.print("Executing code generator locally...")
412
412
  generated_code_content, total_cost, model_name = local_code_generator_func(
413
- prompt=prompt_content, language=language, strength=strength,
414
- temperature=temperature, verbose=verbose
413
+ prompt=prompt_content,
414
+ language=language,
415
+ strength=strength,
416
+ temperature=temperature,
417
+ time=time_budget,
418
+ verbose=verbose,
419
+ preprocess_prompt=True
415
420
  )
421
+ was_incremental_operation = False
416
422
  if verbose:
417
- console.print(Panel(f"Local generation successful. Model: {model_name}, Cost: ${total_cost:.6f}", title="[green]Local Success[/green]", expand=False))
423
+ console.print(Panel(f"Full generation successful. Model: {model_name}, Cost: ${total_cost:.6f}", title="[green]Local Success[/green]", expand=False))
418
424
 
419
425
  if generated_code_content is not None:
420
426
  if output_path:
@@ -4,7 +4,7 @@ from rich import print as rprint
4
4
  from rich.markdown import Markdown
5
5
  from .load_prompt_template import load_prompt_template
6
6
  from .llm_invoke import llm_invoke
7
- from . import EXTRACTION_STRENGTH
7
+ from . import EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME
8
8
 
9
9
  class ConflictChange(BaseModel):
10
10
  prompt_name: str = Field(description="Name of the prompt that needs to be changed")
@@ -16,8 +16,9 @@ class ConflictResponse(BaseModel):
16
16
  def conflicts_in_prompts(
17
17
  prompt1: str,
18
18
  prompt2: str,
19
- strength: float = 0.5,
19
+ strength: float = DEFAULT_STRENGTH,
20
20
  temperature: float = 0,
21
+ time: float = DEFAULT_TIME,
21
22
  verbose: bool = False
22
23
  ) -> Tuple[List[dict], float, str]:
23
24
  """
@@ -28,6 +29,7 @@ def conflicts_in_prompts(
28
29
  prompt2 (str): Second prompt to compare
29
30
  strength (float): Model strength (0-1)
30
31
  temperature (float): Model temperature (0-1)
32
+ time (float): Time budget for LLM calls.
31
33
  verbose (bool): Whether to print detailed information
32
34
 
33
35
  Returns:
@@ -66,6 +68,7 @@ def conflicts_in_prompts(
66
68
  input_json=input_json,
67
69
  strength=strength,
68
70
  temperature=temperature,
71
+ time=time,
69
72
  verbose=verbose
70
73
  )
71
74
 
@@ -88,6 +91,7 @@ def conflicts_in_prompts(
88
91
  input_json=extract_input,
89
92
  strength=EXTRACTION_STRENGTH,
90
93
  temperature=temperature,
94
+ time=time,
91
95
  output_pydantic=ConflictResponse,
92
96
  verbose=verbose
93
97
  )
@@ -125,6 +129,7 @@ def main():
125
129
  prompt2=prompt2,
126
130
  strength=0.7,
127
131
  temperature=0,
132
+ time=DEFAULT_TIME,
128
133
  verbose=True
129
134
  )
130
135
 
pdd/conflicts_main.py CHANGED
@@ -6,6 +6,7 @@ from rich import print as rprint
6
6
 
7
7
  from .construct_paths import construct_paths
8
8
  from .conflicts_in_prompts import conflicts_in_prompts
9
+ from . import DEFAULT_TIME, DEFAULT_STRENGTH
9
10
 
10
11
  def conflicts_main(ctx: click.Context, prompt1: str, prompt2: str, output: Optional[str], verbose: bool = False) -> Tuple[List[Dict], float, str]:
11
12
  """
@@ -40,13 +41,16 @@ def conflicts_main(ctx: click.Context, prompt1: str, prompt2: str, output: Optio
40
41
  prompt2_content = input_strings["prompt2"]
41
42
 
42
43
  # Analyze conflicts
43
- strength = ctx.obj.get('strength', 0.9)
44
+ strength = ctx.obj.get('strength', DEFAULT_STRENGTH)
44
45
  temperature = ctx.obj.get('temperature', 0)
46
+ time_budget = ctx.obj.get('time', DEFAULT_TIME)
45
47
  conflicts, total_cost, model_name = conflicts_in_prompts(
46
48
  prompt1_content,
47
49
  prompt2_content,
48
50
  strength,
49
- temperature
51
+ temperature,
52
+ time_budget,
53
+ verbose
50
54
  )
51
55
 
52
56
  # Replace prompt1 and prompt2 with actual file paths
pdd/context_generator.py CHANGED
@@ -5,9 +5,18 @@ from .llm_invoke import llm_invoke
5
5
  from .unfinished_prompt import unfinished_prompt
6
6
  from .continue_generation import continue_generation
7
7
  from .postprocess import postprocess
8
- from . import EXTRACTION_STRENGTH
9
-
10
- def context_generator(code_module: str, prompt: str, language: str = "python", strength: float = 0.5, temperature: float = 0, verbose: bool = False) -> tuple:
8
+ from . import EXTRACTION_STRENGTH, DEFAULT_TIME
9
+ from typing import Optional
10
+
11
+ def context_generator(
12
+ code_module: str,
13
+ prompt: str,
14
+ language: str = "python",
15
+ strength: float = 0.5,
16
+ temperature: float = 0,
17
+ time: Optional[float] = DEFAULT_TIME,
18
+ verbose: bool = False,
19
+ ) -> tuple:
11
20
  """
12
21
  Generates a concise example on how to use a given code module properly.
13
22
 
@@ -17,6 +26,7 @@ def context_generator(code_module: str, prompt: str, language: str = "python", s
17
26
  language (str): The language of the code module. Default is "python".
18
27
  strength (float): The strength of the LLM model to use. Default is 0.5. Range is between 0 and 1.
19
28
  temperature (float): The temperature of the LLM model to use. Default is 0. Range is between 0 and 1.
29
+ time (Optional[float], optional): Time allocation for the LLM. Defaults to DEFAULT_TIME.
20
30
  verbose (bool): Whether to print out the details of the function. Default is False.
21
31
 
22
32
  Returns:
@@ -45,6 +55,9 @@ def context_generator(code_module: str, prompt: str, language: str = "python", s
45
55
  return None, 0.0, None
46
56
 
47
57
  try:
58
+ if verbose:
59
+ print(f"[bold blue]Generating example for language: {language}[/bold blue]")
60
+
48
61
  # Step 1: Load and preprocess the 'example_generator_LLM' prompt template
49
62
  prompt_template = load_prompt_template("example_generator_LLM")
50
63
  if not prompt_template:
@@ -70,6 +83,7 @@ def context_generator(code_module: str, prompt: str, language: str = "python", s
70
83
  },
71
84
  strength=strength,
72
85
  temperature=temperature,
86
+ time=time,
73
87
  verbose=verbose
74
88
  )
75
89
 
@@ -80,6 +94,7 @@ def context_generator(code_module: str, prompt: str, language: str = "python", s
80
94
  prompt_text=last_600_chars,
81
95
  strength=0.5,
82
96
  temperature=temperature,
97
+ time=time,
83
98
  verbose=verbose
84
99
  )
85
100
  except Exception as e:
@@ -96,6 +111,7 @@ def context_generator(code_module: str, prompt: str, language: str = "python", s
96
111
  llm_output=llm_response['result'],
97
112
  strength=strength,
98
113
  temperature=temperature,
114
+ time=time,
99
115
  verbose=verbose
100
116
  )
101
117
  total_cost = llm_response['cost'] + unfinished_cost + continue_cost
@@ -113,6 +129,7 @@ def context_generator(code_module: str, prompt: str, language: str = "python", s
113
129
  language=language,
114
130
  strength=EXTRACTION_STRENGTH,
115
131
  temperature=temperature,
132
+ time=time,
116
133
  verbose=verbose
117
134
  )
118
135
  total_cost += postprocess_cost
@@ -40,12 +40,14 @@ def context_generator_main(ctx: click.Context, prompt_file: str, code_file: str,
40
40
  # Generate example code
41
41
  strength = ctx.obj.get('strength', 0.5)
42
42
  temperature = ctx.obj.get('temperature', 0)
43
+ time = ctx.obj.get('time')
43
44
  example_code, total_cost, model_name = context_generator(
44
45
  language=language,
45
46
  code_module=code_content,
46
47
  prompt=prompt_content,
47
48
  strength=strength,
48
49
  temperature=temperature,
50
+ time=time,
49
51
  verbose=ctx.obj.get('verbose', False)
50
52
  )
51
53