Skip to content

Commit

Permalink
Merge pull request langchain-ai#38 from langchain-ai/brace/always-exp…
Browse files Browse the repository at this point in the history
…ose-reflections

feat: Ensure reflections button is always exposed
  • Loading branch information
bracesproul authored Oct 15, 2024
2 parents 3346696 + ad85c67 commit 51838e8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export default function Home() {
)}
>
<ContentComposerChatInterface
handleGetReflections={getReflections}
handleDeleteReflections={deleteReflections}
reflections={reflections}
isLoadingReflections={isLoadingReflections}
setSelectedArtifact={setSelectedArtifact}
streamMessage={streamMessage}
setArtifacts={setArtifacts}
Expand Down
10 changes: 9 additions & 1 deletion src/components/ContentComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "@/lib/convert_messages";
import { GraphInput } from "@/hooks/useGraph";
import { Toaster } from "./ui/toaster";
import { Artifact, ProgrammingLanguageOptions } from "@/types";
import { Artifact, ProgrammingLanguageOptions, Reflections } from "@/types";
import { Thread } from "@langchain/langgraph-sdk";
export interface ContentComposerChatInterfaceProps {
messages: BaseMessage[];
Expand All @@ -31,6 +31,10 @@ export interface ContentComposerChatInterfaceProps {
type: "text" | "code",
language?: ProgrammingLanguageOptions
) => void;
isLoadingReflections: boolean;
reflections: (Reflections & { updatedAt: Date }) | undefined;
handleDeleteReflections: () => Promise<boolean>;
handleGetReflections: () => Promise<void>;
}

export function ContentComposerChatInterface(
Expand Down Expand Up @@ -78,6 +82,10 @@ export function ContentComposerChatInterface(
<div className="h-full">
<AssistantRuntimeProvider runtime={runtime}>
<MyThread
handleGetReflections={props.handleGetReflections}
handleDeleteReflections={props.handleDeleteReflections}
reflections={props.reflections}
isLoadingReflections={props.isLoadingReflections}
handleQuickStart={props.handleQuickStart}
showNewThreadButton={props.showNewThreadButton}
createThread={props.createThread}
Expand Down
18 changes: 16 additions & 2 deletions src/components/Primitives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { useArtifactToolUI } from "./ArtifactToolUI";
import { Thread } from "@langchain/langgraph-sdk";
import { useLangSmithLinkToolUI } from "./LangSmithLinkToolUI";
import { ProgrammingLanguageList } from "./ProgrammingLanguageList";
import { ProgrammingLanguageOptions } from "@/types";
import { ProgrammingLanguageOptions, Reflections } from "@/types";
import { ReflectionsDialog } from "./reflections-dialog/ReflectionsDialog";

export interface MyThreadProps {
setSelectedArtifact: (artifactId: string) => void;
Expand All @@ -35,6 +36,10 @@ export interface MyThreadProps {
type: "text" | "code",
language?: ProgrammingLanguageOptions
) => void;
isLoadingReflections: boolean;
reflections: (Reflections & { updatedAt: Date }) | undefined;
handleDeleteReflections: () => Promise<boolean>;
handleGetReflections: () => Promise<void>;
}

interface QuickStartButtonsProps {
Expand Down Expand Up @@ -128,7 +133,16 @@ export const MyThread: FC<MyThreadProps> = (props: MyThreadProps) => {
<SquarePen />
</TooltipIconButton>
) : (
<QuickStartButtons handleQuickStart={props.handleQuickStart} />
<div className="flex flex-row gap-2 items-center">
<ReflectionsDialog
handleGetReflections={props.handleGetReflections}
isLoadingReflections={props.isLoadingReflections}
reflections={props.reflections}
handleDeleteReflections={props.handleDeleteReflections}
/>

<QuickStartButtons handleQuickStart={props.handleQuickStart} />
</div>
)}
</div>
<ThreadPrimitive.Viewport className="flex-1 overflow-y-auto scroll-smooth bg-inherit px-4 pt-8">
Expand Down
14 changes: 8 additions & 6 deletions src/components/artifacts/ArtifactRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,14 @@ export function ArtifactRenderer(props: ArtifactRendererProps) {
</TooltipIconButton>
<h1 className="text-xl font-medium">{props.artifact.title}</h1>
</div>
<ReflectionsDialog
handleGetReflections={props.handleGetReflections}
isLoadingReflections={props.isLoadingReflections}
reflections={props.reflections}
handleDeleteReflections={props.handleDeleteReflections}
/>
<div className="ml-auto mt-[10px] mr-[6px]">
<ReflectionsDialog
handleGetReflections={props.handleGetReflections}
isLoadingReflections={props.isLoadingReflections}
reflections={props.reflections}
handleDeleteReflections={props.handleDeleteReflections}
/>
</div>
{props.artifact.type === "text" ? (
<div className="pr-[6px] pt-3 flex flex-row gap-4 items-center justify-end">
<TooltipIconButton
Expand Down
8 changes: 6 additions & 2 deletions src/components/reflections-dialog/ReflectionsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export interface ReflectionsProps {

function NoReflections(props: Pick<ReflectionsProps, "handleGetReflections">) {
return (
<div className="flex flex-col items-center mt-6 mb-[-24px] gap-2">
<div className="flex flex-col items-center mt-6 mb-[-24px] gap-3">
<p>No reflections have been generated yet.</p>
<p className="text-sm text-gray-500">
Reflections generate after 30s of inactivity. If none appear, try again
later.
</p>
<Button
onClick={props.handleGetReflections}
variant="secondary"
Expand Down Expand Up @@ -53,7 +57,7 @@ export function ReflectionsDialog(props: ReflectionsProps) {
<DialogTrigger asChild>
<div
onClick={() => setOpen(true)}
className="ml-auto mt-[10px] mr-[6px] bg-white hover:bg-gray-50 text-black border border-gray-300 px-4 py-2 rounded-md shadow-sm transition-colors duration-200 cursor-pointer flex items-center space-x-2"
className="ml-auto bg-white hover:bg-gray-50 text-black border border-gray-300 px-4 py-2 rounded-md shadow-sm transition-colors duration-200 cursor-pointer flex items-center space-x-2"
>
<p className="text-sm font-light">Reflections</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const LANGGRAPH_API_URL =
process.env.LANGGRAPH_API_URL ?? "http://localhost:52809";
process.env.LANGGRAPH_API_URL ?? "http://localhost:57227";

0 comments on commit 51838e8

Please sign in to comment.