Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /promptdriven_pdd /context /split_example.py
| import os | |
| from rich.console import Console | |
| from pdd.split import split | |
| # Set up the Rich console for pretty printing | |
| console = Console() | |
| def main() -> None: | |
| """ | |
| Main function to demonstrate the usage of the split function from the pdd.split module. | |
| Sets up environment variables, prepares input parameters, calls the split function, and prints the results. | |
| """ | |
| try: | |
| # Set the PDD_PATH environment variable if not already set | |
| os.environ['PDD_PATH'] = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| # Input parameters | |
| input_prompt: str = "Create a Python function to calculate the factorial of a number." | |
| input_code: str = """ | |
| def factorial(n): | |
| if n == 0 or n == 1: | |
| return 1 | |
| else: | |
| return n * factorial(n-1) | |
| """ | |
| example_code: str = """ | |
| # Example usage | |
| result = factorial(5) | |
| print(f"Factorial of 5 is: {result}") | |
| """ | |
| strength: float = 0.5 # Float value between 0 and 1 | |
| temperature: float = 0.0 # Float value between 0 and 1 | |
| # Call the split function with the new standardized return order | |
| # Returns (result_tuple, total_cost, model_name) | |
| result_tuple, total_cost, model_name = split( | |
| input_prompt=input_prompt, | |
| input_code=input_code, | |
| example_code=example_code, | |
| strength=strength, | |
| temperature=temperature, | |
| verbose=True | |
| ) | |
| # Unpack the result tuple | |
| sub_prompt, modified_prompt = result_tuple | |
| # Print the results | |
| console.print(f"[bold]Sub Prompt:[/bold]\n{sub_prompt}") | |
| console.print(f"[bold]Modified Prompt:[/bold]\n{modified_prompt}") | |
| console.print(f"[bold]Model used:[/bold] {model_name}") | |
| console.print(f"[bold]Total Cost:[/bold] ${total_cost:.6f}") | |
| except Exception as e: | |
| console.print(f"[bold red]An error occurred:[/bold red] {e}") | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 1.99 kB
- Xet hash:
- 839e7063bc265d4bd137cc19dac493eaaa0df114b0ab4242eee5a64c9dab3b67
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.