Skip to content

Commit

Permalink
feat(llm_prompts): typed metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
massi-ang authored and bigadsoleiman committed Nov 22, 2023
1 parent 0c333bb commit 6229b4b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ChatBotHistoryItem,
ChatBotMessageType,
ImageFile,
RagDocument,
} from "./types";

import { getSignedUrl } from "./utils";
Expand Down Expand Up @@ -108,32 +109,33 @@ export default function ChatMessage(props: ChatMessageProps) {
iconName="copy"
onClick={() => {
navigator.clipboard.writeText(
(props.message.metadata.documents as string[])[
parseInt(documentIndex)
]
(
props.message.metadata
.documents as RagDocument[]
)[parseInt(documentIndex)].page_content
);
}}
/>
</Popover>
</div>
<Tabs
tabs={(props.message.metadata.documents as string[]).map(
(p: any, i) => {
return {
id: `${i}`,
label: p.metadata.path,
content: (
<>
<Textarea
value={p["page_content"]}
readOnly={true}
rows={8}
/>
</>
),
};
}
)}
tabs={(
props.message.metadata.documents as RagDocument[]
).map((p: any, i) => {
return {
id: `${i}`,
label: p.metadata.path,
content: (
<>
<Textarea
value={p.page_content}
readOnly={true}
rows={8}
/>
</>
),
};
})}
activeTabId={documentIndex}
onChange={({ detail }) =>
setDocumentIndex(detail.activeTabId)
Expand Down
18 changes: 17 additions & 1 deletion lib/user-interface/react-app/src/components/chatbot/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface ChatBotRunRequest {
data: {
modelName: string;
provider: string;
sessionId?: string;
sessionId: string;
files: ImageFile[] | null;
text: string;
mode: string;
Expand All @@ -84,6 +84,21 @@ export interface ChatBotToken {
value: string;
}

export interface RagDocument {
page_content: string;
metadata: {
chunk_id: string;
workspace_id: string;
document_id: string;
document_sub_id: string | null;
document_type: string;
document_sub_type: string | null;
path: string;
title: string | null;
score: number;
};
}

export interface ChatBotHistoryItem {
type: ChatBotMessageType;
content: string;
Expand All @@ -97,6 +112,7 @@ export interface ChatBotHistoryItem {
| ImageFile[]
| string[]
| string[][]
| RagDocument[]
>;
tokens?: ChatBotToken[];
}
Expand Down

0 comments on commit 6229b4b

Please sign in to comment.