-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
268 additions
and
31 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
27 changes: 27 additions & 0 deletions
27
packages/app/src/components/nodes/DatasetNearestNeighborsNode.tsx
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,27 @@ | ||
import { DatasetNearestNeighborsNode } from '@ironclad/rivet-core'; | ||
import { NodeComponentDescriptor } from '../../hooks/useNodeTypes'; | ||
import { FC } from 'react'; | ||
import { useDatasets } from '../../hooks/useDatasets'; | ||
import { useRecoilValue } from 'recoil'; | ||
import { projectState } from '../../state/savedGraphs'; | ||
|
||
export const DatasetNearestNeightborsNode: FC<{ | ||
node: DatasetNearestNeighborsNode; | ||
}> = ({ node }) => { | ||
const project = useRecoilValue(projectState); | ||
const { datasets } = useDatasets(project.metadata.id); | ||
|
||
const dataset = datasets?.find((d) => d.id === node.data.datasetId); | ||
|
||
return ( | ||
<div> | ||
<div> | ||
{node.data.useDatasetIdInput ? 'Dataset from input' : dataset ? dataset.name : 'Unknown or no dataset selected'} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export const datasetNearestNeighborsNodeDescriptor: NodeComponentDescriptor<'datasetNearestNeighbors'> = { | ||
Body: DatasetNearestNeightborsNode, | ||
}; |
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
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
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,25 @@ | ||
import { Opaque } from 'type-fest'; | ||
import { ProjectId } from '../index.js'; | ||
|
||
export type DatasetId = Opaque<string, 'DatasetId'>; | ||
|
||
export type DatasetMetadata = { | ||
id: DatasetId; | ||
projectId: ProjectId; | ||
name: string; | ||
description: string; | ||
}; | ||
|
||
export type Dataset = { | ||
id: DatasetId; | ||
rows: DatasetRow[]; | ||
}; | ||
|
||
export type DatasetRow = { | ||
id: string; | ||
|
||
data: string[]; | ||
|
||
/** An optional embedding for the row's data. */ | ||
embedding?: number[]; | ||
}; |
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
Oops, something went wrong.