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

[pull] main from chathub-dev:main #83

Merged
merged 16 commits into from
Nov 7, 2023
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ A clear and concise description of what the bug is.
**Desktop (please complete the following information):**
- OS: [e.g. Windows]
- Browser [e.g. chrome, brave]
- ChatHub Version [you can find it in ChatHub Settings]
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
geeguard.js
2 changes: 1 addition & 1 deletion manifest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineManifest(async (env) => {
name: '__MSG_appName__',
description: '__MSG_appDesc__',
default_locale: 'en',
version: '1.38.8',
version: '1.39.2',
icons: {
'16': 'src/assets/icon.png',
'32': 'src/assets/icon.png',
Expand Down
114 changes: 57 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,104 +10,104 @@
"devDependencies": {
"@crxjs/vite-plugin": "^2.0.0-beta.18",
"@headlessui/tailwindcss": "^0.2.0",
"@types/humanize-duration": "^3.27.1",
"@types/lodash-es": "^4.17.8",
"@types/md5": "^2.3.2",
"@types/react": "^18.2.18",
"@types/react-color": "^3.0.6",
"@types/react-copy-to-clipboard": "^5.0.4",
"@types/react-dom": "^18.2.7",
"@types/react-scroll-to-bottom": "^4.2.1",
"@types/turndown": "^5.0.1",
"@types/uuid": "^9.0.2",
"@types/webextension-polyfill": "^0.10.2",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"@vitejs/plugin-react": "^4.0.4",
"autoprefixer": "^10.4.14",
"chrome-types": "^0.1.231",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-react": "^7.33.1",
"@types/humanize-duration": "^3.27.2",
"@types/lodash-es": "^4.17.10",
"@types/md5": "^2.3.4",
"@types/react": "18.2.18",
"@types/react-color": "^3.0.9",
"@types/react-copy-to-clipboard": "^5.0.6",
"@types/react-dom": "^18.2.14",
"@types/react-scroll-to-bottom": "^4.2.3",
"@types/turndown": "^5.0.3",
"@types/uuid": "^9.0.6",
"@types/webextension-polyfill": "^0.10.5",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@vitejs/plugin-react": "^4.1.1",
"autoprefixer": "^10.4.16",
"chrome-types": "^0.1.240",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss": "^8.4.27",
"postcss": "^8.4.31",
"postcss-import": "^15.1.0",
"postcss-nesting": "^11.2.2",
"prettier": "^2.8.8",
"postcss-nesting": "^12.0.1",
"prettier": "^3.0.3",
"process": "^0.11.10",
"sass": "^1.64.2",
"sass": "^1.69.5",
"tailwind-scrollbar": "^3.0.5",
"tailwindcss": "^3.3.3",
"typescript": "^5.1.6",
"vite": "4.4.11",
"vite-tsconfig-paths": "^4.2.0"
"tailwindcss": "^3.3.5",
"typescript": "^5.2.2",
"vite": "4.5.0",
"vite-tsconfig-paths": "^4.2.1"
},
"dependencies": {
"@floating-ui/react": "^0.25.0",
"@headlessui/react": "^1.7.16",
"@floating-ui/react": "^0.26.1",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.6",
"@sentry/integrations": "^7.61.1",
"@sentry/react": "^7.61.1",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/integrations": "^7.77.0",
"@sentry/react": "^7.77.0",
"@tanstack/react-router": "^0.0.1-beta.83",
"browser-fs-access": "^0.34.1",
"browser-fs-access": "^0.35.0",
"cachified": "^3.5.4",
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
"dayjs": "^1.11.9",
"eventsource-parser": "^1.0.0",
"framer-motion": "^10.16.0",
"fuse.js": "^6.6.2",
"github-markdown-css": "^5.2.0",
"dayjs": "^1.11.10",
"eventsource-parser": "^1.1.1",
"framer-motion": "^10.16.4",
"fuse.js": "^7.0.0",
"github-markdown-css": "^5.4.0",
"gpt3-tokenizer": "^1.1.5",
"highlight.js": "^11.8.0",
"humanize-duration": "^3.29.0",
"i18next": "^23.4.2",
"highlight.js": "^11.9.0",
"humanize-duration": "^3.30.0",
"i18next": "^23.6.0",
"i18next-browser-languagedetector": "^7.1.0",
"immer": "^9.0.19",
"immer": "^10.0.3",
"inter-ui": "^3.19.3",
"jotai": "^2.3.0",
"jotai": "^2.5.1",
"jotai-immer": "^0.2.0",
"js-base64": "^3.7.5",
"lodash-es": "^4.17.21",
"lucide-react": "^0.287.0",
"lucide-react": "^0.292.0",
"md5": "^2.3.0",
"nanoid": "^4.0.2",
"ofetch": "^1.1.1",
"nanoid": "^5.0.3",
"ofetch": "^1.3.3",
"plausible-tracker": "^0.3.8",
"react": "^18.2.0",
"react-color": "^2.19.3",
"react-confetti-explosion": "^2.1.2",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-i18next": "^13.0.3",
"react-icons": "^4.10.1",
"react-i18next": "^13.3.1",
"react-icons": "^4.11.0",
"react-markdown": "^8.0.7",
"react-node-to-string": "^0.1.1",
"react-node-to-string": "^0.1.2",
"react-scroll-to-bottom": "^4.2.0",
"react-spinners": "^0.13.8",
"react-textarea-autosize": "^8.5.2",
"react-textarea-autosize": "^8.5.3",
"react-viewport-list": "^7.1.1",
"react-wrap-balancer": "^1.0.0",
"react-wrap-balancer": "^1.1.0",
"rehype-highlight": "^6.0.0",
"rehype-stringify": "^9.0.3",
"rehype-stringify": "^9.0.4",
"remark-breaks": "^3.0.3",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"remark-parse": "^10.0.2",
"remark-rehype": "^10.1.0",
"remark-supersub": "^1.0.0",
"slashes": "^3.0.12",
"swr": "^2.2.0",
"tailwind-merge": "^1.14.0",
"swr": "^2.2.4",
"tailwind-merge": "^2.0.0",
"turndown": "^7.1.2",
"unified": "^10.1.2",
"uuid": "^9.0.0",
"uuid": "^9.0.1",
"webextension-polyfill": "^0.10.0",
"websocket-as-promised": "^2.0.1",
"zod": "^3.21.4"
"zod": "^3.22.4"
},
"packageManager": "[email protected]"
}
3 changes: 3 additions & 0 deletions src/app/bots/chatgpt-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export class ChatGPTApiBot extends AbstractChatGPTApiBot {

private getModelName() {
const { chatgptApiModel } = this.config
if (chatgptApiModel === 'gpt-4-turbo') {
return 'gpt-4-1106-preview'
}
return chatgptApiModel
}

Expand Down
9 changes: 7 additions & 2 deletions src/app/bots/gradio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ interface ConversationContext {
export class GradioBot extends AbstractBot {
private conversationContext?: ConversationContext

constructor(public wsUrl: string, public model: string, public params: number[], public mode?: 'text' | 'html') {
constructor(
public wsUrl: string,
public model: string,
public params: number[],
public mode?: 'text' | 'html',
) {
super()
}

Expand Down Expand Up @@ -104,7 +109,7 @@ export class GradioBot extends AbstractBot {
try {
await wsp.open()
} catch (err) {
console.error('lmsys ws open error', err)
console.error('WS open error', err)
throw new ChatError('Failed to establish websocket connection.', ErrorCode.NETWORK_ERROR)
}

Expand Down
6 changes: 5 additions & 1 deletion src/app/bots/lmsys/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import WebSocketAsPromised from 'websocket-as-promised'
import { GradioBot } from '../gradio'
import { ChatError, ErrorCode } from '~utils/errors'

export class LMSYSBot extends GradioBot {
constructor(model: string) {
Expand Down Expand Up @@ -27,7 +28,10 @@ export class LMSYSBot extends GradioBot {
resolve()
}
})
wsp.open().catch((err) => reject(err))
wsp.open().catch((err) => {
console.error('lmsys ws open error', err)
reject(new ChatError('Failed to establish websocket connection.', ErrorCode.LMSYS_WS_ERROR))
})
})
}

Expand Down
11 changes: 9 additions & 2 deletions src/app/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { cx } from '~/utils'
import { ButtonHTMLAttributes, FC, ReactNode } from 'react'
import { BeatLoader } from 'react-spinners'
import React from 'react'
import { motion } from 'framer-motion'

export interface Props {
text: string
Expand All @@ -13,11 +15,12 @@ export interface Props {
icon?: ReactNode
}

const Button: FC<Props> = (props) => {
const Button = React.forwardRef<HTMLButtonElement, Props>((props, ref) => {
const size = props.size || 'normal'
const type = props.type || 'button'
return (
<button
ref={ref}
type={type}
className={cx(
size === 'normal' && 'text-base font-medium px-6 py-[5px] rounded-full',
Expand All @@ -38,6 +41,10 @@ const Button: FC<Props> = (props) => {
)}
</button>
)
}
})

Button.displayName = 'Button'

export default Button

export const MotionButton = motion(Button)
11 changes: 11 additions & 0 deletions src/app/components/Chat/ErrorAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ const ErrorAction: FC<{ error: ChatError }> = ({ error }) => {
</p>
)
}
if (error.code === ErrorCode.LMSYS_WS_ERROR) {
return (
<p className="ml-2 text-secondary-text text-sm">
Please visit{' '}
<a href="https://chat.lmsys.org" target="_blank" rel="noreferrer" className="underline">
LMSYS.org
</a>{' '}
and try again
</p>
)
}
if (
error.code === ErrorCode.NETWORK_ERROR ||
(error.code === ErrorCode.UNKOWN_ERROR && error.message.includes('Failed to fetch'))
Expand Down
Loading