Skip to content

feat: add natural language search #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tharropoulos
Copy link
Contributor

TLDR

Add NL query parameters to search API and complete NL search models CRUD operations.

Change Summary

Added Features:

  1. New Natural Language Query Support in src/typesense/types/document.py:

    • NLLanguageParameters: Configuration for natural language queries with caching, model selection, and debug options
    • LLMResponse: Schema for raw LLM responses with content, extraction method, and model info
    • ParsedNLQuery: Schema for processed NL queries with timing, generated/augmented parameters, and LLM response
    • Extended SearchParameters to include NLLanguageParameters
    • Added parsed_nl_query field to SearchResponse for NL query metadata
  2. New NL Search Models Management System:

    • NLSearchModel class in src/typesense/nl_search_model.py: Individual model operations (retrieve, update, delete)
    • NLSearchModels class in src/typesense/nl_search_models.py: Collection operations (create, retrieve, getitem)
    • Type definitions in src/typesense/types/nl_search_model.py: Support for multiple LLM providers (OpenAI, Google, GCP Vertex AI, Cloudflare)

Code Changes:

  1. In src/typesense/client.py:

    • Integrated NLSearchModels into main Client class with proper imports
    • Added self.nl_search_models = NLSearchModels(self.api_call) to client initialization
  2. In tests/fixtures/nl_search_model_fixtures.py:

    • Added test fixtures for both individual and collection NL search model operations
    • Includes cleanup utilities and actual API test fixtures
  3. In tests/nl_search_model_test.py and tests/nl_search_models_test.py:

    • Complete test coverage for individual model operations (retrieve, update, delete)
    • Complete test coverage for collection operations (create, retrieve, getitem)
    • Integration tests with actual Typesense server

- add `NLSearchModel` class for individual model operations (retrieve, update, delete)
- add `NLSearchModels` class for collection operations (create, retrieve, __getitem__)
- add type definitions in `types/nl_search_model.py` with support for multiple llm providers
- integrate `nl_search_models` into main `Client` class with proper imports
- add test fixtures and tests for both individual and collection operations
- add `NLLanguageParameters` type with nl query configuration options
- add `LLMResponse` and `ParsedNLQuery` types for nl query responses
- extend `SearchParameters` to include natural language parameters
- add `parsed_nl_query` field to `SearchResponse` for nl query metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant