Skip to content

Commit

Permalink
Feat/0.1.9.4 (#140)
Browse files Browse the repository at this point in the history
支持多版本
适配新的unstructured
  • Loading branch information
yaojin3616 committed Nov 10, 2023
2 parents 2f787c0 + 283cb34 commit 477bf79
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
qdrant_storage
autogen_coding/

# Mac
.DS_Store
Expand Down
4 changes: 3 additions & 1 deletion docker/bisheng/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ database_url:
# 缓存配置 redis://[[username]:[password]]@localhost:6379/0
redis_url: "redis://redis:6379/0"

environment: "dev"
environment:
env: dev
uns_support: ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'txt', 'md', 'html']

# admin 用户配置
admin:
Expand Down
4 changes: 2 additions & 2 deletions src/backend/bisheng/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Optional
from typing import Optional, Union

import yaml
from bisheng.database.models.config import Config
Expand Down Expand Up @@ -27,7 +27,7 @@ class Settings(BaseSettings):
input_output: dict = {}
output_parsers: dict = {}
dev: bool = False
environment: str = 'dev'
environment: Union[dict, str] = 'dev'
database_url: Optional[str] = None
redis_url: Optional[str] = None
admin: dict = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def _completion_with_retry(**kwargs: Any) -> Any:
url = f'{self.host_base_url}/{self.model_name}/infer'
resp = self.client(url=url, json=params).json()

if resp.get('choices', []):
if not resp.get('choices', []):
logger.error(f'host_llm_response response={resp}')
raise ValueError('empty choices in llm chat result')

resp['usage'] = {}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bisheng",
"version": "0.1.9",
"version": "0.1.9.4",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.1",
Expand Down
9 changes: 6 additions & 3 deletions src/frontend/src/contexts/locationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const initialValue = {
setExtraNavigation: () => { },
extraComponent: <></>,
setExtraComponent: () => { },
appConfig: {}
appConfig: { libAccepts: [] }
};

export const locationContext = createContext<locationContextType>(initialValue);
Expand All @@ -61,13 +61,16 @@ export function LocationProvider({ children }: { children: ReactNode }) {
const [showSideBar, setShowSideBar] = useState(initialValue.showSideBar);
const [extraNavigation, setExtraNavigation] = useState({ title: "" });
const [extraComponent, setExtraComponent] = useState(<></>);
const [appConfig, setAppConfig] = useState<any>({})
const [appConfig, setAppConfig] = useState<any>({
libAccepts: []
})

// 获取系统配置
useEffect(() => {
getAppConfig().then(res => {
setAppConfig({
isDev: res.data.data === 'dev'
isDev: res.data.data.env === 'dev',
libAccepts: res.data.data.uns_support
})
})
}, [])
Expand Down
9 changes: 3 additions & 6 deletions src/frontend/src/modals/UploadModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { subUploadLibFile } from "../../controllers/API";
import { uploadFileWithProgress } from "./upload";

let qid = 1
export default function UploadModal({ id, open, desc = '', children = null, setOpen }) {
export default function UploadModal({ id, accept, open, desc = '', children = null, setOpen }) {
const { t } = useTranslation()
// const [file, setFile] = useState(null);
// const [progress, setProgress] = useState(0);
Expand Down Expand Up @@ -149,10 +149,7 @@ export default function UploadModal({ id, open, desc = '', children = null, setO

const { getRootProps, getInputProps, isDragActive } = useDropzone({
accept: {
'application/*': ['.pdf', '.doc', '.docx'],
// 'application/*': ['.doc', '.docx', '.pdf', '.ppt', '.pptx', '.tsv', '.xlsx'],
'image/*': ['.jpeg', '.png', '.jpg', '.tiff'],
// 'text/*': ['.csv', '.html', '.json', '.md', '.msg', '.txt', '.xml'],
'application/*': accept.map(str => `.${str}`)
},
useFsAccessApi: false,
onDrop
Expand Down Expand Up @@ -204,4 +201,4 @@ export default function UploadModal({ id, open, desc = '', children = null, setO
</div>
</form>
</dialog>
};
};
7 changes: 5 additions & 2 deletions src/frontend/src/pages/FileLibPage/files.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import {
} from "../../components/ui/tabs";

import { ArrowLeft } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { useContext, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import ShadTooltip from "../../components/ShadTooltipComponent";
import { deleteFile, readFileByLibDatabase } from "../../controllers/API";
import UploadModal from "../../modals/UploadModal";
import { locationContext } from "../../contexts/locationContext";

export default function FilesPage() {
const { t } = useTranslation()

Expand All @@ -37,6 +39,7 @@ export default function FilesPage() {
const pages = useRef(1)

const [hasPermission, setHasPermission] = useState(true)
const { appConfig } = useContext(locationContext)

const loadPage = (_page) => {
setLoading(true)
Expand Down Expand Up @@ -128,7 +131,7 @@ export default function FilesPage() {
</TabsContent>
<TabsContent value="password"></TabsContent>
</Tabs>
<UploadModal id={id} open={open} setOpen={handleOpen}></UploadModal>
<UploadModal id={id} accept={appConfig.libAccepts} open={open} setOpen={handleOpen}></UploadModal>
{/* Delete confirmation */}
<dialog className={`modal ${delShow && 'modal-open'}`}>
<form method="dialog" className="modal-box w-[360px] bg-[#fff] shadow-lg dark:bg-background">
Expand Down

0 comments on commit 477bf79

Please sign in to comment.