mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
@@ -30,9 +30,10 @@
|
||||
let boilerplate = `from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class Filter:
|
||||
class Valves(BaseModel):
|
||||
max_turns: int
|
||||
max_turns: int = 4
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
@@ -42,14 +43,14 @@ class Filter:
|
||||
|
||||
# Initialize 'valves' with specific configurations. Using 'Valves' instance helps encapsulate settings,
|
||||
# which ensures settings are managed cohesively and not confused with operational flags like 'file_handler'.
|
||||
self.valves = self.Valves(**{"max_turns": 10})
|
||||
self.valves = self.Valves(**{"max_turns": 2})
|
||||
pass
|
||||
|
||||
def inlet(self, body: dict, user: Optional[dict] = None) -> dict:
|
||||
# Modify the request body or validate it before processing by the chat completion API.
|
||||
# This function is the pre-processor for the API where various checks on the input can be performed.
|
||||
# It can also modify the request before sending it to the API.
|
||||
|
||||
|
||||
print("inlet")
|
||||
print(body)
|
||||
print(user)
|
||||
@@ -65,7 +66,7 @@ class Filter:
|
||||
|
||||
def outlet(self, body: dict, user: Optional[dict] = None) -> dict:
|
||||
# Modify or analyze the response body after processing by the API.
|
||||
# This function is the post-processor for the API, which can be used to modify the response
|
||||
# This function is the post-processor for the API, which can be used to modify the response
|
||||
# or perform additional checks and analytics.
|
||||
print(f"outlet")
|
||||
print(body)
|
||||
|
||||
Reference in New Issue
Block a user