Skip to content

Commit

Permalink
feat: update repo name and fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
3Alan committed May 7, 2023
1 parent d06f40e commit 491982f
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 2,388 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DocsMind is an open-source project that allows you to chat with your docs.

## Demo

[Demo Site](https://chat-markdown.alanwang.site/)
[Demo Site](https://docs-mind.alanwang.site/)

Deploy on Vercel and Railway

Expand Down Expand Up @@ -54,7 +54,7 @@ If you find this project helpful, please consider giving it a star 🌟

> **Warning**
>
> Please check if you can access OpenAI in your region, you can refer to the [issue](https://github.com/3Alan/chat-markdown/issues/3#issuecomment-1511470063) for more information.
> Please check if you can access OpenAI in your region, you can refer to the [issue](https://github.com/3Alan/DocsMind/issues/3#issuecomment-1511470063) for more information.
1. Create .env(Optional)

Expand Down
6 changes: 5 additions & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chat With Markdown</title>
<title>DocsMind</title>
<meta
name="description"
content="DocsMind allows you to chat with your docs and summarize your docs, support pdf, md."
/>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "chat-markdown",
"name": "docs-mind",
"private": true,
"version": "0.0.0",
"type": "module",
Expand Down
6 changes: 6 additions & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useEffect, useState } from 'react';
import request from './utils/request';
import FileItem from './constants/fileItem';
import { CurrentFileContext } from './context/currentFile';
import eventEmitter from './utils/eventEmitter';

const App = () => {
const [currentFile, setCurrentFile] = useState<FileItem | null>(null);
Expand All @@ -34,6 +35,11 @@ const App = () => {

useEffect(() => {
getFileList();

eventEmitter.on('refreshFileList', getFileList);
return () => {
eventEmitter.off('refreshFileList', getFileList);
};
}, []);

return (
Expand Down
18 changes: 15 additions & 3 deletions client/src/components/sideMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Alert, Button, Divider } from 'antd';
import { Alert, Button, Divider, Space } from 'antd';
import FileItem from '../../constants/fileItem';
import FileCard from '../fileCard';
import FileUpload from '../upload';
import { GithubOutlined, SettingOutlined } from '@ant-design/icons';

interface SideMenuProps {
fileList: FileItem[];
Expand Down Expand Up @@ -39,7 +40,7 @@ export default function SideMenu({
description={
<>
The upload is not available on the current website. You can
<a href="https://github.com/3Alan/chat-markdown" target="__blank">
<a href="https://github.com/3Alan/DocsMind" target="__blank">
{' '}
fork and clone the project{' '}
</a>
Expand All @@ -51,7 +52,18 @@ export default function SideMenu({
<FileUpload />
)}

<Button onClick={onOpenSetting}>Setting</Button>
<div className="mt-2 flex justify-between items-center">
<span className="text-xs text-gray-500">Made by Alan</span>

<Space>
<Button
href="https://github.com/3Alan/DocsMind"
target="__blank"
icon={<GithubOutlined />}
></Button>
<Button icon={<SettingOutlined />} onClick={onOpenSetting}></Button>
</Space>
</div>
</div>
);
}
2 changes: 2 additions & 0 deletions client/src/components/upload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useState } from 'react';
import confetti from 'canvas-confetti';
import { baseURL } from '../../utils/request';
import useOpenAiKey from '../../utils/useOpenAiKey';
import eventEmitter from '../../utils/eventEmitter';

const { Dragger } = Upload;

Expand All @@ -29,6 +30,7 @@ export default function FileUpload() {
content: `${info.file.name} file uploaded successfully. token usage: 💰 ${info.file.response}`,
duration: 8
});
eventEmitter.emit('refreshFileList');
setUploading(false);
} else if (status === 'error') {
void message.error(
Expand Down
1 change: 1 addition & 0 deletions client/src/utils/eventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import mitt from 'mitt';
type Events = {
scrollToPage: { pageNo: number; time: number };
cleanChat?: null;
refreshFileList?: null;
};

const eventEmitter = mitt<Events>();
Expand Down
2 changes: 1 addition & 1 deletion server/create_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_index(filepath, filename) -> int:
# TODO: 利用 langchain splitter重写 https://python.langchain.com/en/latest/modules/indexes/text_splitters/examples/markdown.html
# 直接将markdown分段再分别转化成html,最后将所有html拼接起来并加上chunk_id
loader = CustomReader()
documents = loader.load_data(html=html, filename=name)
documents = loader.load_data(html=html, file=filepath)
elif ext == ".html":
# TODO:
pass
Expand Down
4 changes: 2 additions & 2 deletions server/custom_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Init params."""
super().__init__(*args, **kwargs)

def load_data(self, html, filename) -> List[Document]:
def load_data(self, html, file) -> List[Document]:
soup = BeautifulSoup(html, "html.parser")
current_chunk_text = ""
current_chunk_id = 1
Expand Down Expand Up @@ -109,7 +109,7 @@ def load_data(self, html, filename) -> List[Document]:
current_chunk_id += 1

# 保存修改后的HTML文件
with open(f"{staticPath}/html/{filename}.html", "w", encoding="utf-8") as f:
with open(file, "w", encoding="utf-8") as f:
f.write(str(soup))

return document_list
4 changes: 4 additions & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ blinker==1.6.2
bs4==0.0.1
cachetools==5.3.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.3
colorama==0.4.6
commonmark==0.9.1
cryptography==40.0.2
dataclasses-json==0.5.7
Deprecated==1.2.13
et-xmlfile==1.1.0
Expand Down Expand Up @@ -52,7 +54,9 @@ openapi-schema-pydantic==1.2.4
openpyxl==3.1.2
packaging==23.0
pandas==1.5.3
pdfminer.six==20221105
Pillow==9.4.0
pycparser==2.21
pydantic==1.10.7
Pygments==2.14.0
pymdown-extensions==9.10
Expand Down
Loading

0 comments on commit 491982f

Please sign in to comment.