Buckets:
| """ | |
| Miscellaneous commands (preprocess). | |
| """ | |
| import click | |
| from typing import Optional, Tuple | |
| from ..preprocess_main import preprocess_main | |
| from ..core.errors import handle_error | |
| # No @track_cost as preprocessing is local, but return dummy tuple for callback | |
| def preprocess( | |
| ctx: click.Context, | |
| prompt_file: str, | |
| output: Optional[str], | |
| xml: bool, | |
| recursive: bool, | |
| double: bool, | |
| exclude: Optional[Tuple[str, ...]], | |
| pdd_tags: bool, | |
| snapshot: bool, | |
| ) -> Optional[Tuple[str, float, str]]: | |
| """Preprocess a prompt file to prepare it for LLM use.""" | |
| try: | |
| # Since preprocess is a local operation, we don't track cost | |
| # But we need to return a tuple in the expected format for result callback | |
| result = preprocess_main( | |
| ctx=ctx, | |
| prompt_file=prompt_file, | |
| output=output, | |
| xml=xml, | |
| recursive=recursive, | |
| double=double, | |
| exclude=list(exclude) if exclude else [], | |
| pdd_tags=pdd_tags, | |
| snapshot=snapshot, | |
| ) | |
| # Handle the result from preprocess_main | |
| if result is None: | |
| # If preprocess_main returns None, still return a dummy tuple for the callback | |
| return "", 0.0, "local" | |
| else: | |
| # Unpack the return value from preprocess_main | |
| processed_prompt, total_cost, model_name = result | |
| return processed_prompt, total_cost, model_name | |
| except click.Abort: | |
| raise | |
| except Exception as exception: | |
| handle_error(exception, "preprocess", ctx.obj.get("quiet", False)) | |
| return None | |
Xet Storage Details
- Size:
- 2.9 kB
- Xet hash:
- 6de2aced32ec18fadc5c035318559acf12468a1fdcd47925acca4ab1e8e612ac
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.