Skip to content
This repository has been archived by the owner on Feb 28, 2025. It is now read-only.

Commit

Permalink
Merge pull request #25 from smallcloudai/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
MarcMcIntosh authored May 23, 2024
2 parents 71100d2 + 9934450 commit fb38ca4
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 18 deletions.
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

0 comments on commit fb38ca4

Please sign in to comment.