Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /BerriAI_litellm /litellm /integrations /custom_prompt_management.py
| from litellm.integrations.custom_logger import CustomLogger | |
| from litellm.integrations.prompt_management_base import ( | |
| PromptManagementBase, | |
| PromptManagementClient, | |
| ) | |
| from litellm.types.llms.openai import AllMessageValues | |
| from litellm.types.prompts.init_prompts import PromptSpec | |
| from litellm.types.utils import StandardCallbackDynamicParams | |
| class CustomPromptManagement(CustomLogger, PromptManagementBase): | |
| def __init__( | |
| self, | |
| ignore_prompt_manager_model: bool | None = False, | |
| ignore_prompt_manager_optional_params: bool | None = False, | |
| **kwargs, | |
| ): | |
| self.ignore_prompt_manager_model = ignore_prompt_manager_model | |
| self.ignore_prompt_manager_optional_params = ignore_prompt_manager_optional_params | |
| def get_chat_completion_prompt( | |
| self, | |
| model: str, | |
| messages: list[AllMessageValues], | |
| non_default_params: dict, | |
| prompt_id: str | None, | |
| prompt_variables: dict | None, | |
| dynamic_callback_params: StandardCallbackDynamicParams, | |
| prompt_spec: PromptSpec | None = None, | |
| prompt_label: str | None = None, | |
| prompt_version: int | None = None, | |
| ignore_prompt_manager_model: bool | None = False, | |
| ignore_prompt_manager_optional_params: bool | None = False, | |
| ) -> tuple[str, list[AllMessageValues], dict]: | |
| """ | |
| Returns: | |
| - model: str - the model to use (can be pulled from prompt management tool) | |
| - messages: List[AllMessageValues] - the messages to use (can be pulled from prompt management tool) | |
| - non_default_params: dict - update with any optional params (e.g. temperature, max_tokens, etc.) to use (can be pulled from prompt management tool) | |
| """ | |
| return model, messages, non_default_params | |
| def integration_name(self) -> str: | |
| return "custom-prompt-management" | |
| def should_run_prompt_management( | |
| self, | |
| prompt_id: str | None, | |
| prompt_spec: PromptSpec | None, | |
| dynamic_callback_params: StandardCallbackDynamicParams, | |
| ) -> bool: | |
| return True | |
| def _compile_prompt_helper( | |
| self, | |
| prompt_id: str | None, | |
| prompt_spec: PromptSpec | None, | |
| prompt_variables: dict | None, | |
| dynamic_callback_params: StandardCallbackDynamicParams, | |
| prompt_label: str | None = None, | |
| prompt_version: int | None = None, | |
| ) -> PromptManagementClient: | |
| raise NotImplementedError("Custom prompt management does not support compile prompt helper") | |
| async def async_compile_prompt_helper( | |
| self, | |
| prompt_id: str | None, | |
| prompt_variables: dict | None, | |
| dynamic_callback_params: StandardCallbackDynamicParams, | |
| prompt_spec: PromptSpec | None = None, | |
| prompt_label: str | None = None, | |
| prompt_version: int | None = None, | |
| ) -> PromptManagementClient: | |
| raise NotImplementedError("Custom prompt management does not support async compile prompt helper") | |
Xet Storage Details
- Size:
- 3.01 kB
- Xet hash:
- 4e8773d177dfffdd4e288f2124e4294185082d8a1294c34e575e21edcf612d1d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.