chore: apply ruff E501 line-too-long linter rule (#8275)

Co-authored-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
Bowen Liang
2024-09-12 14:00:36 +08:00
committed by GitHub
parent 56c90e212a
commit c69f5b07ba
85 changed files with 459 additions and 324 deletions

View File

@@ -179,7 +179,8 @@ class CodeNode(BaseNode):
)
else:
raise ValueError(
f"Output {prefix}.{output_name} is not a valid array. make sure all elements are of the same type."
f"Output {prefix}.{output_name} is not a valid array."
f" make sure all elements are of the same type."
)
elif isinstance(output_value, type(None)):
pass
@@ -201,7 +202,8 @@ class CodeNode(BaseNode):
transformed_result[output_name] = None
else:
raise ValueError(
f"Output {prefix}{dot}{output_name} is not an object, got {type(result.get(output_name))} instead."
f"Output {prefix}{dot}{output_name} is not an object,"
f" got {type(result.get(output_name))} instead."
)
else:
transformed_result[output_name] = self._transform_result(
@@ -228,7 +230,8 @@ class CodeNode(BaseNode):
transformed_result[output_name] = None
else:
raise ValueError(
f"Output {prefix}{dot}{output_name} is not an array, got {type(result.get(output_name))} instead."
f"Output {prefix}{dot}{output_name} is not an array,"
f" got {type(result.get(output_name))} instead."
)
else:
if len(result[output_name]) > dify_config.CODE_MAX_NUMBER_ARRAY_LENGTH:
@@ -248,7 +251,8 @@ class CodeNode(BaseNode):
transformed_result[output_name] = None
else:
raise ValueError(
f"Output {prefix}{dot}{output_name} is not an array, got {type(result.get(output_name))} instead."
f"Output {prefix}{dot}{output_name} is not an array,"
f" got {type(result.get(output_name))} instead."
)
else:
if len(result[output_name]) > dify_config.CODE_MAX_STRING_ARRAY_LENGTH:
@@ -268,7 +272,8 @@ class CodeNode(BaseNode):
transformed_result[output_name] = None
else:
raise ValueError(
f"Output {prefix}{dot}{output_name} is not an array, got {type(result.get(output_name))} instead."
f"Output {prefix}{dot}{output_name} is not an array,"
f" got {type(result.get(output_name))} instead."
)
else:
if len(result[output_name]) > dify_config.CODE_MAX_OBJECT_ARRAY_LENGTH:
@@ -283,7 +288,8 @@ class CodeNode(BaseNode):
pass
else:
raise ValueError(
f"Output {prefix}{dot}{output_name}[{i}] is not an object, got {type(value)} instead at index {i}."
f"Output {prefix}{dot}{output_name}[{i}] is not an object,"
f" got {type(value)} instead at index {i}."
)
transformed_result[output_name] = [

View File

@@ -128,11 +128,12 @@ class KnowledgeRetrievalNode(BaseNode):
weights = None
elif node_data.multiple_retrieval_config.reranking_mode == "weighted_score":
reranking_model = None
vector_setting = node_data.multiple_retrieval_config.weights.vector_setting
weights = {
"vector_setting": {
"vector_weight": node_data.multiple_retrieval_config.weights.vector_setting.vector_weight,
"embedding_provider_name": node_data.multiple_retrieval_config.weights.vector_setting.embedding_provider_name,
"embedding_model_name": node_data.multiple_retrieval_config.weights.vector_setting.embedding_model_name,
"vector_weight": vector_setting.vector_weight,
"embedding_provider_name": vector_setting.embedding_provider_name,
"embedding_model_name": vector_setting.embedding_model_name,
},
"keyword_setting": {
"keyword_weight": node_data.multiple_retrieval_config.weights.keyword_setting.keyword_weight

View File

@@ -23,7 +23,7 @@ Steps:
To illustrate, if the task involves extracting a user's name and their request, your function call might look like this: Ensure your output follows a similar structure to examples.
### Final Output
Produce well-formatted function calls in json without XML tags, as shown in the example.
"""
""" # noqa: E501
FUNCTION_CALLING_EXTRACTOR_USER_TEMPLATE = f"""extract structured information from context inside <context></context> XML tags by calling the function {FUNCTION_CALLING_EXTRACTOR_NAME} with the correct parameters with structure inside <structure></structure> XML tags.
<context>
@@ -33,7 +33,7 @@ FUNCTION_CALLING_EXTRACTOR_USER_TEMPLATE = f"""extract structured information fr
<structure>
\x7bstructure\x7d
</structure>
"""
""" # noqa: E501
FUNCTION_CALLING_EXTRACTOR_EXAMPLE = [
{
@@ -55,7 +55,8 @@ FUNCTION_CALLING_EXTRACTOR_EXAMPLE = [
},
},
"assistant": {
"text": "I need always call the function with the correct parameters. in this case, I need to call the function with the location parameter.",
"text": "I need always call the function with the correct parameters."
" in this case, I need to call the function with the location parameter.",
"function_call": {"name": FUNCTION_CALLING_EXTRACTOR_NAME, "parameters": {"location": "San Francisco"}},
},
},
@@ -72,7 +73,8 @@ FUNCTION_CALLING_EXTRACTOR_EXAMPLE = [
},
},
"assistant": {
"text": "I need always call the function with the correct parameters. in this case, I need to call the function with the food parameter.",
"text": "I need always call the function with the correct parameters."
" in this case, I need to call the function with the food parameter.",
"function_call": {"name": FUNCTION_CALLING_EXTRACTOR_NAME, "parameters": {"food": "apple pie"}},
},
},
@@ -117,7 +119,7 @@ Inside <text></text> XML tags, there is a text that I should extract parameters
### Answer
I should always output a valid JSON object. Output nothing other than the JSON object.
```JSON
"""
""" # noqa: E501
CHAT_GENERATE_JSON_PROMPT = """You should always follow the instructions and output a valid JSON object.
The structure of the JSON object you can found in the instructions.

View File

@@ -12,13 +12,13 @@ QUESTION_CLASSIFIER_SYSTEM_PROMPT = """
<histories>
{histories}
</histories>
"""
""" # noqa: E501
QUESTION_CLASSIFIER_USER_PROMPT_1 = """
{ "input_text": ["I recently had a great experience with your company. The service was prompt and the staff was very friendly."],
"categories": [{"category_id":"f5660049-284f-41a7-b301-fd24176a711c","category_name":"Customer Service"},{"category_id":"8d007d06-f2c9-4be5-8ff6-cd4381c13c60","category_name":"Satisfaction"},{"category_id":"5fbbbb18-9843-466d-9b8e-b9bfbb9482c8","category_name":"Sales"},{"category_id":"23623c75-7184-4a2e-8226-466c2e4631e4","category_name":"Product"}],
"classification_instructions": ["classify the text based on the feedback provided by customer"]}
"""
""" # noqa: E501
QUESTION_CLASSIFIER_ASSISTANT_PROMPT_1 = """
```json
@@ -32,7 +32,7 @@ QUESTION_CLASSIFIER_USER_PROMPT_2 = """
{"input_text": ["bad service, slow to bring the food"],
"categories": [{"category_id":"80fb86a0-4454-4bf5-924c-f253fdd83c02","category_name":"Food Quality"},{"category_id":"f6ff5bc3-aca0-4e4a-8627-e760d0aca78f","category_name":"Experience"},{"category_id":"cc771f63-74e7-4c61-882e-3eda9d8ba5d7","category_name":"Price"}],
"classification_instructions": []}
"""
""" # noqa: E501
QUESTION_CLASSIFIER_ASSISTANT_PROMPT_2 = """
```json
@@ -73,4 +73,4 @@ Here is the chat histories between human and assistant, inside <histories></hist
### User Input
{{"input_text" : ["{input_text}"], "categories" : {categories},"classification_instruction" : ["{classification_instructions}"]}}
### Assistant Output
"""
""" # noqa: E501