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
014e52c0
Commit
014e52c0
authored
May 17, 2024
by
Timothy J. Baek
Browse files
fix: connection timeout
parent
fa54eb68
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
backend/apps/ollama/main.py
backend/apps/ollama/main.py
+2
-1
backend/apps/openai/main.py
backend/apps/openai/main.py
+2
-1
No files found.
backend/apps/ollama/main.py
View file @
014e52c0
...
@@ -124,8 +124,9 @@ async def cancel_ollama_request(request_id: str, user=Depends(get_current_user))
...
@@ -124,8 +124,9 @@ async def cancel_ollama_request(request_id: str, user=Depends(get_current_user))
async
def
fetch_url
(
url
):
async
def
fetch_url
(
url
):
timeout
=
aiohttp
.
ClientTimeout
(
total
=
5
)
try
:
try
:
async
with
aiohttp
.
ClientSession
()
as
session
:
async
with
aiohttp
.
ClientSession
(
timeout
=
timeout
)
as
session
:
async
with
session
.
get
(
url
)
as
response
:
async
with
session
.
get
(
url
)
as
response
:
return
await
response
.
json
()
return
await
response
.
json
()
except
Exception
as
e
:
except
Exception
as
e
:
...
...
backend/apps/openai/main.py
View file @
014e52c0
...
@@ -182,10 +182,11 @@ async def speech(request: Request, user=Depends(get_verified_user)):
...
@@ -182,10 +182,11 @@ async def speech(request: Request, user=Depends(get_verified_user)):
async
def
fetch_url
(
url
,
key
):
async
def
fetch_url
(
url
,
key
):
timeout
=
aiohttp
.
ClientTimeout
(
total
=
5
)
try
:
try
:
if
key
!=
""
:
if
key
!=
""
:
headers
=
{
"Authorization"
:
f
"Bearer
{
key
}
"
}
headers
=
{
"Authorization"
:
f
"Bearer
{
key
}
"
}
async
with
aiohttp
.
ClientSession
()
as
session
:
async
with
aiohttp
.
ClientSession
(
timeout
=
timeout
)
as
session
:
async
with
session
.
get
(
url
,
headers
=
headers
)
as
response
:
async
with
session
.
get
(
url
,
headers
=
headers
)
as
response
:
return
await
response
.
json
()
return
await
response
.
json
()
else
:
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