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
646832ba
Commit
646832ba
authored
Jun 22, 2024
by
Timothy J. Baek
Browse files
refac
parent
6ccb5e8f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
15 deletions
+50
-15
backend/main.py
backend/main.py
+50
-15
No files found.
backend/main.py
View file @
646832ba
...
@@ -278,8 +278,16 @@ async def get_function_call_response(
...
@@ -278,8 +278,16 @@ async def get_function_call_response(
"email"
:
user
.
email
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
"role"
:
user
.
role
,
"valves"
:
Tools
.
get_user_valves_by_id_and_user_id
(
**
(
{
"valves"
:
toolkit_module
.
UserValves
(
Tools
.
get_user_valves_by_id_and_user_id
(
tool_id
,
user
.
id
tool_id
,
user
.
id
)
)
}
if
hasattr
(
toolkit_module
,
"UserValves"
)
else
{}
),
),
},
},
}
}
...
@@ -404,8 +412,18 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
...
@@ -404,8 +412,18 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
"email"
:
user
.
email
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
"role"
:
user
.
role
,
"valves"
:
Functions
.
get_user_valves_by_id_and_user_id
(
**
(
{
"valves"
:
function_module
.
UserValves
(
Functions
.
get_user_valves_by_id_and_user_id
(
filter_id
,
user
.
id
filter_id
,
user
.
id
)
)
}
if
hasattr
(
function_module
,
"UserValves"
)
else
{}
),
),
},
},
}
}
...
@@ -850,12 +868,6 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
...
@@ -850,12 +868,6 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
pipe
=
model
.
get
(
"pipe"
)
pipe
=
model
.
get
(
"pipe"
)
if
pipe
:
if
pipe
:
form_data
[
"user"
]
=
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
}
async
def
job
():
async
def
job
():
pipe_id
=
form_data
[
"model"
]
pipe_id
=
form_data
[
"model"
]
...
@@ -863,7 +875,14 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
...
@@ -863,7 +875,14 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
pipe_id
,
sub_pipe_id
=
pipe_id
.
split
(
"."
,
1
)
pipe_id
,
sub_pipe_id
=
pipe_id
.
split
(
"."
,
1
)
print
(
pipe_id
)
print
(
pipe_id
)
pipe
=
webui_app
.
state
.
FUNCTIONS
[
pipe_id
].
pipe
# Check if function is already loaded
if
pipe_id
not
in
app
.
state
.
FUNCTIONS
:
function_module
,
function_type
=
load_function_module_by_id
(
pipe_id
)
app
.
state
.
FUNCTIONS
[
pipe_id
]
=
function_module
else
:
function_module
=
app
.
state
.
FUNCTIONS
[
pipe_id
]
pipe
=
function_module
.
pipe
# Get the signature of the function
# Get the signature of the function
sig
=
inspect
.
signature
(
pipe
)
sig
=
inspect
.
signature
(
pipe
)
...
@@ -877,8 +896,16 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
...
@@ -877,8 +896,16 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
"email"
:
user
.
email
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
"role"
:
user
.
role
,
"valves"
:
Functions
.
get_user_valves_by_id_and_user_id
(
**
(
{
"valves"
:
pipe
.
UserValves
(
Functions
.
get_user_valves_by_id_and_user_id
(
pipe_id
,
user
.
id
pipe_id
,
user
.
id
)
)
}
if
hasattr
(
function_module
,
"UserValves"
)
else
{}
),
),
},
},
}
}
...
@@ -1079,8 +1106,16 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
...
@@ -1079,8 +1106,16 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
"email"
:
user
.
email
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
"role"
:
user
.
role
,
"valves"
:
Functions
.
get_user_valves_by_id_and_user_id
(
**
(
{
"valves"
:
function_module
.
UserValves
(
Functions
.
get_user_valves_by_id_and_user_id
(
filter_id
,
user
.
id
filter_id
,
user
.
id
)
)
}
if
hasattr
(
function_module
,
"UserValves"
)
else
{}
),
),
},
},
}
}
...
...
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