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
0f5ecafc
Commit
0f5ecafc
authored
Apr 14, 2024
by
Timothy J. Baek
Browse files
fix: api usage issue
parent
98c16776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
backend/apps/ollama/main.py
backend/apps/ollama/main.py
+24
-4
No files found.
backend/apps/ollama/main.py
View file @
0f5ecafc
...
@@ -612,7 +612,12 @@ async def generate_embeddings(
...
@@ -612,7 +612,12 @@ async def generate_embeddings(
user
=
Depends
(
get_current_user
),
user
=
Depends
(
get_current_user
),
):
):
if
url_idx
==
None
:
if
url_idx
==
None
:
if
form_data
.
model
in
app
.
state
.
MODELS
:
model
=
form_data
.
model
if
":"
not
in
model
:
model
=
f
"
{
model
}
:latest"
if
model
in
app
.
state
.
MODELS
:
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
...
@@ -672,7 +677,12 @@ async def generate_completion(
...
@@ -672,7 +677,12 @@ async def generate_completion(
):
):
if
url_idx
==
None
:
if
url_idx
==
None
:
if
form_data
.
model
in
app
.
state
.
MODELS
:
model
=
form_data
.
model
if
":"
not
in
model
:
model
=
f
"
{
model
}
:latest"
if
model
in
app
.
state
.
MODELS
:
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
...
@@ -770,7 +780,12 @@ async def generate_chat_completion(
...
@@ -770,7 +780,12 @@ async def generate_chat_completion(
):
):
if
url_idx
==
None
:
if
url_idx
==
None
:
if
form_data
.
model
in
app
.
state
.
MODELS
:
model
=
form_data
.
model
if
":"
not
in
model
:
model
=
f
"
{
model
}
:latest"
if
model
in
app
.
state
.
MODELS
:
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
...
@@ -874,7 +889,12 @@ async def generate_openai_chat_completion(
...
@@ -874,7 +889,12 @@ async def generate_openai_chat_completion(
):
):
if
url_idx
==
None
:
if
url_idx
==
None
:
if
form_data
.
model
in
app
.
state
.
MODELS
:
model
=
form_data
.
model
if
":"
not
in
model
:
model
=
f
"
{
model
}
:latest"
if
model
in
app
.
state
.
MODELS
:
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
url_idx
=
random
.
choice
(
app
.
state
.
MODELS
[
form_data
.
model
][
"urls"
])
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
...
...
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