cognee/cognee/infrastructure
EricXiao fc7a91d991
feature: implement FEELING_LUCKY search type (#1178)
<!-- .github/pull_request_template.md -->

## Description
<!-- Provide a clear description of the changes in this PR -->
This PR implements the 'FEELING_LUCKY' search type, which intelligently
routes user queries to the most appropriate search retriever, addressing
[#1162](https://github.com/topoteretes/cognee/issues/1162).

- implement new search type FEELING_LUCKY
- Add the select_search_type function to analyze queries and choose the
proper search type
- Integrate with an LLM for intelligent search type determination
- Add logging for the search type selection process
- Support fallback to RAG_COMPLETION when the LLM selection fails
- Add tests for the new search type

## How it works
When a user selects the 'FEELING_LUCKY' search type, the system first
sends their natural language query to an LLM-based classifier. This
classifier analyzes the query's intent (e.g., is it asking for a
relationship, a summary, or a factual answer?) and selects the optimal
SearchType, such as 'INSIGHTS' or 'GRAPH_COMPLETION'. The main search
function then proceeds using this dynamically selected type. If the
classification process fails, it gracefully falls back to the default
'RAG_COMPLETION' type.

## Testing
Tests can be run with:
```bash
python -m pytest cognee/tests/unit/modules/search/search_methods_test.py -k "feeling_lucky" -v
```

## DCO Affirmation
I affirm that all code in every commit of this pull request conforms to
the terms of the Topoteretes Developer Certificate of Origin.

Signed-off-by: EricXiao <taoiaox@gmail.com>
2025-08-02 16:30:08 +02:00
..
context Docstring infrastructure. (#880) 2025-05-28 17:47:31 +02:00
data Docstring infrastructure. (#880) 2025-05-28 17:47:31 +02:00
databases feat: add default tokenizer in case hugging face is not available (#1177) 2025-08-01 16:37:53 +02:00
engine feat: Weighted edges (#1068) 2025-07-14 21:26:25 +02:00
entities Docstring infrastructure. (#880) 2025-05-28 17:47:31 +02:00
files fix: s3 file system env vars (#1112) 2025-07-19 15:56:15 +02:00
llm feature: implement FEELING_LUCKY search type (#1178) 2025-08-02 16:30:08 +02:00
pipeline/models Docstring infrastructure. (#880) 2025-05-28 17:47:31 +02:00
utils feat: s3 storage (#988) 2025-07-14 21:47:08 +02:00
__init__.py fix: enable sdk and fix config 2024-06-03 14:03:24 +02:00