constants.py 5.09 KB
Newer Older
1
2
3
4
5
from enum import Enum


class MESSAGES(str, Enum):
    DEFAULT = lambda msg="": f"{msg if msg else ''}"
6
7
8
9
    MODEL_ADDED = lambda model="": f"The model '{model}' has been added successfully."
    MODEL_DELETED = (
        lambda model="": f"The model '{model}' has been deleted successfully."
    )
10
11


Timothy J. Baek's avatar
Timothy J. Baek committed
12
13
14
15
16
17
18
class WEBHOOK_MESSAGES(str, Enum):
    DEFAULT = lambda msg="": f"{msg if msg else ''}"
    USER_SIGNUP = lambda username="": (
        f"New user signed up: {username}" if username else "New user signed up"
    )


19
class ERROR_MESSAGES(str, Enum):
Timothy J. Baek's avatar
Timothy J. Baek committed
20
21
22
    def __str__(self) -> str:
        return super().__str__()

23
    DEFAULT = lambda err="": f"Something went wrong :/\n{err if err else ''}"
Timothy J. Baek's avatar
Timothy J. Baek committed
24
    ENV_VAR_NOT_FOUND = "Required environment variable not found. Terminating now."
25
    CREATE_USER_ERROR = "Oops! Something went wrong while creating your account. Please try again later. If the issue persists, contact support for assistance."
26
    DELETE_USER_ERROR = "Oops! Something went wrong. We encountered an issue while trying to delete the user. Please give it another shot."
27
    EMAIL_MISMATCH = "Uh-oh! This email does not match the email your provider is registered with. Please check your email and try again."
Timothy J. Baek's avatar
Timothy J. Baek committed
28
29
30
31
    EMAIL_TAKEN = "Uh-oh! This email is already registered. Sign in with your existing account or choose another email to start anew."
    USERNAME_TAKEN = (
        "Uh-oh! This username is already registered. Please choose another username."
    )
Timothy J. Baek's avatar
Timothy J. Baek committed
32
    COMMAND_TAKEN = "Uh-oh! This command is already registered. Please choose another command string."
33
34
    FILE_EXISTS = "Uh-oh! This file is already registered. Please choose another file."

Timothy J. Baek's avatar
Timothy J. Baek committed
35
    ID_TAKEN = "Uh-oh! This id is already registered. Please choose another id string."
Timothy J. Baek's avatar
Timothy J. Baek committed
36
37
    MODEL_ID_TAKEN = "Uh-oh! This model id is already registered. Please choose another model id string."

38
    NAME_TAG_TAKEN = "Uh-oh! This name tag is already registered. Please choose another name tag string."
Timothy J. Baek's avatar
Timothy J. Baek committed
39
40
41
42
    INVALID_TOKEN = (
        "Your session has expired or the token is invalid. Please sign in again."
    )
    INVALID_CRED = "The email or password provided is incorrect. Please check for typos and try logging in again."
43
    INVALID_EMAIL_FORMAT = "The email format you entered is invalid. Please double-check and make sure you're using a valid email address (e.g., yourname@example.com)."
44
45
46
    INVALID_PASSWORD = (
        "The password provided is incorrect. Please check for typos and try again."
    )
47
    INVALID_TRUSTED_HEADER = "Your provider has not provided a trusted header. Please contact your administrator for assistance."
Timothy J. Baek's avatar
Timothy J. Baek committed
48
49
50

    EXISTING_USERS = "You can't turn off authentication because there are existing users. If you want to disable WEBUI_AUTH, make sure your web interface doesn't have any existing users and is a fresh installation."

51
    UNAUTHORIZED = "401 Unauthorized"
Timothy J. Baek's avatar
Timothy J. Baek committed
52
    ACCESS_PROHIBITED = "You do not have permission to access this resource. Please contact your administrator for assistance."
Timothy J. Baek's avatar
Timothy J. Baek committed
53
    ACTION_PROHIBITED = (
54
55
56
57
        "The requested action has been restricted as a security measure."
    )

    FILE_NOT_SENT = "FILE_NOT_SENT"
Timothy J. Baek's avatar
Timothy J. Baek committed
58
59
    FILE_NOT_SUPPORTED = "Oops! It seems like the file format you're trying to upload is not supported. Please upload a file with a supported format (e.g., JPG, PNG, PDF, TXT) and try again."

60
    NOT_FOUND = "We could not find what you're looking for :/"
61
    USER_NOT_FOUND = "We could not find what you're looking for :/"
62
    API_KEY_NOT_FOUND = "Oops! It looks like there's a hiccup. The API key is missing. Please make sure to provide a valid API key to access this feature."
Timothy J. Baek's avatar
Timothy J. Baek committed
63

64
    MALICIOUS = "Unusual activities detected, please try again in a few minutes."
Dave Bauman's avatar
Dave Bauman committed
65
66

    PANDOC_NOT_INSTALLED = "Pandoc is not installed on the server. Please contact your administrator for assistance."
Timothy J. Baek's avatar
Timothy J. Baek committed
67
    INCORRECT_FORMAT = (
68
        lambda err="": f"Invalid format. Please use the correct format{err}"
Timothy J. Baek's avatar
Timothy J. Baek committed
69
    )
Timothy J. Baek's avatar
Timothy J. Baek committed
70
    RATE_LIMIT_EXCEEDED = "API rate limit exceeded"
Timothy J. Baek's avatar
Timothy J. Baek committed
71
72

    MODEL_NOT_FOUND = lambda name="": f"Model '{name}' was not found"
liu.vaayne's avatar
liu.vaayne committed
73
    OPENAI_NOT_FOUND = lambda name="": "OpenAI API was not found"
Timothy J. Baek's avatar
Timothy J. Baek committed
74
    OLLAMA_NOT_FOUND = "WebUI could not connect to Ollama"
liu.vaayne's avatar
liu.vaayne committed
75
    CREATE_API_KEY_ERROR = "Oops! Something went wrong while creating your API key. Please try again later. If the issue persists, contact support for assistance."
Timothy J. Baek's avatar
Timothy J. Baek committed
76
77

    EMPTY_CONTENT = "The content provided is empty. Please ensure that there is text or data present before proceeding."
78
79

    DB_NOT_SQLITE = "This feature is only available when running with SQLite databases."
80
81
82
83

    INVALID_URL = (
        "Oops! The URL you provided is invalid. Please double-check and try again."
    )
84
85

    WEB_SEARCH_ERROR = (
Timothy J. Baek's avatar
Timothy J. Baek committed
86
        lambda err="": f"{err if err else 'Oops! Something went wrong while searching the web.'}"
87
    )
88
89
90
91

    OLLAMA_API_DISABLED = (
        "The Ollama API is disabled. Please enable it to use this feature."
    )
Timothy J. Baek's avatar
Timothy J. Baek committed
92
93
94
95
96
97


class TASKS(str, Enum):
    def __str__(self) -> str:
        return super().__str__()

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
98
99
100
101
102
    DEFAULT = lambda task="": f"{task if task else 'generation'}"
    TITLE_GENERATION = "title_generation"
    EMOJI_GENERATION = "emoji_generation"
    QUERY_GENERATION = "query_generation"
    FUNCTION_CALLING = "function_calling"