Skip to content

Commit

Permalink
sparkles: feat: Chat v0.1 (lobehub#7)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: canisminor1990 <i@canisminor.cc>
  • Loading branch information
arvinxx and canisminor1990 authored Jul 11, 2023
1 parent 59d381e commit 3db700a
Show file tree
Hide file tree
Showing 83 changed files with 3,460 additions and 90 deletions.
13 changes: 11 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
const config = require('@umijs/lint/dist/config/eslint');
const config = require('@lobehub/lint').eslint;

config.extends.push('plugin:@next/next/recommended');
//config.extends.push('plugin:@next/next/core-web-vitals');

module.exports = {
...config,
extends: ['plugin:@next/next/recommended'],
rules: {
...config.rules,
'react/jsx-sort-props': 'off',
'sort-keys-fix/sort-keys-fix': 'off',
'typescript-sort-keys/interface': 'off',
'unicorn/switch-case-braces': 'off',
},
};
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

58 changes: 39 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# Gitignore for LobeHub
################################################################

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
# general
.DS_Store
.idea
.vscode
.history
.temp
.env.local
venv
temp
tmp

# dependencies
node_modules
*.log
*.lock
package-lock.json

# next.js
/.next/
/out/
# ci
coverage
.coverage
.eslintcache
.stylelintcache

# production
/build
dist
es
lib
logs
test-output

# misc
.DS_Store
*.pem
# umi
.umi
.umi-production
.umi-test
.dumi/tmp*

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# husky
.husky/prepare-commit-msg

# misc
# add other ignore file below

# local env files
.env*.local
Expand All @@ -34,3 +52,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.next
.env
7 changes: 2 additions & 5 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module.exports = {
printWidth: 100,
printWidth: 120,
singleQuote: true,
trailingComma: 'all',
proseWrap: 'never',
endOfLine: 'lf',
overrides: [{ files: '.prettierrc', options: { parser: 'json' } }],
plugins: [
require.resolve('prettier-plugin-packagejson'),
require.resolve('prettier-plugin-organize-imports'),
],
plugins: [require.resolve('prettier-plugin-packagejson'), require.resolve('prettier-plugin-organize-imports')],
pluginSearchDirs: false,
};
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
<a name="readme-top"></a>

<div align="center">

<img width="160" src="https://raw.githubusercontent.com/lobehub/.github/main/profile/Logo.webp">

<img height="120" src="https://npm.elemecdn.com/@lobehub/assets-logo@1.0.0/assets/logo-3d.webp">
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
<img height="120" src="https://npm.elemecdn.com/fluentui-emoji/icons/modern/robot.svg">

<h1>Lobe Chat</h1>

Lobe Chat is an open-source chatgpt client

Lobe Chat is an open-source chatbot client using LangChain

Typescript and Next.js

[Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url]

<!-- SHIELD GROUP -->

[![release][release-shield]][release-url]
[![releaseDate][release-date-shield]][release-date-url]
[![ciTest][ci-test-shield]][ci-test-url]
[![ciRelease][ci-release-shield]][ci-release-url]
<br/>
[![ciRelease][ci-release-shield]][ci-release-url] <br/>
[![contributors][contributors-shield]][contributors-url]
[![forks][forks-shield]][forks-url]
[![stargazers][stargazers-shield]][stargazers-url]
[![issues][issues-shield]][issues-url]
![](https://github.com/othneildrew/Best-README-Template/raw/master/images/screenshot.png)

![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)

</div>

<details>
<summary><kbd>Table of contents</kbd></summary>

#### TOC

- [⌨️ Local Development](#️-local-development)
- [🤝 Contributing](#-contributing)

####

</details>

## ⌨️ Local Development

You can use Gitpod for online development:
Expand All @@ -37,8 +52,8 @@ Or clone it for local development:
```bash
$ git clone https://github.com/lobehub/lobe-chat.git
$ cd canisminor-template
$ npm install
$ npm start
$ pnpm install
$ pnpm start
```

<div align="right">
Expand All @@ -47,7 +62,6 @@ $ npm start

</div>


## 🤝 Contributing

<!-- CONTRIBUTION GROUP -->
Expand Down Expand Up @@ -76,11 +90,11 @@ $ npm start
</div>

---

#### 📝 License

Copyright © 2023 [LobeHub][profile-url]. <br />
This project is [MIT](./LICENSE) licensed.

This project is [MIT](./LICENSE) licensed.

<!-- LINK GROUP -->

Expand Down
9 changes: 0 additions & 9 deletions next.config.js

This file was deleted.

32 changes: 32 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @ts-check
const API_END_PORT_URL = process.env.API_END_PORT_URL || '';

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
pageExtensions: ['page.tsx', 'api.ts'],
transpilePackages: ['@lobehub/ui', 'antd-style'],
webpack(config) {
config.experiments = {
asyncWebAssembly: true,
layers: true,
};

return config;
},

async rewrites() {
return [
{
source: '/api/openai-dev',
destination: `${API_END_PORT_URL}/api/openai`,
},
{
source: '/api/chain-dev',
destination: `${API_END_PORT_URL}/api/chain`,
},
];
},
};

export default nextConfig;
82 changes: 72 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
{
"name": "@lobehub/chat",
"version": "1.1.0",
"private": true,
"description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
"keywords": [
"chatbot",
"ChatGPT",
"LangChain",
"typescript",
"Next.js"
],
"homepage": "https://github.com/lobehub/lobe-chat",
"bugs": {
"url": "https://github.com/lobehub/lobe-chat/issues/new"
},
"repository": {
"type": "git",
"url": "https://github.com/lobehub/lobe-chat.git"
},
"license": "MIT",
"author": "LobeHub <i@lobehub.com>",
"sideEffects": false,
"scripts": {
"build": "next build",
"dev": "PORT=3010 next dev",
"lint": "next lint && npm run ts-check && npm run stylelint",
"lint": "eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
"lint:md": "remark . --quiet --frail --output",
"lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
"prepare": "husky install",
"prettier": "prettier -c --write \"**/**\"",
"release": "semantic-release",
Expand All @@ -14,17 +34,61 @@
"test": "vitest --passWithNoTests",
"test:coverage": "vitest run --coverage --passWithNoTests",
"test:update": "vitest -u",
"ts-check": "tsc --noEmit"
"type-check": "tsc --noEmit"
},
"lint-staged": {
"*.md": [
"remark --quiet --output --",
"prettier --write --no-error-on-unmatched-pattern"
],
"*.json": [
"prettier --write --no-error-on-unmatched-pattern"
],
"*.{js,jsx}": [
"prettier --write",
"stylelint --fix",
"eslint --fix"
],
"*.{ts,tsx}": [
"prettier --parser=typescript --write",
"stylelint --fix",
"eslint --fix"
]
},
"dependencies": {
"@lobehub/ui": "^1",
"@ant-design/colors": "^7",
"@ant-design/icons": "^5",
"@commitlint/cli": "^17",
"@lobehub/ui": "latest",
"@vercel/analytics": "^1",
"ahooks": "^3",
"antd": "^5",
"antd-style": "^3",
"brotli-wasm": "^1",
"chroma-js": "^2",
"fast-deep-equal": "^3",
"gpt-tokenizer": "^2",
"i18next": "^23",
"immer": "^10",
"langchain": "latest",
"next": "^13",
"lodash-es": "^4",
"lucide-react": "latest",
"nanoid": "^4",
"next": "13.4.7",
"polished": "^4",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"react-hotkeys-hook": "^4",
"react-i18next": "^13",
"react-layout-kit": "^1",
"swr": "^2",
"ts-md5": "^1",
"zustand": "^4",
"zustand-utils": "^1"
},
"devDependencies": {
"@commitlint/cli": "^17",
"@lobehub/lint": "^1",
"@next/eslint-plugin-next": "^13",
"@testing-library/jest-dom": "^5",
"@testing-library/react": "^14",
Expand All @@ -36,7 +100,8 @@
"@types/testing-library__jest-dom": "^5",
"@types/uuid": "^9",
"@umijs/lint": "^4",
"@vitest/coverage-c8": "latest",
"@vitest/coverage-v8": "latest",
"commitlint": "^17",
"eslint": "^8",
"husky": "^8",
"jsdom": "^22",
Expand All @@ -50,9 +115,6 @@
"semantic-release": "^21",
"semantic-release-config-gitmoji": "^1",
"stylelint": "^15",
"stylelint-config-clean-order": "^5",
"stylelint-config-recommended": "^12",
"stylelint-order": "^6",
"typescript": "^5",
"vitest": "latest"
}
Expand Down
1 change: 1 addition & 0 deletions src/const/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const OPENAI_SERVICE_ERROR_CODE = 555;
8 changes: 8 additions & 0 deletions src/const/modelTokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { LanguageModel } from '@/types/llm';

export const ModelTokens: Record<LanguageModel, number> = {
[LanguageModel.GPT3_5]: 4096,
[LanguageModel.GPT3_5_16K]: 4096 * 4,
[LanguageModel.GPT4]: 8196,
[LanguageModel.GPT4_32K]: 8196 * 4,
};
Loading

0 comments on commit 3db700a

Please sign in to comment.