mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-11 13:49:03 +08:00
Remove dead code (#17899)
This commit is contained in:
parent
08a693a0a0
commit
5d72003ebb
@ -21,12 +21,6 @@ def _validate_name(name):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
def _validate_description_length(description):
|
|
||||||
if description and len(description) > 400:
|
|
||||||
raise ValueError("Description cannot exceed 400 characters.")
|
|
||||||
return description
|
|
||||||
|
|
||||||
|
|
||||||
class ExternalApiTemplateListApi(Resource):
|
class ExternalApiTemplateListApi(Resource):
|
||||||
@setup_required
|
@setup_required
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -14,18 +14,6 @@ from services.entities.knowledge_entities.knowledge_entities import (
|
|||||||
from services.metadata_service import MetadataService
|
from services.metadata_service import MetadataService
|
||||||
|
|
||||||
|
|
||||||
def _validate_name(name):
|
|
||||||
if not name or len(name) < 1 or len(name) > 40:
|
|
||||||
raise ValueError("Name must be between 1 to 40 characters.")
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
def _validate_description_length(description):
|
|
||||||
if len(description) > 400:
|
|
||||||
raise ValueError("Description cannot exceed 400 characters.")
|
|
||||||
return description
|
|
||||||
|
|
||||||
|
|
||||||
class DatasetMetadataCreateApi(Resource):
|
class DatasetMetadataCreateApi(Resource):
|
||||||
@setup_required
|
@setup_required
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -286,8 +286,6 @@ class AccountDeleteApi(Resource):
|
|||||||
class AccountDeleteUpdateFeedbackApi(Resource):
|
class AccountDeleteUpdateFeedbackApi(Resource):
|
||||||
@setup_required
|
@setup_required
|
||||||
def post(self):
|
def post(self):
|
||||||
account = current_user
|
|
||||||
|
|
||||||
parser = reqparse.RequestParser()
|
parser = reqparse.RequestParser()
|
||||||
parser.add_argument("email", type=str, required=True, location="json")
|
parser.add_argument("email", type=str, required=True, location="json")
|
||||||
parser.add_argument("feedback", type=str, required=True, location="json")
|
parser.add_argument("feedback", type=str, required=True, location="json")
|
||||||
|
@ -13,18 +13,6 @@ from services.entities.knowledge_entities.knowledge_entities import (
|
|||||||
from services.metadata_service import MetadataService
|
from services.metadata_service import MetadataService
|
||||||
|
|
||||||
|
|
||||||
def _validate_name(name):
|
|
||||||
if not name or len(name) < 1 or len(name) > 40:
|
|
||||||
raise ValueError("Name must be between 1 to 40 characters.")
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
def _validate_description_length(description):
|
|
||||||
if len(description) > 400:
|
|
||||||
raise ValueError("Description cannot exceed 400 characters.")
|
|
||||||
return description
|
|
||||||
|
|
||||||
|
|
||||||
class DatasetMetadataCreateServiceApi(DatasetApiResource):
|
class DatasetMetadataCreateServiceApi(DatasetApiResource):
|
||||||
def post(self, tenant_id, dataset_id):
|
def post(self, tenant_id, dataset_id):
|
||||||
parser = reqparse.RequestParser()
|
parser = reqparse.RequestParser()
|
||||||
|
@ -117,9 +117,6 @@ class SegmentApi(DatasetApiResource):
|
|||||||
parser.add_argument("keyword", type=str, default=None, location="args")
|
parser.add_argument("keyword", type=str, default=None, location="args")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
status_list = args["status"]
|
|
||||||
keyword = args["keyword"]
|
|
||||||
|
|
||||||
segments, total = SegmentService.get_segments(
|
segments, total = SegmentService.get_segments(
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
tenant_id=current_user.current_tenant_id,
|
tenant_id=current_user.current_tenant_id,
|
||||||
|
@ -228,7 +228,7 @@ class OracleVector(BaseVector):
|
|||||||
|
|
||||||
top_k = kwargs.get("top_k", 5)
|
top_k = kwargs.get("top_k", 5)
|
||||||
# just not implement fetch by score_threshold now, may be later
|
# just not implement fetch by score_threshold now, may be later
|
||||||
score_threshold = float(kwargs.get("score_threshold") or 0.0)
|
# score_threshold = float(kwargs.get("score_threshold") or 0.0)
|
||||||
if len(query) > 0:
|
if len(query) > 0:
|
||||||
# Check which language the query is in
|
# Check which language the query is in
|
||||||
zh_pattern = re.compile("[\u4e00-\u9fa5]+")
|
zh_pattern = re.compile("[\u4e00-\u9fa5]+")
|
||||||
|
@ -65,8 +65,6 @@ class RelytVector(BaseVector):
|
|||||||
return VectorType.RELYT
|
return VectorType.RELYT
|
||||||
|
|
||||||
def create(self, texts: list[Document], embeddings: list[list[float]], **kwargs) -> None:
|
def create(self, texts: list[Document], embeddings: list[list[float]], **kwargs) -> None:
|
||||||
index_params: dict[str, Any] = {}
|
|
||||||
metadatas = [d.metadata for d in texts]
|
|
||||||
self.create_collection(len(embeddings[0]))
|
self.create_collection(len(embeddings[0]))
|
||||||
self.embedding_dimension = len(embeddings[0])
|
self.embedding_dimension = len(embeddings[0])
|
||||||
self.add_texts(texts, embeddings)
|
self.add_texts(texts, embeddings)
|
||||||
|
@ -187,7 +187,6 @@ class TiDBVector(BaseVector):
|
|||||||
def search_by_vector(self, query_vector: list[float], **kwargs: Any) -> list[Document]:
|
def search_by_vector(self, query_vector: list[float], **kwargs: Any) -> list[Document]:
|
||||||
top_k = kwargs.get("top_k", 4)
|
top_k = kwargs.get("top_k", 4)
|
||||||
score_threshold = float(kwargs.get("score_threshold") or 0.0)
|
score_threshold = float(kwargs.get("score_threshold") or 0.0)
|
||||||
filter = kwargs.get("filter")
|
|
||||||
distance = 1 - score_threshold
|
distance = 1 - score_threshold
|
||||||
|
|
||||||
query_vector_str = ", ".join(format(x) for x in query_vector)
|
query_vector_str = ", ".join(format(x) for x in query_vector)
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from core.workflow.graph_engine.entities.graph import GraphParallel
|
|
||||||
|
|
||||||
|
|
||||||
class NextGraphNode(BaseModel):
|
|
||||||
node_id: str
|
|
||||||
"""next node id"""
|
|
||||||
|
|
||||||
parallel: Optional[GraphParallel] = None
|
|
||||||
"""parallel"""
|
|
@ -597,7 +597,6 @@ class KnowledgeRetrievalNode(LLMNode):
|
|||||||
def _get_prompt_template(self, node_data: KnowledgeRetrievalNodeData, metadata_fields: list, query: str):
|
def _get_prompt_template(self, node_data: KnowledgeRetrievalNodeData, metadata_fields: list, query: str):
|
||||||
model_mode = ModelMode.value_of(node_data.metadata_model_config.mode) # type: ignore
|
model_mode = ModelMode.value_of(node_data.metadata_model_config.mode) # type: ignore
|
||||||
input_text = query
|
input_text = query
|
||||||
memory_str = ""
|
|
||||||
|
|
||||||
prompt_messages: list[LLMNodeChatModelMessage] = []
|
prompt_messages: list[LLMNodeChatModelMessage] = []
|
||||||
if model_mode == ModelMode.CHAT:
|
if model_mode == ModelMode.CHAT:
|
||||||
|
@ -8,7 +8,6 @@ from models.provider import Provider
|
|||||||
|
|
||||||
@message_was_created.connect
|
@message_was_created.connect
|
||||||
def handle(sender, **kwargs):
|
def handle(sender, **kwargs):
|
||||||
message = sender
|
|
||||||
application_generate_entity = kwargs.get("application_generate_entity")
|
application_generate_entity = kwargs.get("application_generate_entity")
|
||||||
|
|
||||||
if not isinstance(application_generate_entity, ChatAppGenerateEntity | AgentChatAppGenerateEntity):
|
if not isinstance(application_generate_entity, ChatAppGenerateEntity | AgentChatAppGenerateEntity):
|
||||||
|
@ -571,10 +571,6 @@ class AccountService:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _get_login_cache_key(*, account_id: str, token: str):
|
|
||||||
return f"account_login:{account_id}:{token}"
|
|
||||||
|
|
||||||
|
|
||||||
class TenantService:
|
class TenantService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_tenant(name: str, is_setup: Optional[bool] = False, is_from_dashboard: Optional[bool] = False) -> Tenant:
|
def create_tenant(name: str, is_setup: Optional[bool] = False, is_from_dashboard: Optional[bool] = False) -> Tenant:
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
|
import psycopg2 # type: ignore
|
||||||
|
|
||||||
from core.rag.datasource.vdb.opengauss.opengauss import OpenGauss, OpenGaussConfig
|
from core.rag.datasource.vdb.opengauss.opengauss import OpenGauss, OpenGaussConfig
|
||||||
from tests.integration_tests.vdb.test_vector_store import (
|
from tests.integration_tests.vdb.test_vector_store import (
|
||||||
AbstractVectorTest,
|
AbstractVectorTest,
|
||||||
|
@ -425,8 +425,8 @@ def test_multi_colons_parse(setup_http_mock):
|
|||||||
result = node._run()
|
result = node._run()
|
||||||
assert result.process_data is not None
|
assert result.process_data is not None
|
||||||
assert result.outputs is not None
|
assert result.outputs is not None
|
||||||
resp = result.outputs
|
|
||||||
|
|
||||||
assert urlencode({"Redirect": "http://example2.com"}) in result.process_data.get("request", "")
|
assert urlencode({"Redirect": "http://example2.com"}) in result.process_data.get("request", "")
|
||||||
assert 'form-data; name="Redirect"\r\n\r\nhttp://example6.com' in result.process_data.get("request", "")
|
assert 'form-data; name="Redirect"\r\n\r\nhttp://example6.com' in result.process_data.get("request", "")
|
||||||
|
# resp = result.outputs
|
||||||
# assert "http://example3.com" == resp.get("headers", {}).get("referer")
|
# assert "http://example3.com" == resp.get("headers", {}).get("referer")
|
||||||
|
@ -46,13 +46,6 @@ def test_retry_default_value_partial_success():
|
|||||||
|
|
||||||
def test_retry_failed():
|
def test_retry_failed():
|
||||||
"""retry failed with success status"""
|
"""retry failed with success status"""
|
||||||
error_code = """
|
|
||||||
def main() -> dict:
|
|
||||||
return {
|
|
||||||
"result": 1 / 0,
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|
||||||
graph_config = {
|
graph_config = {
|
||||||
"edges": DEFAULT_VALUE_EDGE,
|
"edges": DEFAULT_VALUE_EDGE,
|
||||||
"nodes": [
|
"nodes": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user