Skip to content

Commit

Permalink
Merge branch 'fix/chore-fix' into dev/plugin-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Dec 6, 2024
2 parents fbcd4fe + 337eff2 commit 1ce7990
Show file tree
Hide file tree
Showing 85 changed files with 1,845 additions and 1,203 deletions.
13 changes: 3 additions & 10 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@ Please include a summary of the change and which issue is fixed. Please also inc

# Screenshots

<table>
<tr>
<td>Before: </td>
<td>After: </td>
</tr>
<tr>
<td>...</td>
<td>...</td>
</tr>
</table>
| Before | After |
|--------|-------|
| ... | ... |

# Checklist

Expand Down
8 changes: 4 additions & 4 deletions api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ def migrate_knowledge_vector_database():
skipped_count = 0
total_count = 0
vector_type = dify_config.VECTOR_STORE
upper_colletion_vector_types = {
upper_collection_vector_types = {
VectorType.MILVUS,
VectorType.PGVECTOR,
VectorType.RELYT,
VectorType.WEAVIATE,
VectorType.ORACLE,
VectorType.ELASTICSEARCH,
}
lower_colletion_vector_types = {
lower_collection_vector_types = {
VectorType.ANALYTICDB,
VectorType.CHROMA,
VectorType.MYSCALE,
Expand Down Expand Up @@ -308,7 +308,7 @@ def migrate_knowledge_vector_database():
continue
collection_name = ""
dataset_id = dataset.id
if vector_type in upper_colletion_vector_types:
if vector_type in upper_collection_vector_types:
collection_name = Dataset.gen_collection_name_by_id(dataset_id)
elif vector_type == VectorType.QDRANT:
if dataset.collection_binding_id:
Expand All @@ -324,7 +324,7 @@ def migrate_knowledge_vector_database():
else:
collection_name = Dataset.gen_collection_name_by_id(dataset_id)

elif vector_type in lower_colletion_vector_types:
elif vector_type in lower_collection_vector_types:
collection_name = Dataset.gen_collection_name_by_id(dataset_id).lower()
else:
raise ValueError(f"Vector store {vector_type} is not supported.")
Expand Down
2 changes: 1 addition & 1 deletion api/configs/packaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PackagingInfo(BaseSettings):

CURRENT_VERSION: str = Field(
description="Dify version",
default="0.13.0",
default="0.13.1",
)

COMMIT_SHA: str = Field(
Expand Down
2 changes: 1 addition & 1 deletion api/core/app/apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Due to the presence of tasks in App Runner that require long execution times, such as LLM generation and external requests, Flask-Sqlalchemy's strategy for database connection pooling is to allocate one connection (transaction) per request. This approach keeps a connection occupied even during non-DB tasks, leading to the inability to acquire new connections during high concurrency requests due to multiple long-running tasks.

Therefore, the database operations in App Runner and Task Pipeline must ensure connections are closed immediately after use, and it's better to pass IDs rather than Model objects to avoid deattach errors.
Therefore, the database operations in App Runner and Task Pipeline must ensure connections are closed immediately after use, and it's better to pass IDs rather than Model objects to avoid detach errors.

Examples:

Expand Down
2 changes: 1 addition & 1 deletion api/core/app/apps/base_app_generate_response_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _get_simple_metadata(cls, metadata: dict[str, Any]):
for resource in metadata["retriever_resources"]:
updated_resources.append(
{
"segment_id": resource["segment_id"],
"segment_id": resource.get("segment_id", ""),
"position": resource["position"],
"document_name": resource["document_name"],
"score": resource["score"],
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_runtime/docs/zh_Hans/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class XinferenceProvider(Provider):
"""
```

也可以直接抛出对应Erros,并做如下定义,这样在之后的调用中可以直接抛出`InvokeConnectionError`等异常。
也可以直接抛出对应 Errors,并做如下定义,这样在之后的调用中可以直接抛出`InvokeConnectionError`等异常。

```python
@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
CHAT_APP_COMPLETION_PROMPT_CONFIG = {
"completion_prompt_config": {
"prompt": {
"text": "{{#pre_prompt#}}\nHere is the chat histories between human and assistant, inside <histories></histories> XML tags.\n\n<histories>\n{{#histories#}}\n</histories>\n\n\nHuman: {{#query#}}\n\nAssistant: " # noqa: E501
"text": "{{#pre_prompt#}}\nHere are the chat histories between human and assistant, inside <histories></histories> XML tags.\n\n<histories>\n{{#histories#}}\n</histories>\n\n\nHuman: {{#query#}}\n\nAssistant: " # noqa: E501
},
"conversation_histories_role": {"user_prefix": "Human", "assistant_prefix": "Assistant"},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ def search_by_full_text(self, query: str, **kwargs: Any) -> list[Document]:
for result in results:
if result:
document = self._document_from_scored_point(result, Field.CONTENT_KEY.value, Field.METADATA_KEY.value)
document.metadata["vector"] = result.vector
documents.append(document)

return documents
Expand All @@ -394,6 +393,7 @@ def _document_from_scored_point(
) -> Document:
return Document(
page_content=scored_point.payload.get(content_payload_key),
vector=scored_point.vector,
metadata=scored_point.payload.get(metadata_payload_key) or {},
)

Expand Down
10 changes: 5 additions & 5 deletions api/core/workflow/nodes/if_else/if_else_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _run(self) -> NodeRunResult:
"""
node_inputs: dict[str, list] = {"conditions": []}

process_datas: dict[str, list] = {"condition_results": []}
process_data: dict[str, list] = {"condition_results": []}

input_conditions = []
final_result = False
Expand All @@ -40,7 +40,7 @@ def _run(self) -> NodeRunResult:
operator=case.logical_operator,
)

process_datas["condition_results"].append(
process_data["condition_results"].append(
{
"group": case.model_dump(),
"results": group_result,
Expand All @@ -65,23 +65,23 @@ def _run(self) -> NodeRunResult:

selected_case_id = "true" if final_result else "false"

process_datas["condition_results"].append(
process_data["condition_results"].append(
{"group": "default", "results": group_result, "final_result": final_result}
)

node_inputs["conditions"] = input_conditions

except Exception as e:
return NodeRunResult(
status=WorkflowNodeExecutionStatus.FAILED, inputs=node_inputs, process_data=process_datas, error=str(e)
status=WorkflowNodeExecutionStatus.FAILED, inputs=node_inputs, process_data=process_data, error=str(e)
)

outputs = {"result": final_result, "selected_case_id": selected_case_id}

data = NodeRunResult(
status=WorkflowNodeExecutionStatus.SUCCEEDED,
inputs=node_inputs,
process_data=process_datas,
process_data=process_data,
edge_source_handle=selected_case_id or "false", # Use case ID or 'default'
outputs=outputs,
)
Expand Down
5 changes: 2 additions & 3 deletions api/core/workflow/nodes/iteration/iteration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _run(self) -> Generator[NodeEvent | InNodeEvent, None, None]:
variable_pool.add([self.node_id, "item"], iterator_list_value[0])

# init graph engine
from core.workflow.graph_engine.graph_engine import GraphEngine
from core.workflow.graph_engine.graph_engine import GraphEngine, GraphEngineThreadPool

graph_engine = GraphEngine(
tenant_id=self.tenant_id,
Expand Down Expand Up @@ -163,8 +163,7 @@ def _run(self) -> Generator[NodeEvent | InNodeEvent, None, None]:
if self.node_data.is_parallel:
futures: list[Future] = []
q = Queue()
thread_pool = graph_engine.workflow_thread_pool_mapping[graph_engine.thread_pool_id]
thread_pool._max_workers = self.node_data.parallel_nums
thread_pool = GraphEngineThreadPool(max_workers=self.node_data.parallel_nums, max_submit_count=100)
for index, item in enumerate(iterator_list_value):
future: Future = thread_pool.submit(
self._run_single_iter_parallel,
Expand Down
2 changes: 1 addition & 1 deletion api/core/workflow/nodes/llm/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ def get_default_config(cls, filters: Optional[dict] = None) -> dict:
"completion_model": {
"conversation_histories_role": {"user_prefix": "Human", "assistant_prefix": "Assistant"},
"prompt": {
"text": "Here is the chat histories between human and assistant, inside "
"text": "Here are the chat histories between human and assistant, inside "
"<histories></histories> XML tags.\n\n<histories>\n{{"
"#histories#}}\n</histories>\n\n\nHuman: {{#sys.query#}}\n\nAssistant:",
"edition_type": "basic",
Expand Down
4 changes: 2 additions & 2 deletions api/core/workflow/nodes/parameter_extractor/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
Step 4: Ensure that the JSON object is properly formatted and valid. The output should not contain any XML tags. Only the JSON object should be outputted.
### Memory
Here is the chat histories between human and assistant, inside <histories></histories> XML tags.
Here are the chat histories between human and assistant, inside <histories></histories> XML tags.
<histories>
{histories}
</histories>
Expand All @@ -125,7 +125,7 @@
The structure of the JSON object you can found in the instructions.
### Memory
Here is the chat histories between human and assistant, inside <histories></histories> XML tags.
Here are the chat histories between human and assistant, inside <histories></histories> XML tags.
<histories>
{histories}
</histories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
### Constraint
DO NOT include anything other than the JSON array in your response.
### Memory
Here is the chat histories between human and assistant, inside <histories></histories> XML tags.
Here are the chat histories between human and assistant, inside <histories></histories> XML tags.
<histories>
{histories}
</histories>
Expand Down Expand Up @@ -66,7 +66,7 @@
Assistant:{{"keywords": ["bad service", "slow", "food", "tip", "terrible", "waitresses"],"category_id": "f6ff5bc3-aca0-4e4a-8627-e760d0aca78f","category_name": "Experience"}}
</example>
### Memory
Here is the chat histories between human and assistant, inside <histories></histories> XML tags.
Here are the chat histories between human and assistant, inside <histories></histories> XML tags.
<histories>
{histories}
</histories>
Expand Down
4 changes: 2 additions & 2 deletions api/core/workflow/nodes/variable_assigner/v2/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


class OperationNotSupportedError(VariableOperatorNodeError):
def __init__(self, *, operation: Operation, varialbe_type: str):
super().__init__(f"Operation {operation} is not supported for type {varialbe_type}")
def __init__(self, *, operation: Operation, variable_type: str):
super().__init__(f"Operation {operation} is not supported for type {variable_type}")


class InputTypeNotSupportedError(VariableOperatorNodeError):
Expand Down
4 changes: 2 additions & 2 deletions api/core/workflow/nodes/variable_assigner/v2/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _run(self) -> NodeRunResult:

# Check if operation is supported
if not helpers.is_operation_supported(variable_type=variable.value_type, operation=item.operation):
raise OperationNotSupportedError(operation=item.operation, varialbe_type=variable.value_type)
raise OperationNotSupportedError(operation=item.operation, variable_type=variable.value_type)

# Check if variable input is supported
if item.input_type == InputType.VARIABLE and not helpers.is_variable_input_supported(
Expand Down Expand Up @@ -156,4 +156,4 @@ def _handle_item(
case Operation.DIVIDE:
return variable.value / value
case _:
raise OperationNotSupportedError(operation=operation, varialbe_type=variable.value_type)
raise OperationNotSupportedError(operation=operation, variable_type=variable.value_type)
Loading

0 comments on commit 1ce7990

Please sign in to comment.