-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
875267c
commit b264096
Showing
14 changed files
with
678 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# this is needed to stop pnpm defaulting to workspace:* for the packages for some reason | ||
link-workspace-packages=false |
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,10 @@ | ||
import { fireConfetti } from "./confetti"; | ||
import { multipleStars } from "./stars"; | ||
|
||
export const starsAndConfetti = (text: string = "") => { | ||
if (text.toLowerCase().includes("star")) { | ||
multipleStars(); | ||
} else if (text.toLowerCase().includes("confetti")) { | ||
fireConfetti(); | ||
} | ||
}; |
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,38 @@ | ||
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 options = { | ||
type: "buttons", | ||
delimiter: ";", | ||
}; | ||
|
||
const buttonsComponent = (onClick: OnClick) => { | ||
const ButtonsComponent: LLMOutputComponent = ({ blockMatch }) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [_type, ...buttons] = parseCsv(blockMatch.output, options); | ||
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(options), | ||
component: buttonsComponent(onClick), | ||
}); |
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
Oops, something went wrong.