-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add nearest neighbors support #1182
base: main
Are you sure you want to change the base?
Conversation
66f0550
to
c6b924f
Compare
c6b924f
to
cabac0a
Compare
| { | ||
[K in L]?: "asc" | "desc"; | ||
} | ||
| "relevance"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not sort by ascending or descending relevance as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope.
By default, nearest neighbors returns objects with the highest scores first, so sorting by relevance is equivalent to sorting by score in descending order.
* @param query - Queries support either a vector matching the embedding model defined on the property, or text that is | ||
automatically embedded. | ||
* @param numNeighbors - The number of objects to return. If the number of documents in the objectType is less than the provided | ||
value, all objects will be returned. This value is limited to 1 ≤ numNeighbors ≥ 500. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'm not actually sure how &le
will render, does throwing in < not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, when I used <
, the markdown would show:
// Warning: (tsdoc-malformed-html-name) Invalid HTML element: Expecting an HTML name
@@ -235,318 +235,28 @@ exports[`Load Ontologies Metadata > Loads action types with media refs, interfac | |||
This is some more text.", | |||
"rid": "rid", | |||
}, | |||
"startDate": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm why this large diff in the snapshots?
@@ -147,6 +147,65 @@ describe("ObjectSet", () => { | |||
expect(iter).toEqual(2); | |||
}); | |||
|
|||
it("nearest neighbors object set", async () => { | |||
const numNeighbors = 3; | |||
const nearestNeighborsObjectSet = client(Employee).nearestNeighbors( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some type tests in here to make sure the type of the call signature is what we expect?
c53a50f
to
3695874
Compare
Add
nearestNeighbor
query support.See runNearestNeighborsTest.ts for example usage