Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ ignore = [
"E722", # bare-except
"F821", # undefined-name
"F841", # unused-variable
"FURB113", # repeated-append
"UP007", # non-pep604-annotation
"UP032", # f-string
"B007", # unused-loop-control-variable
Expand Down
56 changes: 28 additions & 28 deletions api/clients/agent_backend/request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,21 @@ def build_for_agent_app(self, run_input: AgentBackendAgentAppRunInput) -> Create

include_shell = run_input.include_shell or run_input.config_layer_config is not None
if include_shell:
layers.append(
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
layers.extend(
[
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
),
),
)
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
layers.append(
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
),
]
)

if run_input.config_layer_config is not None:
Expand Down Expand Up @@ -422,21 +422,21 @@ def build_for_workflow_node(self, run_input: AgentBackendWorkflowNodeRunInput) -

include_shell = run_input.include_shell or run_input.config_layer_config is not None
if include_shell:
layers.append(
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
layers.extend(
[
RunLayerSpec(
name=DIFY_RUNTIME_LAYER_ID,
config=(DifyRuntimeLayerConfig(backend_binding_ref=run_input.backend_binding_ref)).model_dump(
mode="json"
),
),
)
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
layers.append(
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
)
# Sandboxed bash workspace (dify.shell). It enters before config so
# eager pulls materialize content in the same filesystem used by model commands.
RunLayerSpec(
name=DIFY_SHELL_LAYER_ID,
config=(run_input.shell_config or DifyShellLayerConfig()).model_dump(mode="json"),
),
]
)

