Skip to main content

Simple open web ui utilities to be added to and reused across local owui tools

Project description

OWUI Utilities

Package to add in reusable behavior for built in OWUI tools

Motivation

Can write utility functions to be reused across OWUI built in tools. Some tools are more appropriately deployed as tool servers, but some tools benefit from built in events that can access the UI during execution. Utilities to make these tools better can be built once and reused acrross tools.

Currently just a single utility exists, if more utilities are added then specific readmes can be moved out to individual sections.

Param Confirm: Background

Tool calls in openwebui can be great, but they are executed at the will of the llm. The llm will parse out the necessary arguments and decide to make the tool call. This has some potential downsides.

  1. This could be detrimental if the tool call is sending information to an external api that the user did not intend
  2. LLm could be performing an action the user may not have intended and these tool calls can have real effects, ie send emails, databases changes etc...
  3. Tool calls have very little insight for users as to what tool is called and with what arguments

We can mitigate this with reusable function decorators. The current function decorator is used to alert the user to the current tool call and what arguments are being passed to the tool call. This could be expanded for argument collection when parsing by llm proves to not work, and we could be provide more info on what is returned by the tool call. There is room for lots of different utilities.

Example

image The above example shows a user asking to make a sentence from a few words. The description of the tool allows the llm to decide that this is the proper tool to call, and the description of the arguments lets the llm parse the user sentence to get what it needs. Rather than executing the tool call the systems asks if the user would like to and alerts the user as to which arguments are being used. If the user confirms then the tool executes other wise it does not. This is a trivial example but illistrates the usage.

Usage

These are intended for "built in tools" ie tools with code created in the browser, this approach relies on events which are only for local tools not for external openapi tool servers.

These function can be exposed in a few ways.

  1. Code can be packaged and published to pypi with something like twine. This is useful to make the local tools more concise. Then simply add as a requriement to the local tool with the proper moduel docstring section such as below. This is then installed on the backend when the tool is saved. Current gitlab ci script publishes to gitlab package registry and artifactory. Including the artifactory pypi can then be specified by environment variable on openwebui launch
...
-e PIP_PACKAGE_INDEX_OPTIONS="--extra-index-url $ARTIFACTORY_URL"
...

tool header

requirements: pydantic, owui_tools
  1. The other options is include the entirety of the decorator in the code of the local tool.

Functions that wish use this simply need to import the function and decorate themselves with it.

from owui_tools import parameter_confirm
...<some stuff>
class Tools:
    <init and valves and stuff>
    @parameter_confirm(filter_args=True)
    def <function_name>(
        self,
        <arg1>: <type>,
        <arg2>: <type>,
        <arg3>: <type>,
        __event_emitter__: Callable[[dict], Awaitable[None]],
        __event_call__: Callable[[dict], Awaitable[None]],
        __user__: dict = {},
    ) -> str:
    """
    Normal OWUI function and param descriptions
    """
    <Normal function defintion>

If the tool itself does not need to use the event functions they should still be included for the decorator to use. A full example can be seen in the test directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

owui_utilities-0.0.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

owui_utilities-0.0.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file owui_utilities-0.0.3.tar.gz.

File metadata

  • Download URL: owui_utilities-0.0.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for owui_utilities-0.0.3.tar.gz
Algorithm Hash digest
SHA256 813d5329925ca40635b845619285def77c6c0f3e43628a0e9cde626cc2485514
MD5 8554e1ac5a94f61ed7347db29f8787ef
BLAKE2b-256 2c38ab622502afa34a7bdb8d4b9617a4574ac67f2d2efa223535a8f65399caff

See more details on using hashes here.

File details

Details for the file owui_utilities-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: owui_utilities-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for owui_utilities-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e5d6772cdc79245f45c2140156152e72a1addce5ef4ce05a05600f32c08ff168
MD5 bf016c55c97131f5c0d36ef7627745d6
BLAKE2b-256 7b4381b190f4f80d08a398642d79af6a7aea3a0db382a074da7fac315aa4a165

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page