fix: native function calling system prompt duplication

This commit is contained in:
Timothy Jaeryang Baek
2026-01-08 23:08:47 +04:00
parent 7aee9c4783
commit 9223efaff0
4 changed files with 15 additions and 4 deletions

View File

@@ -1256,6 +1256,7 @@ async def generate_chat_completion(
url_idx: Optional[int] = None,
user=Depends(get_verified_user),
bypass_filter: Optional[bool] = False,
bypass_system_prompt: bool = False,
db: Session = Depends(get_session),
):
if BYPASS_MODEL_ACCESS_CONTROL:
@@ -1295,7 +1296,8 @@ async def generate_chat_completion(
system = params.pop("system", None)
payload = apply_model_params_to_body_ollama(params, payload)
payload = apply_system_prompt_to_body(system, payload, metadata, user)
if not bypass_system_prompt:
payload = apply_system_prompt_to_body(system, payload, metadata, user)
# Check if user has access to the model
if not bypass_filter and user.role == "user":

View File

@@ -800,6 +800,7 @@ async def generate_chat_completion(
form_data: dict,
user=Depends(get_verified_user),
bypass_filter: Optional[bool] = False,
bypass_system_prompt: bool = False,
db: Session = Depends(get_session),
):
if BYPASS_MODEL_ACCESS_CONTROL:
@@ -830,7 +831,8 @@ async def generate_chat_completion(
system = params.pop("system", None)
payload = apply_model_params_to_body_openai(params, payload)
payload = apply_system_prompt_to_body(system, payload, metadata, user)
if not bypass_system_prompt:
payload = apply_system_prompt_to_body(system, payload, metadata, user)
# Check if user has access to the model
if not bypass_filter and user.role == "user":

View File

@@ -166,6 +166,7 @@ async def generate_chat_completion(
form_data: dict,
user: Any,
bypass_filter: bool = False,
bypass_system_prompt: bool = False,
):
log.debug(f"generate_chat_completion: {form_data}")
if BYPASS_MODEL_ACCESS_CONTROL:
@@ -237,7 +238,8 @@ async def generate_chat_completion(
yield chunk
response = await generate_chat_completion(
request, form_data, user, bypass_filter=True
request, form_data, user, bypass_filter=True,
bypass_system_prompt=bypass_system_prompt
)
return StreamingResponse(
stream_wrapper(response.body_iterator),
@@ -248,7 +250,8 @@ async def generate_chat_completion(
return {
**(
await generate_chat_completion(
request, form_data, user, bypass_filter=True
request, form_data, user, bypass_filter=True,
bypass_system_prompt=bypass_system_prompt
)
),
"selected_model_id": selected_model_id,
@@ -267,6 +270,7 @@ async def generate_chat_completion(
form_data=form_data,
user=user,
bypass_filter=bypass_filter,
bypass_system_prompt=bypass_system_prompt,
)
if form_data.get("stream"):
response.headers["content-type"] = "text/event-stream"
@@ -283,6 +287,7 @@ async def generate_chat_completion(
form_data=form_data,
user=user,
bypass_filter=bypass_filter,
bypass_system_prompt=bypass_system_prompt,
)

View File

@@ -3410,6 +3410,7 @@ async def process_chat_response(
request,
new_form_data,
user,
bypass_system_prompt=True,
)
if isinstance(res, StreamingResponse):
@@ -3589,6 +3590,7 @@ async def process_chat_response(
request,
new_form_data,
user,
bypass_system_prompt=True,
)
if isinstance(res, StreamingResponse):