Skip to content

Commit a13e5d6

Browse files
committed
fix(frontend): resolve DocumentChunk merge conflicts with develop
Merge develop's effectiveIndexName fallback for chunk CRUD/search APIs while keeping embedding model mismatch validation before hybrid search.
2 parents e260d48 + 533fea1 commit a13e5d6

133 files changed

Lines changed: 8353 additions & 3244 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docker-deploy.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ jobs:
3838
- name: Check if model is cached locally
3939
id: check-model
4040
run: |
41-
if [ -f ~/model-assets/clip-vit-base-patch32/config.json ] && [ -d ~/model-assets/nltk_data ]; then
41+
if [ -f ~/model-assets/clip-vit-base-patch32/config.json ] && \
42+
[ -d ~/model-assets/nltk_data ] && \
43+
[ -d ~/model-assets/table-transformer-structure-recognition ] && \
44+
[ -d ~/model-assets/yolox ]; then
4245
echo "cache-hit=true" >> "$GITHUB_OUTPUT"
4346
cp -r ~/model-assets ./
4447
else
@@ -105,4 +108,4 @@ jobs:
105108
./deploy.sh --mode 3 --is-mainland N --enable-terminal N --version 2 --root-dir "$HOME/nexent-production-data"
106109
else
107110
./deploy.sh --mode 1 --is-mainland N --enable-terminal N --version 2 --root-dir "$HOME/nexent-development-data"
108-
fi
111+
fi

