langflow-ai / langflow

⛓️ Langflow is a visual framework for building multi-agent and RAG applications. It's open-source, Python-powered, fully customizable, model and vector store agnostic.
http://www.langflow.org
MIT License
20.07k stars 2.98k forks source link

Qdrant Search when a clic on Advanced Settings #2255

Open ari-64 opened 1 week ago

ari-64 commented 1 week ago

Sorry, we found an unexpected error!

Please report errors with detailed tracebacks on the GitHub Issues page. Thank you!

Restart Langflow Report On Github

dosubot[bot] commented 1 week ago

Hello, @ari-64! I'm here to help you with any bugs, questions, or contributions you may have. Just let me know how I can assist you!

The error you're encountering when clicking on "Advanced Settings" in the Qdrant Search component might be related to the build_config method, which defines the configuration settings, including advanced settings. Here is the relevant code:

def build_config(self):
    return {
        "search_type": {
            "display_name": "Search Type",
            "options": ["Similarity", "MMR"],
        },
        "input_value": {"display_name": "Input"},
        "embedding": {"display_name": "Embedding"},
        "api_key": {"display_name": "API Key", "password": True, "advanced": True},
        "collection_name": {"display_name": "Collection Name"},
        "content_payload_key": {
            "display_name": "Content Payload Key",
            "advanced": True,
        },
        "distance_func": {"display_name": "Distance Function", "advanced": True},
        "grpc_port": {"display_name": "gRPC Port", "advanced": True},
        "host": {"display_name": "Host", "advanced": True},
        "https": {"display_name": "HTTPS", "advanced": True},
        "location": {"display_name": "Location", "advanced": True},
        "metadata_payload_key": {
            "display_name": "Metadata Payload Key",
            "advanced": True,
        },
        "path": {"display_name": "Path", "advanced": True},
        "port": {"display_name": "Port", "advanced": True},
        "prefer_grpc": {"display_name": "Prefer gRPC", "advanced": True},
        "prefix": {"display_name": "Prefix", "advanced": True},
        "search_kwargs": {"display_name": "Search Kwargs", "advanced": True},
        "timeout": {"display_name": "Timeout", "advanced": True},
        "url": {"display_name": "URL", "advanced": True},
        "number_of_results": {
            "display_name": "Number of Results",
            "info": "Number of results to return.",
            "advanced": True,
        },
    }

Additionally, the build method constructs the Qdrant wrapper from a list of texts, handling advanced settings:

def build(  # type: ignore[override]
    self,
    input_value: Text,
    embedding: Embeddings,
    collection_name: str,
    number_of_results: int = 4,
    search_type: str = "similarity",
    api_key: Optional[str] = None,
    content_payload_key: str = "page_content",
    distance_func: str = "Cosine",
    grpc_port: int = 6334,
    https: bool = False,
    host: Optional[str] = None,
    location: Optional[str] = None,
    metadata_payload_key: str = "metadata",
    path: Optional[str] = None,
    port: Optional[int] = 6333,
    prefer_grpc: bool = False,
    prefix: Optional[str] = None,
    search_kwargs: Optional[NestedDict] = None,
    timeout: Optional[int] = None,
    url: Optional[str] = None,
) -> List[Record]:  # type: ignore[override]
    vector_store = super().build(
        embedding=embedding,
        collection_name=collection_name,
        api_key=api_key,
        content_payload_key=content_payload_key,
        distance_func=distance_func,
        grpc_port=grpc_port,
        https=https,
        host=host,
        location=location,
        metadata_payload_key=metadata_payload_key,
        path=path,
        port=port,
        prefer_grpc=prefer_grpc,
        prefix=prefix,
        timeout=timeout,
        url=url,
    )
    if not vector_store:
        raise ValueError("Failed to load the Qdrant index.")
    if search_kwargs is None:
        search_kwargs = {}

    return self.search_with_vector_store(
        vector_store=vector_store,
        input_value=input_value,
        search_type=search_type,
        k=number_of_results,
        **search_kwargs,
    )

To debug this issue, you can check the error logs or tracebacks stored in the error and traceback fields of the CodeErrorDataTypeAPI type. They can be accessed from the error.response.data.detail object in the ResponseErrorTypeAPI type:

export type CodeErrorDataTypeAPI = {
  error: string | undefined;
  traceback: string | undefined;
};

// error that has a response, that has a data, that has a detail, that has an error
export type ResponseErrorTypeAPI = {
  response: { data: { detail: CodeErrorDataTypeAPI } };
};

Additionally, the TracingService class handles logging and tracing, capturing exceptions and formatting the traceback, which is then logged:

@asynccontextmanager
async def trace_context(
    self,
    trace_name: str,
    trace_type: str,
    inputs: Dict[str, Any],
    metadata: Optional[Dict[str, Any]] = None,
):
    self._start_traces(trace_name, trace_type, inputs, metadata)
    try:
        yield self
    except Exception as e:
        tb = traceback.format_exc()
        error_message = f"{e.__class__.__name__}: {e}\n\n{tb}"
        self._end_traces(trace_name, error_message)
        raise e
    finally:
        self._end_traces(trace_name, None)
        self._reset_io()

This should help you identify and resolve the issue with the "Advanced Settings" in the Qdrant Search component [1][2][3][4].

To continue talking to Dosu, mention @dosu.

lwkask8 commented 1 week ago

To com o mesmo problema

nicoloboschi commented 5 days ago

Could you elaborate more this problem?