-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
f7027d9
commit 2977f1f
Showing
14 changed files
with
358 additions
and
30 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
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
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,69 @@ | ||
import { | ||
List, | ||
ListBase, | ||
TopToolbar, | ||
FilterButton, | ||
Pagination, | ||
SearchInput, | ||
TextInput, | ||
WithListContext, | ||
useListContext, | ||
TextField, | ||
RichTextField, | ||
ChipField, | ||
ReferenceInput, | ||
RecordContextProvider, | ||
WrapperField, | ||
ReferenceField, | ||
ListToolbar, | ||
Title, | ||
SimpleShowLayout, | ||
simpleList | ||
} from 'react-admin'; | ||
|
||
import { Stack, Typography, Paper, Card, Accordion } from '@mui/material'; | ||
|
||
type Chunk = { | ||
id: number; | ||
kind: string; | ||
}; | ||
|
||
const ListActions = () => ( | ||
<TopToolbar > | ||
<FilterButton/> | ||
</TopToolbar> | ||
); | ||
|
||
const listFilters = [ | ||
<TextInput label="Kind" source="kind" defaultValue="all"/>, | ||
<ReferenceInput source="collection_id" reference="collections"/>, | ||
<ReferenceInput source="document_id" reference="documents"/>, | ||
]; | ||
|
||
const ChunkListView = () => { | ||
const { data, isLoading } = useListContext(); | ||
if (isLoading) return null; | ||
|
||
return ( | ||
<> | ||
{data.map((chunk) => <RecordContextProvider key={chunk.id} value={chunk}> | ||
<Card sx={{padding: 2, margin: 1}}> | ||
<SimpleShowLayout> | ||
<ChipField source="kind"/> | ||
<RichTextField source="text"/> | ||
<ReferenceField source="document_id" reference="documents" /> | ||
</SimpleShowLayout> | ||
</Card> | ||
</RecordContextProvider>)} | ||
</> | ||
) | ||
}; | ||
|
||
export const ChunkList = () => ( | ||
<ListBase > | ||
<Title title="Chunks"/> | ||
<ListToolbar actions={<ListActions/>} filters={listFilters}/> | ||
<ChunkListView /> | ||
<Pagination /> | ||
</ListBase> | ||
); |
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,80 @@ | ||
import { | ||
List, | ||
Datagrid, | ||
TextField, | ||
TopToolbar, | ||
FilterButton, | ||
SearchInput, | ||
EditButton, | ||
CreateButton, | ||
Create, | ||
Edit, | ||
SimpleForm, | ||
CheckboxGroupInput, | ||
TextInput, | ||
SelectInput, | ||
required | ||
} from 'react-admin'; | ||
|
||
const ListActions = () => ( | ||
<TopToolbar> | ||
<CreateButton/> | ||
</TopToolbar> | ||
); | ||
export const CollectionList = () => ( | ||
<List actions={<ListActions/>} > | ||
<Datagrid> | ||
<TextField source="name" /> | ||
<TextField source="text_embedding_model" /> | ||
<TextField source="text_distance_metric" /> | ||
<TextField source="llm_model" /> | ||
</Datagrid> | ||
</List> | ||
); | ||
|
||
export const ChunkingConfig = () => ( | ||
<> | ||
<CheckboxGroupInput label="Chunks to Extract" source="extract" defaultValue={["snippets"]} choices={[ | ||
{id: "snippets", name: "Snippets"}, | ||
{id: "summaries", name: "Summaries"}, | ||
{id: "images", name: "Images"} | ||
]}/> | ||
<CheckboxGroupInput label="Retrieve Using" source="index" defaultValue={["text"]} choices={[ | ||
{id: "text", name: "Text"}, | ||
{id: "questions_answered", name: "Questions Answered"}, | ||
{id: "statements", name: "Statements"}, | ||
]}/> | ||
</> | ||
) | ||
|
||
const Form = () => ( | ||
<SimpleForm> | ||
<TextInput source="name" validate={[required()]} fullWidth /> | ||
<SelectInput source="text_embedding_model" defaultValue="hf:BAAI/bge-small-en" choices={[ | ||
{id: 'hf:BAAI/bge-small-en', name: 'BAAI/bge-small-en'}, | ||
{id: 'openai:text-embedding-ada-002', name: 'OpenAI/text_embedding_ada_002'}, | ||
]}/> | ||
<SelectInput source="text_distance_metric" defaultValue="cosine" choices={[ | ||
{id: 'cosine', name: 'Cosine'}, | ||
{id: 'ip', name: 'Inner Product'}, | ||
{id: 'l2', name: 'L2-Norm'}, | ||
]}/> | ||
<SelectInput source="llm_model" defaultValue="huggingface:StabilityAI/stablelm-tuned-alpha-3b" choices={[ | ||
{id: 'huggingface:StabilityAI/stablelm-tuned-alpha-3b', name: 'stablelm-tuned-alpha-3b'}, | ||
{id: 'openai:gpt-3.5-turbo', name: 'gpt-3.5-turbo'}, | ||
]}/> | ||
<ChunkingConfig /> | ||
</SimpleForm> | ||
) | ||
|
||
export const CollectionCreate = () => ( | ||
<Create redirect="list"> | ||
<Form/> | ||
</Create> | ||
); | ||
|
||
export const CollectionEdit = () => ( | ||
<Edit redirect="list"> | ||
<Form/> | ||
</Edit> | ||
); |
Oops, something went wrong.