From 97d4f92a55399256e5bb83712141a15dc2098fa4 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Mon, 22 Jul 2024 23:14:01 -0600 Subject: [PATCH] Added Valves doc, minor updates to others --- docs/pipelines/filters.md | 4 ++-- docs/pipelines/tutorials.md | 2 +- docs/pipelines/valves.md | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 docs/pipelines/valves.md diff --git a/docs/pipelines/filters.md b/docs/pipelines/filters.md index 7d09e5e..19838fc 100644 --- a/docs/pipelines/filters.md +++ b/docs/pipelines/filters.md @@ -1,9 +1,9 @@ --- sidebar_position: 1 -title: "Filter Pipelines" +title: "Filters" --- -# Filter Pipelines +# Filters Filters are used to perform actions against incoming user messages and outgoing assistant (LLM) messages. Potential actions that can be taken in a filter include sending messages to monitoring platforms (such as Langfuse or DataDog), modifying message contents, blocking toxic messages, translating messages to another language, or rate limiting messages from certain users. A list of examples is maintained in the [Pipelines repo](https://github.com/open-webui/pipelines/tree/main/examples/filters). The general workflow can be seen in the image below.

diff --git a/docs/pipelines/tutorials.md b/docs/pipelines/tutorials.md index 616668b..29cf3f6 100644 --- a/docs/pipelines/tutorials.md +++ b/docs/pipelines/tutorials.md @@ -1,5 +1,5 @@ --- -sidebar_position: 3 +sidebar_position: 4 title: "Tutorials" --- diff --git a/docs/pipelines/valves.md b/docs/pipelines/valves.md new file mode 100644 index 0000000..f591b9e --- /dev/null +++ b/docs/pipelines/valves.md @@ -0,0 +1,29 @@ +--- +sidebar_position: 3 +title: "Valves" +--- + +# Valves +Valves are input variables that are set per pipeline. Valves are set as a subclass of the `Pipeline` class, and initialized as part of the `__init__` method of the `Pipeline` class. + +When adding valves to your pipeline, include a way to ensure that valves can be reconfigured by admins in the web UI. There are a few options for this: +- Use `os.getenv()` to set an environment variable to use for the pipeline, and a default value to use if the environment variable isn't set. An example can be seen below: +``` +self.valves = self.Valves( + **{ + "LLAMAINDEX_OLLAMA_BASE_URL": os.getenv("LLAMAINDEX_OLLAMA_BASE_URL", "http://localhost:11434"), + "LLAMAINDEX_MODEL_NAME": os.getenv("LLAMAINDEX_MODEL_NAME", "llama3"), + "LLAMAINDEX_EMBEDDING_MODEL_NAME": os.getenv("LLAMAINDEX_EMBEDDING_MODEL_NAME", "nomic-embed-text"), + } +) +``` +- Set the valve to the `Optional` type, which will allow the pipeline to load even if no value is set for the valve. +``` +class Pipeline: + class Valves(BaseModel): + target_user_roles: List[str] = ["user"] + max_turns: Optional[int] = None +``` + +If you don't leave a way for valves to be updated in the web UI, you'll see the following error in the Pipelines server log after trying to add a pipeline to the web UI: +`WARNING:root:No Pipeline class found in ` \ No newline at end of file