Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha #25

Merged
merged 16 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ jobs:
- run: npm run types
- run: npm run lint
- run: npm run build

- run: |
name=$(echo -n "${{ matrix.node-version }}" | tr -cd '[[:alnum:]]')
echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV

- name: Upload artifacts
uses: actions/upload-artifact@v4

with:
name: refact-chat-js-${{ env.ARTIFACT_NAME }}
if-no-files-found: ignore
path: ./dist
4 changes: 2 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import type { Preview } from "@storybook/react";
import "@radix-ui/themes/styles.css";
import { Theme } from "@radix-ui/themes";
import { Theme } from "../src/components/Theme";

const preview: Preview = {
parameters: {
Expand All @@ -16,7 +16,7 @@ const preview: Preview = {
},
decorators: [
(Page) => (
<Theme>
<Theme accentColor="gray">
<Page />
</Theme>
),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "refact-chat-js",
"version": "1.0.1-alpha.1",
"version": "1.0.1-alpha.4",
"type": "module",
"license": "BSD-3-Clause",
"files": [
Expand Down
7 changes: 2 additions & 5 deletions src/components/ChatContent/ChatContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useImperativeHandle } from "react";
import { ChatMessages, isChatContextFileMessage } from "../../services/refact";
import { Markdown, MarkdownProps } from "../Markdown";
import { MarkdownProps } from "../Markdown";
import { UserInput } from "./UserInput";
import { ScrollArea } from "../ScrollArea";
import { Spinner } from "../Spinner";
Expand Down Expand Up @@ -82,12 +82,9 @@ export const ChatContent = React.forwardRef<HTMLDivElement, ChatContentProps>(
{text}
</AssistantInput>
);
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if (role === "system") {
} else {
return null;
// return <SystemInput key={index}>{text}</SystemInput>;
} else {
return <Markdown key={index}>{text}</Markdown>;
}
})}
{isWaiting && <Spinner />}
Expand Down
3 changes: 2 additions & 1 deletion src/components/FIMDebug/SymoblList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const SymbolText: React.FC<{
>
{withIcon ? (
<>
🔎 <TruncateLeft className={styles.symbol}>{children}</TruncateLeft>
🔎&nbsp;
<TruncateLeft className={styles.symbol}>{children}</TruncateLeft>
</>
) : (
children
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileList/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const FileList: React.FC<FileListProps> = ({ files }) => {
title={file.file_content}
className={styles.file}
>
📎 <TruncateLeft>{name}</TruncateLeft>
📎&nbsp;<TruncateLeft>{name}</TruncateLeft>
</Text>
);
})}
Expand Down
10 changes: 6 additions & 4 deletions src/hooks/useEventBusForChat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,19 @@ function formatChatResponse(
return acc.concat([[cur.delta.role, cur.delta.content]]);
}

if (acc.length === 0) {
if (acc.length === 0 && cur.delta.role) {
return acc.concat([[cur.delta.role, cur.delta.content]]);
}

const lastMessage = acc[acc.length - 1];
if (lastMessage[0] === "assistant") {
const last = acc.slice(0, -1);
const currentMessage = lastMessage[1];
return last.concat([
[cur.delta.role, currentMessage + cur.delta.content],
]);
return last.concat([["assistant", currentMessage + cur.delta.content]]);
}

if (cur.delta.role === null) {
return acc;
}

return acc.concat([[cur.delta.role, cur.delta.content]]);
Expand Down
4 changes: 2 additions & 2 deletions src/services/refact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ export function isChatContextFileMessage(
}

interface BaseDelta {
role: ChatRole;
role: ChatRole | null;
}

interface AssistantDelta extends BaseDelta {
role: "assistant";
role: "assistant" | null;
content: string;
}
interface ChatContextFileDelta extends BaseDelta {
Expand Down
Loading