Skip to content

Commit

Permalink
refactor: claude updated with main (#81)
Browse files Browse the repository at this point in the history
* fix: typo

* feat: IOS PWA

* nit: reorder (trying to fix ci)

* fix: apple-mobile-web-app-status-bar-style

* fix: restore default status bar style

* fix: theme color

* nit: reorder

* fix: fixes "[object Object]" copy code button output (#68)

* fixes object copy code error

* Update src/components/utils/Markdown.tsx

---------

Co-authored-by: t11s <[email protected]>

* feat: add gpt-4-32k support

* fix: copy messages to clipboard keybind

* fix: markdown styling improvements, list item newline fix (#62)

Co-authored-by: t11s <[email protected]>

* nit: hr tweaks

* nit: tweak red highlight (#64)

Co-authored-by: t11s <[email protected]>

* nit: restore shadow

* docs: update repo links

* docs: update description

* feat: whisper support (#76)

Co-authored-by: t11s <[email protected]>

* nit: whitespace

* feat: track whisper usage in mixpanel

* feat: whisper transcription keybind

* get claude working

* add readme for self

* cleanup

* make title and link optional

---------

Co-authored-by: t11s <[email protected]>
Co-authored-by: jaavin <[email protected]>
  • Loading branch information
3 people authored Jun 10, 2023
1 parent 6a3ffc7 commit 8e2e240
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 35 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div align="center">
<h1 align="center">Flux</h1>
<p align="center">
LLM power tool
Graph-based LLM power tool for exploring many completions in parallel.
<br />
<br />
<a href="https://twitter.com/transmissions11/status/1640775967856803840">Announcement</a>
·
<a href="http://flux.paradigm.xyz">Try Online</a>
·
<a href="https://github.com/transmissions11/flux/issues">Report a Bug</a>
<a href="https://github.com/paradigmxyz/flux/issues">Report a Bug</a>
</p>
</div>

Expand Down Expand Up @@ -37,7 +37,7 @@ Visit [flux.paradigm.xyz](https://flux.paradigm.xyz) to try Flux online or follo
## Running Locally

```sh
git clone https://github.com/transmissions11/flux.git
git clone https://github.com/paradigmxyz/flux.git
npm install
npm run dev
```
Expand All @@ -46,4 +46,4 @@ Note: To run the `claude` branch locally, you will also need to [utilize this CO

## Contributing

See the [open issues](https://github.com/transmissions11/flux/issues) for a list of proposed features (and known issues).
See the [open issues](https://github.com/paradigmxyz/flux/issues) for a list of proposed features (and known issues).
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<meta name="twitter:title" content="Flux" />
<meta name="twitter:description" content="LLM power tool." />
<meta name="twitter:image" content="https://flux.paradigm.xyz/meta.jpg" />

<meta name="theme-color" content="#ffffff" />

<meta name="apple-mobile-web-app-title" content="Flux" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
</head>
<body>
<div id="root"></div>
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react-beforeunload": "^2.5.3",
"react-dom": "^18.2.0",
"react-hotkeys-hook": "^4.3.7",
"react-icons": "^4.8.0",
"react-markdown": "^8.0.6",
"react-textarea-autosize": "^8.4.0",
"reactflow": "^11.7.0",
Expand Down
7 changes: 7 additions & 0 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getFluxNodeTypeColor, getFluxNodeTypeDarkColor } from "../utils/color";
import { getPlatformModifierKey, getPlatformModifierKeyText } from "../utils/platform";
import {
API_KEY_LOCAL_STORAGE_KEY,
OPEN_AI_API_KEY_LOCAL_STORAGE_KEY,
DEFAULT_SETTINGS,
FIT_VIEW_SETTINGS,
HOTKEY_CONFIG,
Expand Down Expand Up @@ -855,6 +856,9 @@ function App() {
//////////////////////////////////////////////////////////////*/

const [apiKey, setApiKey] = useLocalStorage<string>(API_KEY_LOCAL_STORAGE_KEY);
const [openApiKey, setOpenApiKey] = useLocalStorage<string>(
OPEN_AI_API_KEY_LOCAL_STORAGE_KEY
);

const isAnythingLoading = isSavingReactFlow || isSavingSettings;

Expand Down Expand Up @@ -992,6 +996,8 @@ function App() {
onClose={onCloseSettingsModal}
apiKey={apiKey}
setApiKey={setApiKey}
openApiKey={openApiKey}
setOpenApiKey={setOpenApiKey}
/>
<Column
mainAxisAlignment="center"
Expand Down Expand Up @@ -1134,6 +1140,7 @@ function App() {
);
}}
submitPrompt={() => submitPrompt(false)}
openApiKey={openApiKey}
/>
) : (
<Column
Expand Down
55 changes: 37 additions & 18 deletions src/components/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useState, useEffect, useRef } from "react";
import TextareaAutosize from "react-textarea-autosize";
import { Node, useReactFlow } from "reactflow";
import { getPlatformModifierKeyText } from "../utils/platform";
import { Whisper } from "./utils/Whisper";

export function Prompt({
lineage,
Expand All @@ -22,6 +23,7 @@ export function Prompt({
newConnectedToSelectedNode,
settings,
setSettings,
openApiKey,
}: {
lineage: Node<FluxNodeData>[];
onType: (text: string) => void;
Expand All @@ -30,6 +32,7 @@ export function Prompt({
newConnectedToSelectedNode: (type: FluxNodeType) => void;
settings: Settings;
setSettings: (settings: Settings) => void;
openApiKey: string | null;
}) {
const { setNodes } = useReactFlow();

Expand Down Expand Up @@ -177,8 +180,8 @@ export function Prompt({
zIndex={10}
variant="outline"
border="0px"
_hover={{ background: "none" }}
p={1}
_hover={{ background: "none" }}
>
{data.streamId ? (
<NotAllowedIcon boxSize={4} />
Expand All @@ -200,25 +203,41 @@ export function Prompt({
crossAxisAlignment="flex-start"
borderRadius="6px"
wordBreak="break-word"
minHeight={
data.fluxNodeType === FluxNodeType.User && isLast && isEditing
? "75px"
: "0px"
}
>
{isLast && isEditing ? (
<TextareaAutosize
id="promptBox"
style={{
width: "100%",
backgroundColor: "transparent",
outline: "none",
}}
value={data.text ?? ""}
onChange={(e) => onType(e.target.value)}
placeholder={
data.fluxNodeType === FluxNodeType.User
? "Write a poem about..."
: data.fluxNodeType === FluxNodeType.System
? "You are ChatGPT..."
: undefined
}
/>
<>
<TextareaAutosize
id="promptBox"
style={{
width: "100%",
backgroundColor: "transparent",
outline: "none",
}}
minRows={data.fluxNodeType === FluxNodeType.User ? 3 : 1}
value={data.text ?? ""}
onChange={(e) => onType(e.target.value)}
placeholder={
data.fluxNodeType === FluxNodeType.User
? "Write a poem about..."
: data.fluxNodeType === FluxNodeType.System
? "You are ChatGPT..."
: undefined
}
/>
{data.fluxNodeType === FluxNodeType.User && (
<Whisper
onConvertedText={(text: string) =>
onType(`${data.text}${data.text ? " " : ""}${text}`)
}
apiKey={openApiKey}
/>
)}
</>
) : (
<Markdown text={data.text} />
)}
Expand Down
13 changes: 13 additions & 0 deletions src/components/modals/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export const SettingsModal = memo(function SettingsModal({
setSettings,
apiKey,
setApiKey,
openApiKey,
setOpenApiKey,
}: {
isOpen: boolean;
onClose: () => void;
settings: Settings;
setSettings: (settings: Settings) => void;
apiKey: string | null;
setApiKey: (apiKey: string) => void;
openApiKey: string | null;
setOpenApiKey: (openApiKey: string) => void;
}) {
const reset = () => {
if (
Expand Down Expand Up @@ -88,6 +92,15 @@ export const SettingsModal = memo(function SettingsModal({

<APIKeyInput mt={4} width="100%" apiKey={apiKey} setApiKey={setApiKey} />

<APIKeyInput
title="OpenAI API Key"
link="https://platform.openai.com/account/api-keys"
mt={4}
width="100%"
apiKey={openApiKey}
setApiKey={setOpenApiKey}
/>

<LabeledSlider
mt={4}
label="Temperature (randomness)"
Expand Down
8 changes: 6 additions & 2 deletions src/components/utils/APIKeyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ import { LabeledPasswordInputWithLink } from "./LabeledInputs";
export function APIKeyInput({
apiKey,
setApiKey,
title,
link,
...others
}: {
apiKey: string | null;
setApiKey: (apiKey: string) => void;
title?: string;
link?: string;
} & BoxProps) {
return (
<LabeledPasswordInputWithLink
width="80%"
label="Anthropic API Key"
label={title ? title : "Anthropic API Key"}
linkLabel="Get a key"
placeholder="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
link="https://console.anthropic.com"
link={link ? link : "https://console.anthropic.com"}
value={apiKey ?? ""}
setValue={setApiKey}
{...others}
Expand Down
41 changes: 40 additions & 1 deletion src/components/utils/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect, memo, ReactNode } from "react";
import ReactMarkdown from "react-markdown";
import "highlight.js/styles/atom-one-light.css";
import rehypeHighlight from "rehype-highlight";
import { Button, Box, Code, Text, useTheme } from "@chakra-ui/react";
import { Button, Box, Code, Text, useTheme, List, ListItem } from "@chakra-ui/react";
import { CopyIcon } from "@chakra-ui/icons";
import { Row, Column } from "../../utils/chakra";
import { copySnippetToClipboard } from "../../utils/clipboard";
Expand Down Expand Up @@ -76,6 +76,40 @@ export const Markdown = memo(function Markdown({ text }: { text: string }) {
[rehypeHighlight, { ignoreMissing: true, languages: { solidity, yul } }],
]}
components={{
ul({ children }) {
return (
<List styleType="disc" h="fit-content">
{children}
</List>
);
},
ol({ children }) {
return (
<List styleType="decimal" h="fit-content">
{children}
</List>
);
},
li({ children }) {
return (
<ListItem as="li" mb="0px" ml="20px">
{children?.filter(
(child: ReactNode) =>
!(typeof child === "string" && child.trim() === "")
)}
</ListItem>
);
},
blockquote({ children }) {
return (
<Box borderLeft="2px solid currentcolor" pl="20px">
{children?.filter(
(child: ReactNode) =>
!(typeof child === "string" && child.trim() === "")
)}
</Box>
);
},
code({ node, inline, className, children, style, ...props }) {
const match = /language-(\w+)/.exec(className || "");

Expand Down Expand Up @@ -136,6 +170,11 @@ const stringifyChildren = (children: ReactNode[]): string => {
);
}

// Ignore non-text ReactNodes, fixing [object Object] error.
if (typeof currentNode === "object") {
return concatenatedText;
}

return concatenatedText + String(currentNode || "");
}, "")
// react-markdown sometimes includes a newline at the end of the children array.
Expand Down
7 changes: 5 additions & 2 deletions src/components/utils/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ export function NavigationBar({
<MenuDivider />

<MenuGroup title="Copy">
<MenuItem command={`${modifierKeyText}C`} onClick={copyMessagesToClipboard}>
<MenuItem
command={`⇧${modifierKeyText}C`}
onClick={copyMessagesToClipboard}
>
Copy messages to clipboard
</MenuItem>
</MenuGroup>
Expand All @@ -234,7 +237,7 @@ export function NavigationBar({
Up to parent node
</MenuItem>
<MenuItem command={`${modifierKeyText}↓`} onClick={moveToChild}>
Down child node
Down to child node
</MenuItem>
</MenuGroup>

Expand Down
Loading

0 comments on commit 8e2e240

Please sign in to comment.