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
ed0d4b5a
Commit
ed0d4b5a
authored
Mar 20, 2024
by
Timothy J. Baek
Browse files
chore: comment clean up
parent
1a240e10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
9 deletions
+1
-9
backend/apps/litellm/main.py
backend/apps/litellm/main.py
+1
-9
No files found.
backend/apps/litellm/main.py
View file @
ed0d4b5a
...
...
@@ -67,20 +67,15 @@ class ModifyModelsResponseMiddleware(BaseHTTPMiddleware):
response
=
await
call_next
(
request
)
user
=
request
.
state
.
user
# Check if the request is for the `/models` route
if
"/models"
in
request
.
url
.
path
:
# Ensure the response is a StreamingResponse
if
isinstance
(
response
,
StreamingResponse
):
# Read the content of the streaming response
body
=
b
""
async
for
chunk
in
response
.
body_iterator
:
body
+=
chunk
# Modify the content as needed
data
=
json
.
loads
(
body
.
decode
(
"utf-8"
))
print
(
data
)
if
app
.
state
.
MODEL_FILTER_ENABLED
:
if
user
and
user
.
role
==
"user"
:
data
[
"data"
]
=
list
(
...
...
@@ -91,14 +86,11 @@ class ModifyModelsResponseMiddleware(BaseHTTPMiddleware):
)
)
#
Example modification: Add a new key-value pair
#
Modified Flag
data
[
"modified"
]
=
True
# Return a new JSON response with the modified content
return
JSONResponse
(
content
=
data
)
return
response
# Add the middleware to the app
app
.
add_middleware
(
ModifyModelsResponseMiddleware
)
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