Skip to content
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

feat(query): Add custom lancedb query generation for lancedb search #518

Merged

Conversation

shamb0
Copy link
Contributor

@shamb0 shamb0 commented Dec 31, 2024

Fixes: #511

This PR implements the CustomStrategy<Q> trait for LanceDB, enabling flexible and customizable vector similarity search capabilities. The implementation follows the successful pattern established in the pgvector integration while leveraging LanceDB-specific features.

@shamb0 shamb0 marked this pull request as ready for review December 31, 2024 14:05
Copy link
Member

@timonv timonv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Couple of comments

swiftide/tests/lancedb.rs Outdated Show resolved Hide resolved
swiftide/tests/lancedb.rs Outdated Show resolved Hide resolved
swiftide-integrations/src/lancedb/retrieve.rs Outdated Show resolved Hide resolved
swiftide-integrations/src/lancedb/retrieve.rs Outdated Show resolved Hide resolved
.context("Failed to create vector similarity query")?
.column(&vector_field);

let result_limit = usize::try_from(similarity_config.top_k())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just use an arbitrary number? Feels a bit complicated to just create a new search strategy, if you really need a number.

@shamb0 shamb0 force-pushed the feat/lancedb/custom-strategy-integration branch 2 times, most recently from 1705ed1 to 6e99c2d Compare January 9, 2025 11:41
@shamb0
Copy link
Contributor Author

shamb0 commented Jan 9, 2025

Hi @timonv,

I've updated the custom strategy implementation in swiftide-core/src/search_strategies/custom_strategy.rs to handle async query builders, addressing your feedback about LanceDB connection management. The documentation has been streamlined as well.

https://github.com/bosun-ai/swiftide/pull/518#discussion_r1900417336
https://github.com/bosun-ai/swiftide/pull/518#discussion_r1900417831

Would appreciate your thoughts on whether this prototype aligns with your expectations.

This commit implements the CustomStrategy trait for LanceDB vector
similarity search, enabling flexible query generation with metadata
filtering.

Signed-off-by: shamb0 <[email protected]>
@shamb0 shamb0 force-pushed the feat/lancedb/custom-strategy-integration branch from 6e99c2d to 39d7b97 Compare January 9, 2025 12:07
timonv
timonv previously approved these changes Jan 12, 2025
Copy link
Member

@timonv timonv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, this is really good! Will merge it asap.

@timonv timonv merged commit 7f85735 into bosun-ai:master Jan 16, 2025
7 checks passed
timonv pushed a commit that referenced this pull request Jan 16, 2025
## 🤖 New release
* `swiftide`: 0.16.4 -> 0.17.0 (✓ API compatible changes)
* `swiftide-agents`: 0.16.4 -> 0.17.0 (✓ API compatible changes)
* `swiftide-core`: 0.16.4 -> 0.17.0 (⚠️ API breaking changes)
* `swiftide-macros`: 0.16.4 -> 0.17.0
* `swiftide-indexing`: 0.16.4 -> 0.17.0
* `swiftide-integrations`: 0.16.4 -> 0.17.0 (✓ API compatible changes)
* `swiftide-query`: 0.16.4 -> 0.17.0

### ⚠️ `swiftide-core` breaking changes

```
--- failure trait_method_added: pub trait method added ---

Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.38.0/src/lints/trait_method_added.ron

Failed in:
  trait method swiftide_core::agent_traits::AgentContext::redrive in file /tmp/.tmps520nh/swiftide/swiftide-core/src/agent_traits.rs:153
  trait method swiftide_core::AgentContext::redrive in file /tmp/.tmps520nh/swiftide/swiftide-core/src/agent_traits.rs:153
```

<details><summary><i><b>Changelog</b></i></summary><p>

## `swiftide`
<blockquote>

##
[0.17.0](v0.16.4...v0.17.0)
- 2025-01-16

### New features

-
[835c35e](835c35e)
*(agents)* Redrive completions manually on failure (#551)

````text
Sometimes LLMs fail a completion without deterministic errors, or the
  user case where you just want to retry. `redrive` can now be called on a
  context, popping any new messages (if any), and making the messages
  available again to the agent.
````

-
[f83f3f0](f83f3f0)
*(agents)* Implement ToolExecutor for common dyn pointers (#549)

-
[7f85735](7f85735)
*(query)* Add custom lancedb query generation for lancedb search (#518)

-
[ce4e34b](ce4e34b)
*(tree-sitter)* Add golang support (#552)

````text
Seems someone conveniently forgot to add Golang support for the
  splitter.
````

### Miscellaneous

- [0000000](0000000) Update
Cargo.lock dependencies


**Full Changelog**:
0.16.4...0.17.0
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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.

Implementation of CustomStrategy for LanceDB and Qdrant
2 participants