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
0ea9e19d
Commit
0ea9e19d
authored
Apr 23, 2024
by
Jun Siang Cheah
Browse files
feat: add LITELLM_PROXY_PORT to configure internal proxy port
parent
86bc0c8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
backend/apps/litellm/main.py
backend/apps/litellm/main.py
+9
-7
backend/config.py
backend/config.py
+8
-0
No files found.
backend/apps/litellm/main.py
View file @
0ea9e19d
...
@@ -23,7 +23,12 @@ log = logging.getLogger(__name__)
...
@@ -23,7 +23,12 @@ log = logging.getLogger(__name__)
log
.
setLevel
(
SRC_LOG_LEVELS
[
"LITELLM"
])
log
.
setLevel
(
SRC_LOG_LEVELS
[
"LITELLM"
])
from
config
import
MODEL_FILTER_ENABLED
,
MODEL_FILTER_LIST
,
DATA_DIR
from
config
import
(
MODEL_FILTER_ENABLED
,
MODEL_FILTER_LIST
,
DATA_DIR
,
LITELLM_PROXY_PORT
,
)
from
litellm.utils
import
get_llm_provider
from
litellm.utils
import
get_llm_provider
...
@@ -90,9 +95,7 @@ async def run_background_process(command):
...
@@ -90,9 +95,7 @@ async def run_background_process(command):
async
def
start_litellm_background
():
async
def
start_litellm_background
():
log
.
info
(
"start_litellm_background"
)
log
.
info
(
"start_litellm_background"
)
# Command to run in the background
# Command to run in the background
command
=
(
command
=
f
"litellm --port
{
LITELLM_PROXY_PORT
}
--telemetry False --config ./data/litellm/config.yaml"
"litellm --port 14365 --telemetry False --config ./data/litellm/config.yaml"
)
await
run_background_process
(
command
)
await
run_background_process
(
command
)
...
@@ -109,7 +112,6 @@ async def shutdown_litellm_background():
...
@@ -109,7 +112,6 @@ async def shutdown_litellm_background():
@
app
.
on_event
(
"startup"
)
@
app
.
on_event
(
"startup"
)
async
def
startup_event
():
async
def
startup_event
():
log
.
info
(
"startup_event"
)
log
.
info
(
"startup_event"
)
# TODO: Check config.yaml file and create one
# TODO: Check config.yaml file and create one
asyncio
.
create_task
(
start_litellm_background
())
asyncio
.
create_task
(
start_litellm_background
())
...
@@ -186,7 +188,7 @@ async def get_models(user=Depends(get_current_user)):
...
@@ -186,7 +188,7 @@ async def get_models(user=Depends(get_current_user)):
while
not
background_process
:
while
not
background_process
:
await
asyncio
.
sleep
(
0.1
)
await
asyncio
.
sleep
(
0.1
)
url
=
"http://localhost:
14365
/v1"
url
=
f
"http://localhost:
{
LITELLM_PROXY_PORT
}
/v1"
r
=
None
r
=
None
try
:
try
:
r
=
requests
.
request
(
method
=
"GET"
,
url
=
f
"
{
url
}
/models"
)
r
=
requests
.
request
(
method
=
"GET"
,
url
=
f
"
{
url
}
/models"
)
...
@@ -289,7 +291,7 @@ async def delete_model_from_config(
...
@@ -289,7 +291,7 @@ async def delete_model_from_config(
async
def
proxy
(
path
:
str
,
request
:
Request
,
user
=
Depends
(
get_verified_user
)):
async
def
proxy
(
path
:
str
,
request
:
Request
,
user
=
Depends
(
get_verified_user
)):
body
=
await
request
.
body
()
body
=
await
request
.
body
()
url
=
"http://localhost:
14365
"
url
=
f
"http://localhost:
{
LITELLM_PROXY_PORT
}
"
target_url
=
f
"
{
url
}
/
{
path
}
"
target_url
=
f
"
{
url
}
/
{
path
}
"
...
...
backend/config.py
View file @
0ea9e19d
...
@@ -499,3 +499,11 @@ IMAGES_OPENAI_API_KEY = os.getenv("IMAGES_OPENAI_API_KEY", OPENAI_API_KEY)
...
@@ -499,3 +499,11 @@ IMAGES_OPENAI_API_KEY = os.getenv("IMAGES_OPENAI_API_KEY", OPENAI_API_KEY)
AUDIO_OPENAI_API_BASE_URL
=
os
.
getenv
(
"AUDIO_OPENAI_API_BASE_URL"
,
OPENAI_API_BASE_URL
)
AUDIO_OPENAI_API_BASE_URL
=
os
.
getenv
(
"AUDIO_OPENAI_API_BASE_URL"
,
OPENAI_API_BASE_URL
)
AUDIO_OPENAI_API_KEY
=
os
.
getenv
(
"AUDIO_OPENAI_API_KEY"
,
OPENAI_API_KEY
)
AUDIO_OPENAI_API_KEY
=
os
.
getenv
(
"AUDIO_OPENAI_API_KEY"
,
OPENAI_API_KEY
)
####################################
# LiteLLM
####################################
LITELLM_PROXY_PORT
=
int
(
os
.
getenv
(
"LITELLM_PROXY_PORT"
,
"14365"
))
if
LITELLM_PROXY_PORT
<
0
or
LITELLM_PROXY_PORT
>
65535
:
raise
ValueError
(
"Invalid port number for LITELLM_PROXY_PORT"
)
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