refac: on_valves_update -> on_valves_updated

This commit is contained in:
Timothy J. Baek 2024-05-29 23:32:28 -07:00
parent f677bb9d0c
commit c29231ea37
8 changed files with 23 additions and 15 deletions

View File

@ -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(

View File

@ -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 []

View File

@ -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()

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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