From c29231ea37d61a87cab02ab741be755928577897 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 29 May 2024 23:32:28 -0700 Subject: [PATCH] refac: on_valves_update -> on_valves_updated --- main.py | 4 ++-- .../examples/anthropic_manifold_pipeline.py | 18 +++++++++++++----- pipelines/examples/cohere_manifold_pipeline.py | 2 +- pipelines/examples/detoxify_filter_pipeline.py | 2 +- pipelines/examples/langfuse_filter_pipeline.py | 2 +- .../examples/litellm_manifold_pipeline.py | 2 +- .../litellm_subprocess_manifold_pipeline.py | 4 ++-- pipelines/examples/ollama_manifold_pipeline.py | 4 ++-- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/main.py b/main.py index 594652e..9f953d1 100644 --- a/main.py +++ b/main.py @@ -451,8 +451,8 @@ async def update_valves(pipeline_id: str, form_data: dict): valves = ValvesModel(**form_data) pipeline.valves = valves - if hasattr(pipeline, "on_valves_update"): - await pipeline.on_valves_update() + if hasattr(pipeline, "on_valves_updated"): + await pipeline.on_valves_updated() except Exception as e: print(e) raise HTTPException( diff --git a/pipelines/examples/anthropic_manifold_pipeline.py b/pipelines/examples/anthropic_manifold_pipeline.py index 6b3d05d..0f794f7 100644 --- a/pipelines/examples/anthropic_manifold_pipeline.py +++ b/pipelines/examples/anthropic_manifold_pipeline.py @@ -47,7 +47,7 @@ class Pipeline: print(f"on_shutdown:{__name__}") pass - async def on_valves_update(self): + async def on_valves_updated(self): # This function is called when the valves are updated. self.client = Anthropic(api_key=self.valves.ANTHROPIC_API_KEY) pass @@ -71,8 +71,12 @@ class Pipeline: def stream_response( self, model_id: str, messages: List[dict], body: dict ) -> Generator: - max_tokens = body.get("max_tokens") if body.get("max_tokens") is not None else 4096 - temperature = body.get("temperature") if body.get("temperature") is not None else 0.8 + max_tokens = ( + body.get("max_tokens") if body.get("max_tokens") is not None else 4096 + ) + temperature = ( + body.get("temperature") if body.get("temperature") is not None else 0.8 + ) top_k = body.get("top_k") if body.get("top_k") is not None else 40 top_p = body.get("top_p") if body.get("top_p") is not None else 0.9 stop_sequences = body.get("stop") if body.get("stop") is not None else [] @@ -95,8 +99,12 @@ class Pipeline: yield chunk.delta.text def get_completion(self, model_id: str, messages: List[dict], body: dict) -> str: - max_tokens = body.get("max_tokens") if body.get("max_tokens") is not None else 4096 - temperature = body.get("temperature") if body.get("temperature") is not None else 0.8 + max_tokens = ( + body.get("max_tokens") if body.get("max_tokens") is not None else 4096 + ) + temperature = ( + body.get("temperature") if body.get("temperature") is not None else 0.8 + ) top_k = body.get("top_k") if body.get("top_k") is not None else 40 top_p = body.get("top_p") if body.get("top_p") is not None else 0.9 stop_sequences = body.get("stop") if body.get("stop") is not None else [] diff --git a/pipelines/examples/cohere_manifold_pipeline.py b/pipelines/examples/cohere_manifold_pipeline.py index 1986b3c..01c1a8b 100644 --- a/pipelines/examples/cohere_manifold_pipeline.py +++ b/pipelines/examples/cohere_manifold_pipeline.py @@ -39,7 +39,7 @@ class Pipeline: print(f"on_shutdown:{__name__}") pass - async def on_valves_update(self): + async def on_valves_updated(self): # This function is called when the valves are updated. self.pipelines = self.get_cohere_models() diff --git a/pipelines/examples/detoxify_filter_pipeline.py b/pipelines/examples/detoxify_filter_pipeline.py index d3dcb80..36d83d0 100644 --- a/pipelines/examples/detoxify_filter_pipeline.py +++ b/pipelines/examples/detoxify_filter_pipeline.py @@ -52,7 +52,7 @@ class Pipeline: print(f"on_shutdown:{__name__}") pass - async def on_valves_update(self): + async def on_valves_updated(self): # This function is called when the valves are updated. pass diff --git a/pipelines/examples/langfuse_filter_pipeline.py b/pipelines/examples/langfuse_filter_pipeline.py index 87bbf8e..5205b13 100644 --- a/pipelines/examples/langfuse_filter_pipeline.py +++ b/pipelines/examples/langfuse_filter_pipeline.py @@ -62,7 +62,7 @@ class Pipeline: self.langfuse.flush() pass - async def on_valves_update(self): + async def on_valves_updated(self): # This function is called when the valves are updated. self.set_langfuse() diff --git a/pipelines/examples/litellm_manifold_pipeline.py b/pipelines/examples/litellm_manifold_pipeline.py index df27df8..e43f647 100644 --- a/pipelines/examples/litellm_manifold_pipeline.py +++ b/pipelines/examples/litellm_manifold_pipeline.py @@ -38,7 +38,7 @@ class Pipeline: print(f"on_shutdown:{__name__}") pass - async def on_valves_update(self): + async def on_valves_updated(self): # This function is called when the valves are updated. self.pipelines = self.get_litellm_models() diff --git a/pipelines/examples/litellm_subprocess_manifold_pipeline.py b/pipelines/examples/litellm_subprocess_manifold_pipeline.py index 97940e9..62e69b7 100644 --- a/pipelines/examples/litellm_subprocess_manifold_pipeline.py +++ b/pipelines/examples/litellm_subprocess_manifold_pipeline.py @@ -72,10 +72,10 @@ class Pipeline: await self.shutdown_litellm_background() pass - async def on_valves_update(self): + async def on_valves_updated(self): # This function is called when the valves are updated. - print(f"on_valves_update:{__name__}") + print(f"on_valves_updated:{__name__}") with open(self.valves.LITELLM_CONFIG_DIR, "r") as file: litellm_config = yaml.safe_load(file) diff --git a/pipelines/examples/ollama_manifold_pipeline.py b/pipelines/examples/ollama_manifold_pipeline.py index 3979812..0eb4b13 100644 --- a/pipelines/examples/ollama_manifold_pipeline.py +++ b/pipelines/examples/ollama_manifold_pipeline.py @@ -38,9 +38,9 @@ class Pipeline: print(f"on_shutdown:{__name__}") pass - async def on_valves_update(self): + async def on_valves_updated(self): # This function is called when the valves are updated. - print(f"on_valves_update:{__name__}") + print(f"on_valves_updated:{__name__}") self.pipelines = self.get_ollama_models() pass