Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
richardgill committed May 29, 2024
1 parent aef4f03 commit 57956ab
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@llm-ui/markdown": "workspace:*",
"@llm-ui/react": "workspace:*",
"@llm-ui/json": "workspace:*",
"@llm-ui/csv": "workspace:*",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
Expand Down
8 changes: 5 additions & 3 deletions apps/www/src/components/demo/message/Message.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"use client";
import { buttonsBlock as createButtonsBlock } from "@/components/examples/Buttons";
import { buttonsCsvBlock as createCsvButtonsBlock } from "@/components/examples/ButtonsCsv";
import { buttonsJsonBlock as createJsonButtonsBlock } from "@/components/examples/ButtonsJson";
import { codeBlockBlock } from "@/components/examples/CodeBlock";
import { Markdown } from "@/components/examples/Markdown";
import { markdownLookBack } from "@llm-ui/markdown";
import { useLLMOutput } from "@llm-ui/react";

const buttonsBlock = createButtonsBlock();
const buttonsJsonBlock = createJsonButtonsBlock();
const buttonsCsvBlock = createCsvButtonsBlock();

export const Message: React.FC<{
message: string;
Expand All @@ -17,7 +19,7 @@ export const Message: React.FC<{
component: Markdown,
lookBack: markdownLookBack(),
},
blocks: [codeBlockBlock, buttonsBlock],
blocks: [codeBlockBlock, buttonsJsonBlock, buttonsCsvBlock],
isStreamFinished,
});

Expand Down
32 changes: 32 additions & 0 deletions apps/www/src/components/examples/ButtonsCsv.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { starsAndConfetti } from "@/animations/buttonHandler";
import { csvBlock, parseCsv } from "@llm-ui/csv";
import type { LLMOutputBlock, LLMOutputComponent } from "@llm-ui/react";
import { Button } from "../ui/Button";

type OnClick = (buttonText: string | undefined) => void;

const buttonsComponent = (onClick: OnClick) => {
const ButtonsComponent: LLMOutputComponent = ({ blockMatch }) => {
const buttons = parseCsv(blockMatch.output);
if (!buttons || !blockMatch.isVisible) {
return undefined;
}
return (
<div className="flex flex-row my-4 gap-2">
{buttons?.map((buttonText, index) => (
<Button key={index} onClick={() => onClick(buttonText ?? "")}>
{buttonText}
</Button>
))}
</div>
);
};
return ButtonsComponent;
};

export const buttonsCsvBlock = (
onClick: OnClick = starsAndConfetti,
): LLMOutputBlock => ({
...csvBlock(),
component: buttonsComponent(onClick),
});
5 changes: 3 additions & 2 deletions apps/www/src/components/examples/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React, {
} from "react";
import { Loader } from "../ui/custom/Loader";
import { H2 } from "../ui/custom/Text";
import { buttonsCsvBlock } from "./ButtonsCsv";
import { buttonsJsonBlock } from "./ButtonsJson";
import { codeBlockBlock } from "./CodeBlock";
import { Controls } from "./Controls";
Expand Down Expand Up @@ -228,7 +229,7 @@ export const ExampleTabsTokenArray: React.FC<ExampleTokenArrayProps> = ({
const { finishCount, restart, blockMatches, isFinished, visibleText } =
useLLMOutput({
llmOutput: output,
blocks: [codeBlockBlock, buttonsBlockRef.current],
blocks: [codeBlockBlock, buttonsBlockRef.current, buttonsCsvBlock()],
fallbackBlock: {
component: Markdown,
lookBack: markdownLookBack(),
Expand Down Expand Up @@ -343,7 +344,7 @@ export const ExampleSideBySideTokenArray: React.FC<
const { finishCount, restart, blockMatches, isFinished, visibleText } =
useLLMOutput({
llmOutput: output,
blocks: [codeBlockBlock, buttonsBlockRef.current],
blocks: [codeBlockBlock, buttonsBlockRef.current, buttonsCsvBlock()],
fallbackBlock: {
component: Markdown,
lookBack: markdownLookBack(),
Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/content/docs/blocks/csv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Allow LLMs to reply with CSV, which can be rendered as custom components in your

<ExampleSideBySide
client:load
example={`Buttons:\nButton 1,Button 2`}
example={`Buttons:\nStar ⭐,Confetti 🎉`}
options={{ delayMultiplier: 0.2 }}
/>

Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/content/docs/blocks/json.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Generates:

<CodeBlock code={buttonPrompt} />

You can also hardcode the prompt into your application.
You can also hardcode the prompt into your

# Options

Expand Down
1 change: 1 addition & 0 deletions packages/csv/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { csvBlockPrompt } from "./csvBlockPrompt";
export { csvBlockLookBack } from "./lookback";
export { findCompleteCsvBlock, findPartialCsvBlock } from "./matchers";
export type { CsvBlockOptions } from "./options";
export { parseCsv } from "./parseCsv";
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 57956ab

Please sign in to comment.