fix: arena model exclude filter

This commit is contained in:
Timothy J. Baek 2024-10-24 14:22:04 -07:00
parent e9e49babf8
commit 856c00bc2f
2 changed files with 5 additions and 2 deletions

View File

@ -761,6 +761,7 @@ async def generate_chat_completion(
form_data: GenerateChatCompletionForm, form_data: GenerateChatCompletionForm,
url_idx: Optional[int] = None, url_idx: Optional[int] = None,
user=Depends(get_verified_user), user=Depends(get_verified_user),
bypass_filter: Optional[bool] = False,
): ):
payload = {**form_data.model_dump(exclude_none=True)} payload = {**form_data.model_dump(exclude_none=True)}
log.debug(f"generate_chat_completion() - 1.payload = {payload}") log.debug(f"generate_chat_completion() - 1.payload = {payload}")
@ -769,7 +770,7 @@ async def generate_chat_completion(
model_id = form_data.model model_id = form_data.model
if app.state.config.ENABLE_MODEL_FILTER: if not bypass_filter and app.state.config.ENABLE_MODEL_FILTER:
if user.role == "user" and model_id not in app.state.config.MODEL_FILTER_LIST: if user.role == "user" and model_id not in app.state.config.MODEL_FILTER_LIST:
raise HTTPException( raise HTTPException(
status_code=403, status_code=403,

View File

@ -1154,7 +1154,9 @@ async def generate_chat_completions(
# Using /ollama/api/chat endpoint # Using /ollama/api/chat endpoint
form_data = convert_payload_openai_to_ollama(form_data) form_data = convert_payload_openai_to_ollama(form_data)
form_data = GenerateChatCompletionForm(**form_data) form_data = GenerateChatCompletionForm(**form_data)
response = await generate_ollama_chat_completion(form_data=form_data, user=user) response = await generate_ollama_chat_completion(
form_data=form_data, user=user, bypass_filter=True
)
if form_data.stream: if form_data.stream:
response.headers["content-type"] = "text/event-stream" response.headers["content-type"] = "text/event-stream"
return StreamingResponse( return StreamingResponse(