feat: add natural language search #94
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR
Add NL query parameters to search API and complete NL search models CRUD operations.
Change Summary
Added Features:
New Natural Language Query Support in
src/typesense/types/document.py
:NLLanguageParameters
: Configuration for natural language queries with caching, model selection, and debug optionsLLMResponse
: Schema for raw LLM responses with content, extraction method, and model infoParsedNLQuery
: Schema for processed NL queries with timing, generated/augmented parameters, and LLM responseSearchParameters
to includeNLLanguageParameters
parsed_nl_query
field toSearchResponse
for NL query metadataNew NL Search Models Management System:
NLSearchModel
class insrc/typesense/nl_search_model.py
: Individual model operations (retrieve, update, delete)NLSearchModels
class insrc/typesense/nl_search_models.py
: Collection operations (create, retrieve, getitem)src/typesense/types/nl_search_model.py
: Support for multiple LLM providers (OpenAI, Google, GCP Vertex AI, Cloudflare)Code Changes:
In
src/typesense/client.py
:NLSearchModels
into mainClient
class with proper importsself.nl_search_models = NLSearchModels(self.api_call)
to client initializationIn
tests/fixtures/nl_search_model_fixtures.py
:In
tests/nl_search_model_test.py
andtests/nl_search_models_test.py
: