remove unnecessary nesting, remove unused endpoint

This commit is contained in:
Michael Poluektov 2024-08-10 11:58:18 +01:00
parent c8badfe21f
commit 3befadb29f

View File

@ -532,7 +532,9 @@ async def chat_completion_tools_handler(body, user, __event_emitter__, __event_c
task_model_id = get_task_model_id(body["model"])
# If tool_ids field is present, call the functions
if "tool_ids" in body:
if "tool_ids" not in body:
return body, {}
print(body["tool_ids"])
for tool_id in body["tool_ids"]:
print(tool_id)
@ -563,6 +565,7 @@ async def chat_completion_tools_handler(body, user, __event_emitter__, __event_c
except Exception as e:
print(f"Error: {e}")
del body["tool_ids"]
print(f"tool_contexts: {contexts}")
@ -1610,41 +1613,6 @@ Message: """{{prompt}}"""
return await generate_chat_completions(form_data=payload, user=user)
@app.post("/api/task/tools/completions")
async def get_tools_function_calling(form_data: dict, user=Depends(get_verified_user)):
print("get_tools_function_calling")
model_id = form_data["model"]
if model_id not in app.state.MODELS:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Model not found",
)
# Check if the user has a custom task model
# If the user has a custom task model, use that model
model_id = get_task_model_id(model_id)
print(model_id)
template = app.state.config.TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE
try:
context, _, _ = await get_function_call_response(
form_data["messages"],
form_data.get("files", []),
form_data["tool_id"],
template,
model_id,
user,
)
return context
except Exception as e:
return JSONResponse(
status_code=e.args[0],
content={"detail": e.args[1]},
)
##################################
#
# Pipelines Endpoints