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

Show similarity scores for points when available. #267

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/Points/PointCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const PointCard = (props) => {
)}
<CardHeader
title={'Point ' + point.id}
subheader={point.score && `Score: ${point.score}`}
action={
<>
{Object.keys(point.payload).length === 0 && (
Expand Down
1 change: 1 addition & 0 deletions src/components/Points/PointsTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const PointsTabs = ({ collectionName, client }) => {
<Grid xs={12} item key={point.id}>
<PointCard
point={point}
score={point.score}
onConditionChange={onConditionChange}
conditions={conditions}
collectionName={collectionName}
Expand Down
65 changes: 65 additions & 0 deletions src/components/Points/pointCard.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import PointCard from './PointCard';
import { describe, it, expect } from 'vitest';
import qdrantClient from '../../common/client';

function noop(...args) {
// do nothing.
}

const client = qdrantClient({});

const SCORED_POINT = {
id: 10,
version: 3,
score: 0.9621345,
payload: {},
vector: [0.325, 0.112, 0.2],
};

const UNSCORED_POINT = {
id: 11,
version: 3,
payload: {},
vector: [0.325, 0.112, 0.2],
};

describe('PointCard', () => {
it('should render score when it is present', () => {
render(
<MemoryRouter>
<PointCard
point={SCORED_POINT}
onConditionChange={noop}
conditions={[]}
collectionName="example"
deletePoint={noop}
payloadSchema={{}}
client={client}
/>
</MemoryRouter>
);
expect(screen.getByText('Point 10')).toBeInTheDocument();
expect(screen.getByText('Score: 0.9621345')).toBeInTheDocument();
});

it('should not render score when it is not available', async () => {
render(
<MemoryRouter>
<PointCard
point={UNSCORED_POINT}
onConditionChange={noop}
conditions={[]}
collectionName="example"
deletePoint={noop}
payloadSchema={{}}
client={client}
/>
</MemoryRouter>
);
expect(screen.getByText('Point 11')).toBeInTheDocument();
expect(screen.queryByText('Score') === null);
expect(screen.queryByText('Score: undefined') === null);
});
});
8 changes: 7 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export default defineConfig(async () => {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/setupTests.js'],
alias: [
{
find: /^monaco-editor$/,
replacement: __dirname + '/node_modules/monaco-editor/esm/vs/editor/editor.api',
},
],
},
}
};
});
Loading