Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.3.7 #3536

Merged
merged 24 commits into from
Jun 30, 2024
Merged

0.3.7 #3536

Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift click to select a range
9111970
Update translation.json
aguvener Jun 28, 2024
3cc5da8
Update translation.json for minor change
aguvener Jun 28, 2024
57c3305
Fix: admin role for OIDC signup for first user
Jun 28, 2024
7d10dac
Fix: set jwt_token to cookie (instead of token from OIDC)
Jun 28, 2024
4d3e1ff
chore(deps): bump authlib from 1.3.0 to 1.3.1
dependabot[bot] Jun 28, 2024
269db07
fix: isInstance of streamingResponse but content-type is application/…
Peter-De-Ath Jun 28, 2024
8ab4b7a
i18n: Update Chinese translation
KarlLee830 Jun 28, 2024
2ef8992
added indonesian language
Naufal05R Jun 29, 2024
5b848dc
added indonesian language
Naufal05R Jun 29, 2024
45cb1c0
Updated Catalan Translation
Jun 29, 2024
6e03a1c
i18n: Updated Catalan Translation
Jun 29, 2024
776082d
i18n: Updated Catalan Translation
aleixdorca Jun 29, 2024
98ae064
Merge pull request #3525 from aleixdorca/dev
tjbck Jun 29, 2024
58398b6
Merge pull request #3514 from KarlLee830/translate
tjbck Jun 29, 2024
d3a67b4
Merge pull request #3499 from Semihal/fix-oauth-openid
tjbck Jun 29, 2024
27709c8
Merge pull request #3497 from aguvener/dev
tjbck Jun 29, 2024
73135b6
Merge pull request #3511 from Peter-De-Ath/ollama-chat-no-stream
tjbck Jun 29, 2024
61972ca
Merge pull request #3519 from Naufal05R/main
tjbck Jun 29, 2024
d056783
fix
tjbck Jun 30, 2024
16454c0
chore: format
tjbck Jun 30, 2024
41c55fb
enh: boilerplate
tjbck Jun 30, 2024
56137ac
Merge pull request #3507 from open-webui/dependabot/pip/authlib-1.3.1
tjbck Jun 30, 2024
df8d1da
refac: browser language detection
tjbck Jun 30, 2024
58d8dd9
chore: bump
tjbck Jun 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enh: boilerplate
  • Loading branch information
tjbck committed Jun 30, 2024
commit 41c55fbb81ece5b43827a1f408abc07d169e27ad
54 changes: 33 additions & 21 deletions src/lib/components/workspace/Functions/FunctionEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,61 27,73 @@
}

let codeEditor;
let boilerplate = `from pydantic import BaseModel
let boilerplate = `"""
title: Example Filter
author: open-webui
author_url: https://github.com/open-webui
funding_url: https://github.com/open-webui
version: 0.1
"""

from pydantic import BaseModel, Field
from typing import Optional


class Filter:
class Valves(BaseModel):
max_turns: int = 4
priority: int = Field(
default=0, description="Priority level for the filter operations."
)
max_turns: int = Field(
default=8, description="Maximum allowable conversation turns for a user."
)
pass

class UserValves(BaseModel):
max_turns: int = Field(
default=4, description="Maximum allowable conversation turns for a user."
)
pass

def __init__(self):
# 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.
# 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,
# which ensures settings are managed cohesively and not confused with operational flags like 'file_handler'.
self.valves = self.Valves(**{"max_turns": 2})
self.valves = self.Valves()
pass

def inlet(self, body: dict, user: Optional[dict] = None) -> dict:
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(f"inlet:{__name__}")
print(f"inlet:body:{body}")
print(f"inlet:user:{user}")
print(f"inlet:user:{__user__}")

if user.get("role", "admin") in ["user", "admin"]:
if __user__.get("role", "admin") in ["user", "admin"]:
messages = body.get("messages", [])
if len(messages) > self.valves.max_turns:

max_turns = min(__user__["valves"].max_turns, self.valves.max_turns)
if len(messages) > max_turns:
raise Exception(
f"Conversation turn limit exceeded. Max turns: {self.valves.max_turns}"
f"Conversation turn limit exceeded. Max turns: {max_turns}"
)

return body

def outlet(self, body: dict, user: Optional[dict] = None) -> dict:
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
# or perform additional checks and analytics.
print(f"outlet:{__name__}")
print(f"outlet:body:{body}")
print(f"outlet:user:{user}")

messages = [
{
**message,
"content": f"{message['content']} - @@Modified from Filter Outlet",
}
for message in body.get("messages", [])
]

return {"messages": messages}
print(f"outlet:user:{__user__}")

return body
`;

const _boilerplate = `from pydantic import BaseModel
Expand Down
Loading