if run_input.config_layer_config is not None:
Expand Down
27 changes: 16 additions & 11 deletions api/core/mcp/auth/auth_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,25 @@ def build_oauth_authorization_server_metadata_discovery_urls(auth_server_url: st
base = f"{parsed.scheme}://{parsed.netloc}"
path = parsed.path.rstrip("/")
# OAuth 2.0 Authorization Server Metadata at root (MCP-03-26)
urls.append(f"{base}/.well-known/oauth-authorization-server")

# OpenID Connect Discovery at root
urls.append(f"{base}/.well-known/openid-configuration")
urls.extend(
[
f"{base}/.well-known/oauth-authorization-server",
# OpenID Connect Discovery at root
f"{base}/.well-known/openid-configuration",
]
)

if path:
# OpenID Connect Discovery with path insertion
urls.append(f"{base}/.well-known/openid-configuration{path}")

# OpenID Connect Discovery path appending
urls.append(f"{base}{path}/.well-known/openid-configuration")

# OAuth 2.0 Authorization Server Metadata with path insertion
urls.append(f"{base}/.well-known/oauth-authorization-server{path}")
urls.extend(
[
f"{base}/.well-known/openid-configuration{path}",
# OpenID Connect Discovery path appending
f"{base}{path}/.well-known/openid-configuration",
# OAuth 2.0 Authorization Server Metadata with path insertion
f"{base}/.well-known/oauth-authorization-server{path}",
]
)

return urls

Expand Down
3 changes: 1 addition & 2 deletions api/core/rag/extractor/word_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ def _table_to_markdown(self, table, image_map):

header_row = table.rows[0]
headers = self._parse_row(header_row, image_map, total_cols)
markdown.append("| " + " | ".join(headers) + " |")
markdown.append("| " + " | ".join(["---"] * total_cols) + " |")
markdown.extend(("| " + " | ".join(headers) + " |", "| " + " | ".join(["---"] * total_cols) + " |"))

for row in table.rows[1:]:
row_cells = self._parse_row(row, image_map, total_cols)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ def _build_workflow_context_prompt(
lines.append(f"- User query: {query}")

if uploaded_files is not None:
lines.append("- Uploaded workflow files:")
lines.append(f" - sys.files: {uploaded_files}")
lines.extend(("- Uploaded workflow files:", f" - sys.files: {uploaded_files}"))

if resolved_outputs:
lines.append("- Previous node outputs:")
Expand Down
3 changes: 1 addition & 2 deletions api/extensions/ext_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ def __call__(self, *args: object, **kwargs: object) -> object:
"schedule": timedelta(minutes=dify_config.HUMAN_INPUT_TIMEOUT_TASK_INTERVAL),
}
if dify_config.ENABLE_CHECK_UPGRADABLE_PLUGIN_TASK and dify_config.MARKETPLACE_ENABLED:
imports.append("schedule.check_upgradable_plugin_task")
imports.append("tasks.process_tenant_plugin_autoupgrade_check_task")
imports.extend(("schedule.check_upgradable_plugin_task", "tasks.process_tenant_plugin_autoupgrade_check_task"))
beat_schedule["check_upgradable_plugin_task"] = {
"task": "schedule.check_upgradable_plugin_task.check_upgradable_plugin_task",
"schedule": crontab(minute="*/15"),
Expand Down
42 changes: 8 additions & 34 deletions api/models/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,40 +255,14 @@ def build_doc_metadata(self, dataset_metadatas: "Sequence[DatasetMetadata]") ->
for dataset_metadata in dataset_metadatas
]
if self.built_in_field_enabled:
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.document_name,
"type": "string",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.uploader,
"type": "string",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.upload_date,
"type": "time",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.last_update_date,
"type": "time",
}
)
doc_metadata.append(
{
"id": "built-in",
"name": BuiltInField.source,
"type": "string",
}
doc_metadata.extend(
(
{"id": "built-in", "name": BuiltInField.document_name, "type": "string"},
{"id": "built-in", "name": BuiltInField.uploader, "type": "string"},
{"id": "built-in", "name": BuiltInField.upload_date, "type": "time"},
{"id": "built-in", "name": BuiltInField.last_update_date, "type": "time"},
{"id": "built-in", "name": BuiltInField.source, "type": "string"},
)
)
return doc_metadata

Expand Down
63 changes: 32 additions & 31 deletions api/providers/vdb/vdb-baidu/src/dify_vdb_baidu/baidu_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,43 +275,44 @@ def _create_table(self, dimension: int):

# Construct field schema
fields = []
fields.append(
Field(
VDBField.PRIMARY_KEY,
FieldType.STRING,
primary_key=True,
partition_key=True,
auto_increment=False,
not_null=True,
fields.extend(
(
Field(
VDBField.PRIMARY_KEY,
FieldType.STRING,
primary_key=True,
partition_key=True,
auto_increment=False,
not_null=True,
),
Field(VDBField.CONTENT_KEY, FieldType.TEXT, not_null=False),
Field(VDBField.METADATA_KEY, FieldType.JSON, not_null=False),
Field(VDBField.VECTOR, FieldType.FLOAT_VECTOR, not_null=True, dimension=dimension),
)
)
fields.append(Field(VDBField.CONTENT_KEY, FieldType.TEXT, not_null=False))
fields.append(Field(VDBField.METADATA_KEY, FieldType.JSON, not_null=False))
fields.append(Field(VDBField.VECTOR, FieldType.FLOAT_VECTOR, not_null=True, dimension=dimension))

# Construct vector index params
indexes = []
indexes.append(
VectorIndex(
index_name=self.vector_index,
index_type=index_type,
field=VDBField.VECTOR,
metric_type=metric_type,
params=HNSWParams(m=16, efconstruction=200),
auto_build=True,
auto_build_index_policy=AutoBuildRowCountIncrement(
row_count_increment=self._client_config.auto_build_row_count_increment,
row_count_increment_ratio=self._client_config.auto_build_row_count_increment_ratio,
indexes.extend(
[
VectorIndex(
index_name=self.vector_index,
index_type=index_type,
field=VDBField.VECTOR,
metric_type=metric_type,
params=HNSWParams(m=16, efconstruction=200),
auto_build=True,
auto_build_index_policy=AutoBuildRowCountIncrement(
row_count_increment=self._client_config.auto_build_row_count_increment,
row_count_increment_ratio=self._client_config.auto_build_row_count_increment_ratio,
),
),
)
)

# Filtering index
indexes.append(
FilteringIndex(
index_name=self.filtering_index,
fields=[VDBField.METADATA_KEY],
)
# Filtering index
FilteringIndex(
index_name=self.filtering_index,
fields=[VDBField.METADATA_KEY],
),
]
)

# Get analyzer and parse_mode from config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ def _bulk_with_retry(actions):
action_header["index"]["routing"] = self._routing
action_values[ROUTING_FIELD] = self._routing

actions.append(action_header)
actions.append(action_values)
actions.extend((action_header, action_values))

try:
_bulk_with_retry(actions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,15 @@ def create_collection(
):
content_field_kwargs["analyzer_params"] = self._client_config.analyzer_params

fields.append(FieldSchema(Field.CONTENT_KEY, DataType.VARCHAR, **content_field_kwargs))

# Create the primary key field
fields.append(FieldSchema(Field.PRIMARY_KEY, DataType.INT64, is_primary=True, auto_id=True))
# Create the vector field, supports binary or float vectors
fields.append(FieldSchema(Field.VECTOR, infer_dtype_bydata(embeddings[0]), dim=dim))
fields.extend(
[
FieldSchema(Field.CONTENT_KEY, DataType.VARCHAR, **content_field_kwargs),
# Create the primary key field
FieldSchema(Field.PRIMARY_KEY, DataType.INT64, is_primary=True, auto_id=True),
# Create the vector field, supports binary or float vectors
FieldSchema(Field.VECTOR, infer_dtype_bydata(embeddings[0]), dim=dim),
]
)
# Create Sparse Vector Index for the collection
if self._hybrid_search_enabled:
fields.append(FieldSchema(Field.SPARSE_VECTOR, DataType.SPARSE_FLOAT_VECTOR))
Expand Down
50 changes: 23 additions & 27 deletions api/services/knowledge/dataset_read_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,33 +252,29 @@ def get_document_built_in_fields(document: Document, *, session: Session) -> lis

def format_document_built_in_fields(document: Document, *, uploader_name: str | None) -> list[DocMetadataDetailItem]:
built_in_fields: list[DocMetadataDetailItem] = []
built_in_fields.append(
{"id": "built-in", "name": BuiltInField.document_name, "type": "string", "value": document.name}
)
built_in_fields.append({"id": "built-in", "name": BuiltInField.uploader, "type": "string", "value": uploader_name})
built_in_fields.append(
{
"id": "built-in",
"name": BuiltInField.upload_date,
"type": "time",
"value": str(document.created_at.timestamp()),
}
)
built_in_fields.append(
{
"id": "built-in",
"name": BuiltInField.last_update_date,
"type": "time",
"value": str(document.updated_at.timestamp()),
}
)
built_in_fields.append(
{
"id": "built-in",
"name": BuiltInField.source,
"type": "string",
"value": MetadataDataSource[document.data_source_type],
}
built_in_fields.extend(
(
{"id": "built-in", "name": BuiltInField.document_name, "type": "string", "value": document.name},
{"id": "built-in", "name": BuiltInField.uploader, "type": "string", "value": uploader_name},
{
"id": "built-in",
"name": BuiltInField.upload_date,
"type": "time",
"value": str(document.created_at.timestamp()),
},
{
"id": "built-in",
"name": BuiltInField.last_update_date,
"type": "time",
"value": str(document.updated_at.timestamp()),
},
{
"id": "built-in",
"name": BuiltInField.source,
"type": "string",
"value": MetadataDataSource[document.data_source_type],
},
)
)
return built_in_fields

Expand Down
Loading
Loading