delete keys if envvars are set

This commit is contained in:
Michael Poluektov 2024-08-19 11:03:55 +01:00
parent a4a7d678f9
commit 18965dcdac
2 changed files with 9 additions and 6 deletions

View File

@ -732,11 +732,10 @@ async def generate_chat_completion(
):
log.debug(f"{form_data.model_dump_json(exclude_none=True).encode()}=")
payload = {
**form_data.model_dump(exclude_none=True, exclude=["metadata"]),
}
if "metadata" in payload:
del payload["metadata"]
payload = {**form_data.model_dump(exclude_none=True)}
for key in ["metadata", "files", "tool_ids"]:
if key in payload:
del payload[key]
model_id = form_data.model
model_info = Models.get_model_by_id(model_id)

View File

@ -453,7 +453,7 @@ async def chat_completion_tools_handler(
contexts.append(tool_output)
except Exception as e:
print(f"Error: {e}")
log.exception(f"Error: {e}")
content = None
log.debug(f"tool_contexts: {contexts}")
@ -997,6 +997,10 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
if model.get("pipe"):
return await generate_function_chat_completion(form_data, user=user)
for key in ["tool_ids", "files"]:
if key in form_data:
del form_data[key]
if model["owned_by"] == "ollama":
return await generate_ollama_chat_completion(form_data, user=user)
else: