Skip to content

Commit

Permalink
stash commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Zewed committed Jan 27, 2024
1 parent 45d7e24 commit 3b1b520
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";

import { Source } from "@/lib/types/MessageMetadata";

import { CopyButton } from "./components/CopyButton";
import { MessageContent } from "./components/MessageContent";
import { QuestionBrain } from "./components/QuestionBrain";
Expand All @@ -13,7 +15,7 @@ type MessageRowProps = {
promptName?: string | null;
children?: React.ReactNode;
metadata?: {
sources?: [string] | [];
sources?: Source[];
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { useEffect, useRef, useState } from "react";
import ReactDOM from "react-dom";
import { FaQuestionCircle } from "react-icons/fa";

import { Source } from "@/lib/types/MessageMetadata";
import { useEventTracking } from "@/services/analytics/june/useEventTracking";

type SourcesButtonProps = {
sources: [string] | [];
sources: Source[];
};

export const SourcesButton = ({ sources }: SourcesButtonProps): JSX.Element => {
Expand Down Expand Up @@ -39,7 +40,7 @@ export const SourcesButton = ({ sources }: SourcesButtonProps): JSX.Element => {
<ul className="list-disc list-inside">
{sources.map((source, index) => (
<li key={index} className="truncate">
{source.trim()}
{source.name}
</li>
))}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DataPanel = (): JSX.Element => {
const lastMessage = messages[messages.length - 1];
setLastMessageMetadata({
closeBrains: lastMessage.metadata?.close_brains ?? [],
sources: lastMessage.metadata?.sources ?? [""],
sources: lastMessage.metadata?.sources ?? [],
});
}
}, [messages]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
display: flex;
align-items: center;
gap: Spacings.$spacing03;
overflow: hidden;

.copy_icon {
visibility: hidden;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import { useEffect } from "react";

import { FoldableSection } from "@/lib/components/ui/FoldableSection/FoldableSection";
import { Source } from "@/lib/types/MessageMetadata";

interface SourcesProps {
sources?: [string];
sources?: Source[];
}

const Sources = ({ sources }: SourcesProps): JSX.Element => {
useEffect(() => {
console.info(sources);
}, [sources]);

return (
<FoldableSection label="Sources" icon="file">
{sources?.map((source, index) => (
<div key={index}>{source}</div>
<a
href={source.source_url}
key={index}
target="_blank"
rel="noopener noreferrer"
>
<div>{source.name}</div>
</a>
))}
</FoldableSection>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/chat/[chatId]/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UUID } from "crypto";

import { CloseBrain } from "@/lib/types/MessageMetadata";
import { CloseBrain, Source } from "@/lib/types/MessageMetadata";

export type ChatQuestion = {
model?: string;
Expand All @@ -20,7 +20,7 @@ export type ChatMessage = {
brain_name?: string;
brain_id?: UUID;
metadata?: {
sources?: [string];
sources?: Source[];
close_brains?: CloseBrain[];
};
};
Expand Down
8 changes: 7 additions & 1 deletion frontend/lib/types/MessageMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ export interface CloseBrain {
name: string;
}

export interface Source {
name: string;
source_url: string;
type: string;
}

export interface MessageMetadata {
closeBrains: CloseBrain[];
sources: [string];
sources: Source[];
}

0 comments on commit 3b1b520

Please sign in to comment.