Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
f14ca483
Commit
f14ca483
authored
Jun 20, 2024
by
Timothy J. Baek
Browse files
refac
parent
96d7c3e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
src/lib/components/workspace/Functions/FunctionEditor.svelte
src/lib/components/workspace/Functions/FunctionEditor.svelte
+10
-10
No files found.
src/lib/components/workspace/Functions/FunctionEditor.svelte
View file @
f14ca483
...
@@ -39,6 +39,7 @@ class Filter:
...
@@ -39,6 +39,7 @@ class Filter:
def __init__(self):
def __init__(self):
# Indicates custom file handling logic. This flag helps disengage default routines in favor of custom
# Indicates custom file handling logic. This flag helps disengage default routines in favor of custom
# implementations, informing the WebUI to defer file-related operations to designated methods within this class.
# implementations, informing the WebUI to defer file-related operations to designated methods within this class.
# Alternatively, you can remove the files directly from the body in from the inlet hook
self.file_handler = True
self.file_handler = True
# Initialize 'valves' with specific configurations. Using 'Valves' instance helps encapsulate settings,
# Initialize 'valves' with specific configurations. Using 'Valves' instance helps encapsulate settings,
...
@@ -50,16 +51,15 @@ class Filter:
...
@@ -50,16 +51,15 @@ class Filter:
# Modify the request body or validate it before processing by the chat completion API.
# 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.
# 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.
# It can also modify the request before sending it to the API.
print(f"inlet:{__name__}")
print(f"inlet:body:{body}")
print(f"inlet:user:{user}")
print("inlet")
if user.get("role", "admin") in ["user", "admin"]:
print(body)
print(user)
if user.get("role", "admin") in ["user"]:
messages = body.get("messages", [])
messages = body.get("messages", [])
if len(messages) > self.max_turns:
if len(messages) > self.
valves.
max_turns:
raise Exception(
raise Exception(
f"Conversation turn limit exceeded. Max turns: {self.max_turns}"
f"Conversation turn limit exceeded. Max turns: {self.
valves.
max_turns}"
)
)
return body
return body
...
@@ -68,9 +68,9 @@ class Filter:
...
@@ -68,9 +68,9 @@ class Filter:
# Modify or analyze the response body after processing by the API.
# 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.
# or perform additional checks and analytics.
print(f"outlet")
print(f"outlet
:{__name__}
")
print(
body
)
print(
f"outlet:body:{body}"
)
print(
user
)
print(
f"outlet:user:{user}"
)
return body`;
return body`;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment