chore: format
This commit is contained in:
@@ -679,9 +679,7 @@ async def lifespan(app: FastAPI):
|
||||
}
|
||||
)
|
||||
await set_tool_servers(mock_request)
|
||||
log.info(
|
||||
f"Initialized {len(app.state.TOOL_SERVERS)} tool server(s)"
|
||||
)
|
||||
log.info(f"Initialized {len(app.state.TOOL_SERVERS)} tool server(s)")
|
||||
except Exception as e:
|
||||
log.warning(f"Failed to initialize tool servers at startup: {e}")
|
||||
|
||||
|
||||
@@ -451,9 +451,7 @@ class ChatTable:
|
||||
# Clean up orphaned old tags in one query
|
||||
removed = set(old_tags) - set(new_tag_ids)
|
||||
if removed:
|
||||
self.delete_orphan_tags_for_user(
|
||||
list(removed), user.id, db=db
|
||||
)
|
||||
self.delete_orphan_tags_for_user(list(removed), user.id, db=db)
|
||||
|
||||
return ChatModel.model_validate(chat)
|
||||
|
||||
@@ -1380,9 +1378,7 @@ class ChatTable:
|
||||
with get_db_context(db) as db:
|
||||
orphans = []
|
||||
for tag_id in tag_ids:
|
||||
count = self.count_chats_by_tag_name_and_user_id(
|
||||
tag_id, user_id, db=db
|
||||
)
|
||||
count = self.count_chats_by_tag_name_and_user_id(tag_id, user_id, db=db)
|
||||
if count <= threshold:
|
||||
orphans.append(tag_id)
|
||||
Tags.delete_tags_by_ids_and_user_id(orphans, user_id, db=db)
|
||||
|
||||
@@ -218,11 +218,7 @@ class GroupTable:
|
||||
)
|
||||
)
|
||||
|
||||
results = (
|
||||
query.group_by(Group.id)
|
||||
.order_by(Group.updated_at.desc())
|
||||
.all()
|
||||
)
|
||||
results = query.group_by(Group.id).order_by(Group.updated_at.desc()).all()
|
||||
|
||||
return [
|
||||
GroupResponse.model_validate(
|
||||
|
||||
@@ -123,9 +123,9 @@ class TagTable:
|
||||
return True
|
||||
try:
|
||||
with get_db_context(db) as db:
|
||||
db.query(Tag).filter(
|
||||
Tag.id.in_(ids), Tag.user_id == user_id
|
||||
).delete(synchronize_session=False)
|
||||
db.query(Tag).filter(Tag.id.in_(ids), Tag.user_id == user_id).delete(
|
||||
synchronize_session=False
|
||||
)
|
||||
db.commit()
|
||||
return True
|
||||
except Exception as e:
|
||||
|
||||
@@ -107,7 +107,9 @@ async def get_tools(
|
||||
|
||||
# MCP Tool Servers
|
||||
for server in request.app.state.config.TOOL_SERVER_CONNECTIONS:
|
||||
if server.get("type", "openapi") == "mcp" and server.get("config", {}).get("enable"):
|
||||
if server.get("type", "openapi") == "mcp" and server.get("config", {}).get(
|
||||
"enable"
|
||||
):
|
||||
server_id = server.get("info", {}).get("id")
|
||||
auth_type = server.get("auth_type", "none")
|
||||
|
||||
|
||||
@@ -1918,9 +1918,7 @@ async def convert_url_images_to_base64(form_data):
|
||||
return form_data
|
||||
|
||||
|
||||
def load_messages_from_db(
|
||||
chat_id: str, message_id: str
|
||||
) -> Optional[list[dict]]:
|
||||
def load_messages_from_db(chat_id: str, message_id: str) -> Optional[list[dict]]:
|
||||
"""
|
||||
Load the message chain from DB up to message_id,
|
||||
keeping only LLM-relevant fields (role, content, output).
|
||||
@@ -2164,7 +2162,8 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
form_data["messages"] = add_or_update_user_message(
|
||||
(
|
||||
request.app.state.config.CODE_INTERPRETER_PROMPT_TEMPLATE
|
||||
if request.app.state.config.CODE_INTERPRETER_PROMPT_TEMPLATE != ""
|
||||
if request.app.state.config.CODE_INTERPRETER_PROMPT_TEMPLATE
|
||||
!= ""
|
||||
else DEFAULT_CODE_INTERPRETER_PROMPT
|
||||
),
|
||||
form_data["messages"],
|
||||
@@ -2198,7 +2197,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
if skill.id in user_skill_ids:
|
||||
# User-selected: inject full content
|
||||
form_data["messages"] = add_or_update_system_message(
|
||||
f"<skill name=\"{skill.name}\">\n{skill.content}\n</skill>",
|
||||
f'<skill name="{skill.name}">\n{skill.content}\n</skill>',
|
||||
form_data["messages"],
|
||||
append=True,
|
||||
)
|
||||
@@ -2447,7 +2446,9 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
{
|
||||
**extra_params,
|
||||
"__event_emitter__": event_emitter,
|
||||
"__skill_ids__": [s.id for s in available_skills if s.id not in user_skill_ids],
|
||||
"__skill_ids__": [
|
||||
s.id for s in available_skills if s.id not in user_skill_ids
|
||||
],
|
||||
},
|
||||
features,
|
||||
model,
|
||||
|
||||
Reference in New Issue
Block a user