backend/agents/create_agent_info.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import threading
1+
import threading
22
import logging
33
from typing import List, Optional
44
from urllib.parse import urljoin
@@ -498,6 +498,7 @@ async def create_tool_config_list(agent_id, tenant_id, user_id, version_no: int
498498
rerank = param_dict.get("rerank", False)
499499
rerank_model_name = param_dict.get("rerank_model_name", "")
500500
rerank_model = None
501+
is_multimodal = bool(tool_config.params.pop("multimodal", False))
501502
if rerank and rerank_model_name:
502503
rerank_model = get_rerank_model(
503504
tenant_id=tenant_id, model_name=rerank_model_name
@@ -877,7 +878,7 @@ async def create_agent_run_info(
877878
# Filter MCP servers and tools, and build mcp_host with authorization
878879
used_mcp_urls = filter_mcp_servers_and_tools(agent_config, remote_mcp_dict)
879880

880-
# Build mcp_host list with authorization tokens
881+
# Build mcp_host list with authorization tokens and custom headers
881882
mcp_host = []
882883
for url in used_mcp_urls:
883884
# Find the MCP record for this URL
@@ -892,10 +893,15 @@ async def create_agent_run_info(
892893
"url": url,
893894
"transport": "sse" if url.endswith("/sse") else "streamable-http"
894895
}
895-
# Add authorization if present
896+
headers = {}
896897
auth_token = mcp_record.get("authorization_token")
897898
if auth_token:
898-
mcp_config["authorization"] = auth_token
899+
headers["Authorization"] = auth_token
900+
custom_headers = mcp_record.get("custom_headers")
901+
if custom_headers and isinstance(custom_headers, dict):
902+
headers.update(custom_headers)
903+
if headers:
904+
mcp_config["headers"] = headers
899905
mcp_host.append(mcp_config)
900906
else:
901907
# Fallback to string format if record not found

backend/apps/file_management_app.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ async def upload_files(
129129

130130
@file_management_config_router.post("/process")
131131
async def process_files(
132-
files: List[dict] = Body(
133-
..., description="List of file details to process, including path_or_url and filename"),
134-
chunking_strategy: Optional[str] = Body("basic"),
135-
index_name: str = Body(...),
136-
destination: str = Body(...),
137-
authorization: Optional[str] = Header(None)
132+
files: Annotated[List[dict], Body(
133+
..., description="List of file details to process, including path_or_url and filename")],
134+
index_name: Annotated[str, Body(...)],
135+
destination: Annotated[str, Body(...)],
136+
chunking_strategy: Annotated[Optional[str], Body(...)] = "basic",
137+
model_id: Annotated[Optional[int], Body(...)] = None,
138+
authorization: Annotated[Optional[str], Header()] = None
138139
):
139140
"""
140141
Trigger data processing for a list of uploaded files.
@@ -147,7 +148,8 @@ async def process_files(
147148
chunking_strategy=chunking_strategy,
148149
source_type=destination,
149150
index_name=index_name,
150-
authorization=authorization
151+
authorization=authorization,
152+
model_id=model_id
151153
)
152154

153155
process_result = await trigger_data_process(files, process_params)

backend/apps/model_managment_app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from fastapi.responses import JSONResponse
3434
from fastapi.encoders import jsonable_encoder
3535
from http import HTTPStatus
36-
from typing import List, Optional
36+
from typing import Annotated, List, Optional
3737
from services.model_health_service import (
3838
check_model_connectivity,
3939
verify_model_config_connectivity,
@@ -298,7 +298,8 @@ async def get_llm_model_list(authorization: Optional[str] = Header(None)):
298298

299299
@router.post("/healthcheck")
300300
async def check_model_health(
301-
display_name: str = Query(..., description="Display name to check"),
301+
display_name: Annotated[str, Query(..., description="Display name to check")],
302+
model_type: Annotated[str, Query(..., description="...")],
302303
authorization: Optional[str] = Header(None)
303304
):
304305
"""Check and update model connectivity, returning the latest status.
@@ -309,7 +310,7 @@ async def check_model_health(
309310
"""
310311
try:
311312
_, tenant_id = get_current_user_id(authorization)
312-
result = await check_model_connectivity(display_name, tenant_id)
313+
result = await check_model_connectivity(display_name, tenant_id, model_type)
313314
return JSONResponse(status_code=HTTPStatus.OK, content={
314315
"message": "Successfully checked model connectivity",
315316
"data": result

backend/apps/remote_mcp_app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ async def add_mcp_service_endpoint(
122122
server_url=payload.server_url,
123123
tags=payload.tags,
124124
authorization_token=payload.authorization_token,
125+
custom_headers=payload.custom_headers,
125126
container_config=payload.container_config,
126127
registry_json=payload.registry_json,
127128
enabled=payload.enabled if payload.enabled is not None else False,
@@ -239,6 +240,7 @@ async def update_mcp_service_endpoint(
239240
description=payload.description,
240241
server_url=payload.server_url,
241242
authorization_token=payload.authorization_token,
243+
custom_headers=payload.custom_headers,
242244
tags=payload.tags,
243245
)
244246

@@ -421,6 +423,7 @@ async def get_mcp_record(
421423
"mcp_name": mcp_record.get("mcp_name"),
422424
"mcp_server": mcp_record.get("mcp_server"),
423425
"authorization_token": mcp_record.get("authorization_token"),
426+
"custom_headers": mcp_record.get("custom_headers"),
424427
"status": "success"
425428
}
426429
)

backend/apps/vectordatabase_app.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ def create_new_index(
8484
# Extract optional fields from request body
8585
ingroup_permission = None
8686
group_ids = None
87-
embedding_model_name = None
87+
embedding_model_name: Optional[str] = None
88+
is_multimodal: Optional[bool] = None
8889
if request:
8990
ingroup_permission = request.get("ingroup_permission")
9091
group_ids = request.get("group_ids")
91-
embedding_model_name = request.get("embedding_model_name")
92+
embedding_model_name = request.get("embeddingModel")
93+
is_multimodal = request.get("is_multimodal")
9294

9395
# Treat path parameter as user-facing knowledge base name for new creations
9496
return ElasticSearchService.create_knowledge_base(
@@ -100,6 +102,7 @@ def create_new_index(
100102
ingroup_permission=ingroup_permission,
101103
group_ids=group_ids,
102104
embedding_model_name=embedding_model_name,
105+
is_multimodal=is_multimodal,
103106
)
104107
except Exception as e:
105108
raise HTTPException(
@@ -714,6 +717,7 @@ def update_chunk(
714717
chunk_request=payload,
715718
vdb_core=vdb_core,
716719
user_id=user_id,
720+
tenant_id=tenant_id,
717721
)
718722
return JSONResponse(status_code=HTTPStatus.OK, content=result)
719723
except ValueError as e:
@@ -778,8 +782,17 @@ async def hybrid_search(
778782
"""Run a hybrid (accurate + semantic) search across indices."""
779783
try:
780784
_, tenant_id = get_current_user_id(authorization)
785+
resolved_index_names: List[str] = []
786+
for requested_name in payload.index_names:
787+
try:
788+
resolved_name = get_index_name_by_knowledge_name(
789+
requested_name, tenant_id
790+
)
791+
except Exception:
792+
resolved_name = requested_name
793+
resolved_index_names.append(resolved_name)
781794
result = ElasticSearchService.search_hybrid(
782-
index_names=payload.index_names,
795+
index_names=resolved_index_names,
783796
query=payload.query,
784797
tenant_id=tenant_id,
785798
top_k=payload.top_k,

backend/consts/const.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class VectorDatabaseType(str, Enum):
3131
# Data Processing Service Configuration
3232
DATA_PROCESS_SERVICE = os.getenv("DATA_PROCESS_SERVICE")
3333
CLIP_MODEL_PATH = os.getenv("CLIP_MODEL_PATH")
34+
TABLE_TRANSFORMER_MODEL_PATH = os.getenv("TABLE_TRANSFORMER_MODEL_PATH")
35+
UNSTRUCTURED_DEFAULT_MODEL_INITIALIZE_PARAMS_JSON_PATH = os.getenv(
36+
"UNSTRUCTURED_DEFAULT_MODEL_INITIALIZE_PARAMS_JSON_PATH"
37+
)
3438

3539

3640
# Upload Configuration
@@ -151,6 +155,7 @@ class VectorDatabaseType(str, Enum):
151155
MINIO_SECRET_KEY = os.getenv("MINIO_SECRET_KEY")
152156
MINIO_REGION = os.getenv("MINIO_REGION")
153157
MINIO_DEFAULT_BUCKET = os.getenv("MINIO_DEFAULT_BUCKET")
158+
S3_URL_PREFIX = "s3://"
154159

155160

156161
# Postgres Configuration

backend/consts/model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ class ProcessParams(BaseModel):
338338
source_type: str
339339
index_name: str
340340
authorization: Optional[str] = None
341+
model_id: Optional[int] = None
341342

342343

343344
class OpinionRequest(BaseModel):
@@ -679,6 +680,8 @@ class MCPUpdateRequest(BaseModel):
679680
new_mcp_url: str = Field(..., description="New MCP server URL")
680681
new_authorization_token: Optional[str] = Field(
681682
None, description="New authorization token for MCP server authentication (e.g., Bearer token)")
683+
custom_headers: Optional[Dict[str, Any]] = Field(
684+
None, description="Custom HTTP headers as JSON object")
682685

683686

684687
# Tenant Management Data Models
@@ -1118,6 +1121,7 @@ class AddMcpServiceRequest(BaseModel):
11181121
source: MCPSourceType = Field(default=MCPSourceType.LOCAL, description="MCP source type")
11191122
tags: List[str] = Field(default_factory=list, description="MCP tags")
11201123
authorization_token: Optional[str] = Field(None, description="Authorization token for MCP server")
1124+
custom_headers: Optional[Dict[str, Any]] = Field(None, description="Custom HTTP headers as JSON object")
11211125
container_config: Optional[Dict[str, Any]] = Field(None, description="Container configuration")
11221126
registry_json: Optional[Dict[str, Any]] = Field(None, description="Registry metadata JSON")
11231127
enabled: Optional[bool] = Field(default=False, description="Whether the MCP is enabled after creation")
@@ -1157,6 +1161,7 @@ class UpdateMcpServiceRequest(BaseModel):
11571161
server_url: str = Field(..., min_length=1, description="New MCP server URL")
11581162
tags: List[str] = Field(default_factory=list, description="MCP tags")
11591163
authorization_token: Optional[str] = Field(None, description="Authorization token for MCP server")
1164+
custom_headers: Optional[Dict[str, Any]] = Field(None, description="Custom HTTP headers as JSON object")
11601165

11611166
@field_validator("name", "server_url", "description", "authorization_token", mode="before")
11621167
@classmethod

0 commit comments

Comments
 (0)