Skip to content

Commit

Permalink
add source id to source object (#485)
Browse files Browse the repository at this point in the history
* add source id

* up

* up
  • Loading branch information
elliotdauber authored Jan 14, 2025
1 parent 56d8859 commit 88fa997
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 18 deletions.
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type SourceType =
| 'salesforce';

export interface Source {
id: string;
type: SourceType;
data?: {
url?: string;
Expand Down
15 changes: 12 additions & 3 deletions packages/react/src/chat/ChatView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ describe('ChatView', () => {
response = [{ content: 'answer' }];
const references = [
{
file: { path: '/page1', source: { type: 'file-upload' as const } },
file: {
path: '/page1',
source: { id: '0', type: 'file-upload' as const },
},
meta: { leadHeading: { value: 'Page 1' } },
},
];
Expand All @@ -542,7 +545,10 @@ describe('ChatView', () => {
response = [{ content: 'answer' }];
const references = [
{
file: { path: '/page1', source: { type: 'file-upload' as const } },
file: {
path: '/page1',
source: { id: '0', type: 'file-upload' as const },
},
meta: { leadHeading: { value: 'Page 1' } },
},
];
Expand All @@ -569,7 +575,10 @@ describe('ChatView', () => {
response = [{ content: 'answer' }];
const references = [
{
file: { path: '/page1', source: { type: 'file-upload' as const } },
file: {
path: '/page1',
source: { id: '0', type: 'file-upload' as const },
},
meta: { leadHeading: { value: 'Page 1' } },
},
];
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const heading = 'Heading 1';
const headingSlug = 'heading-1';
const headingId = 'generated-id';
const noTitleFileName = 'no-title';
const githubSource: Source = { type: 'github' };
const websiteSource: Source = { type: 'website' };
const githubSource: Source = { id: '0', type: 'github' };
const websiteSource: Source = { id: '0', type: 'website' };
const shortContent = 'Some content';

const loremIpsum =
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/primitives/headless.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ test('References renders the passed ReferenceComponent', () => {
render(
<Markprompt.References
references={[
{ file: { path: '/path/to/file', source: { type: 'github' } } },
{
file: { path: '/path/to/file', source: { id: '0', type: 'github' } },
},
]}
ReferenceComponent={ReferenceComponent}
/>,
Expand Down
39 changes: 27 additions & 12 deletions packages/react/src/search/SearchView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,25 @@ describe('SearchView', () => {

results = [
{
file: { path: 'path/to/file', source: { type: 'github' } },
file: {
path: 'path/to/file',
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
{
file: {
path: 'path/to/file',
title: 'result 1',
source: { type: 'github' },
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
{
file: {
path: 'path/to/file',
title: 'result 2',
source: { type: 'github' },
source: { id: '0', type: 'github' },
},
matchType: 'title',
meta: {
Expand All @@ -108,7 +111,7 @@ describe('SearchView', () => {
{
file: {
path: 'path/to/file',
source: { type: 'github' },
source: { id: '0', type: 'github' },
},
matchType: 'leadHeading',
meta: {
Expand All @@ -121,7 +124,7 @@ describe('SearchView', () => {
{
file: {
path: 'path/to/file',
source: { type: 'github' },
source: { id: '0', type: 'github' },
},
meta: {
leadHeading: {
Expand Down Expand Up @@ -177,22 +180,25 @@ describe('SearchView', () => {

results = [
{
file: { path: 'path/to/file', source: { type: 'github' } },
file: {
path: 'path/to/file',
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
{
file: {
path: 'path/to/file',
title: 'result 1',
source: { type: 'github' },
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
{
file: {
path: 'path/to/file',
title: 'result 2',
source: { type: 'github' },
source: { id: '0', type: 'github' },
},
matchType: 'title',
meta: {
Expand Down Expand Up @@ -265,7 +271,10 @@ describe('SearchView', () => {

results = [
{
file: { path: 'path/to/file', source: { type: 'github' } },
file: {
path: 'path/to/file',
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
];
Expand Down Expand Up @@ -300,7 +309,10 @@ describe('SearchView', () => {

results = [
{
file: { path: '#file', source: { type: 'github' } },
file: {
path: '#file',
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
];
Expand Down Expand Up @@ -330,7 +342,7 @@ describe('SearchView', () => {
file: {
path: 'path/to/file',
title: 'test',
source: { type: 'github' },
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
Expand Down Expand Up @@ -414,7 +426,10 @@ describe('SearchView', () => {

results = [
{
file: { path: 'path/to/file', source: { type: 'github' } },
file: {
path: 'path/to/file',
source: { id: '0', type: 'github' },
},
matchType: 'title',
},
];
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/search/useSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('useSearch', () => {
title: 'Home page',
path: '/',
source: {
id: '0',
type: 'file-upload',
},
},
Expand All @@ -91,6 +92,7 @@ describe('useSearch', () => {
file: {
path: '/page1',
source: {
id: '0',
type: 'file-upload',
},
},
Expand All @@ -104,6 +106,7 @@ describe('useSearch', () => {
file: {
path: '/page2',
source: {
id: '0',
type: 'file-upload',
},
},
Expand Down

0 comments on commit 88fa997

Please sign in to comment.