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
439185be
Unverified
Commit
439185be
authored
Jan 05, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jan 05, 2024
Browse files
Merge pull request #397 from ollama-webui/logging
feat: proxy logging
parents
e5932122
78477baa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
backend/apps/ollama/main.py
backend/apps/ollama/main.py
+3
-1
No files found.
backend/apps/ollama/main.py
View file @
439185be
...
@@ -68,6 +68,7 @@ async def update_ollama_api_url(
...
@@ -68,6 +68,7 @@ async def update_ollama_api_url(
@
app
.
api_route
(
"/{path:path}"
,
methods
=
[
"GET"
,
"POST"
,
"PUT"
,
"DELETE"
])
@
app
.
api_route
(
"/{path:path}"
,
methods
=
[
"GET"
,
"POST"
,
"PUT"
,
"DELETE"
])
async
def
proxy
(
path
:
str
,
request
:
Request
,
user
=
Depends
(
get_current_user
)):
async
def
proxy
(
path
:
str
,
request
:
Request
,
user
=
Depends
(
get_current_user
)):
target_url
=
f
"
{
app
.
state
.
OLLAMA_API_BASE_URL
}
/
{
path
}
"
target_url
=
f
"
{
app
.
state
.
OLLAMA_API_BASE_URL
}
/
{
path
}
"
print
(
target_url
)
body
=
await
request
.
body
()
body
=
await
request
.
body
()
headers
=
dict
(
request
.
headers
)
headers
=
dict
(
request
.
headers
)
...
@@ -93,6 +94,7 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)):
...
@@ -93,6 +94,7 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)):
request
.
method
,
target_url
,
data
=
body
,
headers
=
headers
request
.
method
,
target_url
,
data
=
body
,
headers
=
headers
)
)
print
(
response
)
if
not
response
.
ok
:
if
not
response
.
ok
:
data
=
await
response
.
json
()
data
=
await
response
.
json
()
print
(
data
)
print
(
data
)
...
@@ -100,6 +102,7 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)):
...
@@ -100,6 +102,7 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)):
async
def
generate
():
async
def
generate
():
async
for
line
in
response
.
content
:
async
for
line
in
response
.
content
:
print
(
line
)
yield
line
yield
line
await
session
.
close
()
await
session
.
close
()
...
@@ -118,7 +121,6 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)):
...
@@ -118,7 +121,6 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)):
error_detail
=
f
"Ollama:
{
e
}
"
error_detail
=
f
"Ollama:
{
e
}
"
await
session
.
close
()
await
session
.
close
()
raise
HTTPException
(
raise
HTTPException
(
status_code
=
response
.
status
if
response
else
500
,
status_code
=
response
.
status
if
response
else
500
,
detail
=
error_detail
,
detail
=
error_detail
,
...
...
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