-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to pass customField to /rerank endpoint (#303)
## Problem The current implementation of `/rerank` in the TS client does not (correctly) allow users to pass a custom field upon which to rerank. ## Solution Allow custom fields! Please reference this PR to account for all expected functionality: https://github.com/pinecone-io/python-plugin-inference/pull/21/files ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan CI passes + reviewer xreferences PR above w/functionality introduced in this PR. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1208523729730914 --------- Co-authored-by: Jesse Seldess <[email protected]>
- Loading branch information
Showing
6 changed files
with
359 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Inference } from '../inference'; | ||
import type { PineconeConfiguration } from '../../data'; | ||
import { inferenceOperationsBuilder } from '../inferenceOperationsBuilder'; | ||
|
||
let inference: Inference; | ||
|
||
beforeAll(() => { | ||
const config: PineconeConfiguration = { apiKey: 'test-api-key' }; | ||
const infApi = inferenceOperationsBuilder(config); | ||
inference = new Inference(infApi); | ||
}); | ||
|
||
describe('Inference Class: _formatInputs', () => { | ||
test('Should format inputs correctly', () => { | ||
const inputs = ['input1', 'input2']; | ||
const expected = [{ text: 'input1' }, { text: 'input2' }]; | ||
const result = inference._formatInputs(inputs); | ||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
|
||
describe('Inference Class: embed', () => { | ||
test('Should throw error if response is missing required fields', async () => { | ||
const model = 'test-model'; | ||
const inputs = ['input1', 'input2']; | ||
const params = { inputType: 'text', truncate: 'END' }; | ||
|
||
const mockedIncorrectResponse = { model: 'test-model' }; | ||
const expectedError = Error( | ||
'Response from Inference API is missing required fields' | ||
); | ||
const embed = jest.spyOn(inference._inferenceApi, 'embed'); | ||
// @ts-ignore | ||
embed.mockResolvedValue(mockedIncorrectResponse); | ||
|
||
try { | ||
await inference.embed(model, inputs, params); | ||
} catch (error) { | ||
expect(error).toEqual(expectedError); | ||
} | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.