mirror of
https://github.com/open-webui/pipelines
synced 2025-05-12 16:40:45 +00:00
refac: on_valves_update -> on_valves_updated
This commit is contained in:
parent
f677bb9d0c
commit
c29231ea37
4
main.py
4
main.py
@ -451,8 +451,8 @@ async def update_valves(pipeline_id: str, form_data: dict):
|
|||||||
valves = ValvesModel(**form_data)
|
valves = ValvesModel(**form_data)
|
||||||
pipeline.valves = valves
|
pipeline.valves = valves
|
||||||
|
|
||||||
if hasattr(pipeline, "on_valves_update"):
|
if hasattr(pipeline, "on_valves_updated"):
|
||||||
await pipeline.on_valves_update()
|
await pipeline.on_valves_updated()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
@ -47,7 +47,7 @@ class Pipeline:
|
|||||||
print(f"on_shutdown:{__name__}")
|
print(f"on_shutdown:{__name__}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_valves_update(self):
|
async def on_valves_updated(self):
|
||||||
# This function is called when the valves are updated.
|
# This function is called when the valves are updated.
|
||||||
self.client = Anthropic(api_key=self.valves.ANTHROPIC_API_KEY)
|
self.client = Anthropic(api_key=self.valves.ANTHROPIC_API_KEY)
|
||||||
pass
|
pass
|
||||||
@ -71,8 +71,12 @@ class Pipeline:
|
|||||||
def stream_response(
|
def stream_response(
|
||||||
self, model_id: str, messages: List[dict], body: dict
|
self, model_id: str, messages: List[dict], body: dict
|
||||||
) -> Generator:
|
) -> Generator:
|
||||||
max_tokens = body.get("max_tokens") if body.get("max_tokens") is not None else 4096
|
max_tokens = (
|
||||||
temperature = body.get("temperature") if body.get("temperature") is not None else 0.8
|
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_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
|
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 []
|
stop_sequences = body.get("stop") if body.get("stop") is not None else []
|
||||||
@ -95,8 +99,12 @@ class Pipeline:
|
|||||||
yield chunk.delta.text
|
yield chunk.delta.text
|
||||||
|
|
||||||
def get_completion(self, model_id: str, messages: List[dict], body: dict) -> str:
|
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
|
max_tokens = (
|
||||||
temperature = body.get("temperature") if body.get("temperature") is not None else 0.8
|
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_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
|
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 []
|
stop_sequences = body.get("stop") if body.get("stop") is not None else []
|
||||||
|
@ -39,7 +39,7 @@ class Pipeline:
|
|||||||
print(f"on_shutdown:{__name__}")
|
print(f"on_shutdown:{__name__}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_valves_update(self):
|
async def on_valves_updated(self):
|
||||||
# This function is called when the valves are updated.
|
# This function is called when the valves are updated.
|
||||||
|
|
||||||
self.pipelines = self.get_cohere_models()
|
self.pipelines = self.get_cohere_models()
|
||||||
|
@ -52,7 +52,7 @@ class Pipeline:
|
|||||||
print(f"on_shutdown:{__name__}")
|
print(f"on_shutdown:{__name__}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_valves_update(self):
|
async def on_valves_updated(self):
|
||||||
# This function is called when the valves are updated.
|
# This function is called when the valves are updated.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class Pipeline:
|
|||||||
self.langfuse.flush()
|
self.langfuse.flush()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_valves_update(self):
|
async def on_valves_updated(self):
|
||||||
# This function is called when the valves are updated.
|
# This function is called when the valves are updated.
|
||||||
|
|
||||||
self.set_langfuse()
|
self.set_langfuse()
|
||||||
|
@ -38,7 +38,7 @@ class Pipeline:
|
|||||||
print(f"on_shutdown:{__name__}")
|
print(f"on_shutdown:{__name__}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_valves_update(self):
|
async def on_valves_updated(self):
|
||||||
# This function is called when the valves are updated.
|
# This function is called when the valves are updated.
|
||||||
|
|
||||||
self.pipelines = self.get_litellm_models()
|
self.pipelines = self.get_litellm_models()
|
||||||
|
@ -72,10 +72,10 @@ class Pipeline:
|
|||||||
await self.shutdown_litellm_background()
|
await self.shutdown_litellm_background()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_valves_update(self):
|
async def on_valves_updated(self):
|
||||||
# This function is called when the valves are updated.
|
# 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:
|
with open(self.valves.LITELLM_CONFIG_DIR, "r") as file:
|
||||||
litellm_config = yaml.safe_load(file)
|
litellm_config = yaml.safe_load(file)
|
||||||
|
@ -38,9 +38,9 @@ class Pipeline:
|
|||||||
print(f"on_shutdown:{__name__}")
|
print(f"on_shutdown:{__name__}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def on_valves_update(self):
|
async def on_valves_updated(self):
|
||||||
# This function is called when the valves are updated.
|
# 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()
|
self.pipelines = self.get_ollama_models()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user