Skip to content

Commit 4655f92

Browse files
authored
Merge pull request #748 from vishnoianil/doc-conv-flag
Add flag to enable or disable knowledge document conversion
2 parents 652516e + 116289a commit 4655f92

File tree

10 files changed

+78
-37
lines changed

10 files changed

+78
-37
lines changed

.env.github.example

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
IL_UI_ADMIN_USERNAME=admin # user/pass for dev mode
2-
IL_UI_ADMIN_PASSWORD=password
31
IL_UI_DEPLOYMENT=github # Start UI stack in github mode.
42
OAUTH_GITHUB_ID=<OAUTH_APP_ID>
53
OAUTH_GITHUB_SECRET=<OAUTH_APP_SECRET>
@@ -12,14 +10,14 @@ NEXT_PUBLIC_TAXONOMY_DOCUMENTS_REPO=github.com/instructlab-public/taxonomy-knowl
1210
NEXT_PUBLIC_AUTHENTICATION_ORG=<AUTHENTICATION_ORG>
1311
NEXT_PUBLIC_TAXONOMY_REPO_OWNER=<GITHUB_ACCOUNT>
1412
NEXT_PUBLIC_TAXONOMY_REPO=<REPO_NAME>
15-
16-
IL_GRANITE_API=<GRANITE_HOST>
17-
IL_GRANITE_MODEL_NAME=<GRANITE_MODEL_NAME>
18-
IL_MERLINITE_API=<MERLINITE_HOST>
19-
IL_MERLINITE_MODEL_NAME=<MERLINITE_MODEL_NAME>
20-
21-
IL_ENABLE_DEV_MODE=true #Enable this option if you want to enable UI features that helps in development, such as form Auto-Fill feature.
22-
2313
NEXT_PUBLIC_EXPERIMENTAL_FEATURES=false
2414

2515
SLACK_WEBHOOK_URL=
16+
17+
# (Optional) Enable this option if you want to enable UI features that helps in development, such as form Auto-Fill feature.
18+
# Default: false
19+
IL_ENABLE_DEV_MODE=false
20+
21+
# (Optional) Enable document conversion. Any non-markdown file will be converted to markdown file
22+
# Default: false
23+
IL_ENABLE_DOC_CONVERSION=false

.env.native.example

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@ IL_UI_ADMIN_PASSWORD=password
55
NEXTAUTH_SECRET=your_super_secret_random_string
66
NEXTAUTH_URL=http://localhost:3000
77

8-
IL_UI_DEPLOYMENT=native # Two deployment modes are available: github and native
9-
IL_ENABLE_DEV_MODE=true #Enable this option if you want to enable UI features that helps in development, such as form Auto-Fill feature.
8+
# (Optional) Enable this option if you want to enable UI features that helps in development, such as form Auto-Fill feature.
9+
# Default: false
10+
IL_ENABLE_DEV_MODE=false
1011

11-
NEXT_PUBLIC_TAXONOMY_ROOT_DIR= # Required value. Recommended /<INSERT_HOME_DIRECTORY_PATH>/.instructlab-ui
12+
# (Optional) Enable document conversion. Any non-markdown file will be converted to markdown file
13+
# Default: false
14+
IL_ENABLE_DOC_CONVERSION=false
1215

16+
# (Optional) Document conversion requires docling service to convert the documents.
17+
# Uncomment and fill in the http://host:port where docling service is running.
18+
# By default it assuming docling service is running on local host listening on port 5001
19+
# IL_FILE_CONVERSION_SERVICE=http://localhost:5001
20+
21+
# (Required) Set to the parent directory where taxonomy repo is cloned.
22+
NEXT_PUBLIC_TAXONOMY_ROOT_DIR=
23+
24+
# (Optional)Enable experiment features like synthetic data generation, training, and chat evaluation.
1325
NEXT_PUBLIC_EXPERIMENTAL_FEATURES=false
1426

15-
# IL_FILE_CONVERSION_SERVICE=http://localhost:5001 # Uncomment and fill in the http://host:port if the docling conversion service is running.
16-
# NEXT_PUBLIC_API_SERVER=http://localhost:8080 # Uncomment and point to the URL the api-server is running on. Native mode only and needs to be running on the same host as the UI.
17-
# NEXT_PUBLIC_MODEL_SERVER_URL=http://x.x.x.x # Used for model chat evaluation vLLM instances. Currently, server side rendering is not supported so the client must have access to this address for model chat evaluation to function in the UI. Currently ports, 8000 & 8001 are hardcoded and why it is not an option to set.
27+
# (Optional) Uncomment and point to the URL the api-server is running on. Native mode only and needs
28+
# to be running on the same host as the UI.
29+
# NEXT_PUBLIC_API_SERVER=http://localhost:8080

deploy/podman/github/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ kubectl create secret generic ui-env \
3232
--from-literal=IL_MERLINITE_API="" \
3333
--from-literal=IL_MERLINITE_MODEL_NAME="" \
3434
--from-literal=IL_ENABLE_DEV_MODE=false \
35+
--from-literal=IL_ENABLE_DOC_CONVERSION=false \
3536
--dry-run=client -o yaml > secret.yaml
3637
```
3738

deploy/podman/github/instructlab-ui.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ spec:
118118
secretKeyRef:
119119
name: ui-env
120120
key: IL_ENABLE_DEV_MODE
121+
- name: IL_ENABLE_DOC_CONVERSION
122+
valueFrom:
123+
secretKeyRef:
124+
name: ui-env
125+
key: IL_ENABLE_DOC_CONVERSION
121126
ports:
122127
- containerPort: 3000
123128
hostPort: 3000

deploy/podman/github/secret.yaml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ data:
1616
IL_MERLINITE_API: ""
1717
IL_MERLINITE_MODEL_NAME: ""
1818
IL_ENABLE_DEV_MODE: ""
19+
IL_ENABLE_DOC_CONVERSION: ""
1920
kind: Secret
2021
metadata:
2122
creationTimestamp: null

deploy/podman/native/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ kubectl create secret generic ui-env \
2525
--from-literal=NEXT_PUBLIC_TAXONOMY_ROOT_DIR="<TAXONOMY_ROOT_DIR>" \
2626
--from-literal=NEXT_PUBLIC_EXPERIMENTAL_FEATURES="false" \
2727
--from-literal=IL_ENABLE_DEV_MODE=false \
28+
--from-literal=IL_ENABLE_DOC_CONVERSION=false \
2829
--dry-run=client -o yaml > secret.yaml
2930
```
3031

deploy/podman/native/instructlab-ui.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ spec:
8383
secretKeyRef:
8484
name: ui-env
8585
key: IL_ENABLE_DEV_MODE
86+
- name: IL_ENABLE_DOC_CONVERSION
87+
valueFrom:
88+
secretKeyRef:
89+
name: ui-env
90+
key: IL_ENABLE_DOC_CONVERSION
8691
- name: NEXT_PUBLIC_API_SERVER
8792
valueFrom:
8893
secretKeyRef:

deploy/podman/native/secret.yaml.example

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
apiVersion: v1
22
data:
3-
IL_UI_ADMIN_PASSWORD: <PASSWORD>
4-
IL_UI_ADMIN_USERNAME: <USERNAME>
5-
IL_UI_DEPLOYMENT: <UI_DEPLOYMENT>
6-
IL_ENABLE_DEV_MODE: <DEV_MODE>
7-
NEXT_PUBLIC_EXPERIMENTAL_FEATURES: <EXPERIMENTAL_FEATURES>
8-
NEXT_PUBLIC_TAXONOMY_ROOT_DIR: <TAXONOMY_ROOT_DIR>
9-
NEXTAUTH_URL: <AUTH_URL>
10-
NEXTAUTH_SECRET: <AUTH_SECRET>
11-
NEXT_PUBLIC_API_SERVER: <API_SERVER_URL>
3+
IL_UI_ADMIN_PASSWORD: ""
4+
IL_UI_ADMIN_USERNAME: ""
5+
IL_UI_DEPLOYMENT: ""
6+
IL_ENABLE_DEV_MODE: ""
7+
IL_ENABLE_DOC_CONVERSION: ""
8+
NEXT_PUBLIC_EXPERIMENTAL_FEATURES: ""
9+
NEXT_PUBLIC_TAXONOMY_ROOT_DIR: ""
10+
NEXTAUTH_URL: ""
11+
NEXTAUTH_SECRET: ""
12+
NEXT_PUBLIC_API_SERVER: ""
1213

1314
kind: Secret
1415
metadata:

src/app/api/envConfig/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export async function GET() {
1616
UPSTREAM_REPO_NAME: process.env.NEXT_PUBLIC_TAXONOMY_REPO || '',
1717
DEPLOYMENT_TYPE: process.env.IL_UI_DEPLOYMENT || '',
1818
ENABLE_DEV_MODE: process.env.IL_ENABLE_DEV_MODE || 'false',
19+
ENABLE_DOC_CONVERSION: process.env.IL_ENABLE_DOC_CONVERSION || 'false',
1920
EXPERIMENTAL_FEATURES: process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES || '',
2021
TAXONOMY_ROOT_DIR: process.env.NEXT_PUBLIC_TAXONOMY_ROOT_DIR || '',
2122
TAXONOMY_KNOWLEDGE_DOCUMENT_REPO:

src/components/Contribute/Knowledge/UploadFile.tsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,23 @@ export const UploadFile: React.FunctionComponent<UploadFileProps> = ({ existingF
4545
const [showExistingFilesStatus, setExistingFilesStatus] = useState(false);
4646
const [showOverwriteModal, setShowOverwriteModal] = useState(false);
4747
const [showFileDeleteModal, setShowFileDeleteModal] = useState(false);
48+
const [enableDocConversion, setEnableDocConversion] = useState(false);
4849
const [fileToDelete, setFileToDelete] = useState<string[]>([]);
4950
const [filesToOverwrite, setFilesToOverwrite] = useState<File[]>([]);
5051
const [droppedFiles, setDroppedFiles] = React.useState<File[] | undefined>();
5152
const [statusIcon, setStatusIcon] = useState<'inProgress' | 'success' | 'danger'>('inProgress');
5253
const [modalText, setModalText] = useState('');
5354
React.useContext(MultipleFileUploadContext);
5455

56+
useEffect(() => {
57+
const getEnvVariables = async () => {
58+
const res = await fetch('/api/envConfig');
59+
const envConfig = await res.json();
60+
setEnableDocConversion(envConfig.ENABLE_DOC_CONVERSION === 'true');
61+
};
62+
getEnvVariables();
63+
}, []);
64+
5565
useEffect(() => {
5666
if (filesToUpload.length > 0) {
5767
setShowNewFilesStatus(true);
@@ -111,17 +121,19 @@ export const UploadFile: React.FunctionComponent<UploadFileProps> = ({ existingF
111121
setShowFileDeleteModal(false);
112122
};
113123

114-
// Define allowed file types
115-
const allowedFileTypes: { [mime: string]: string[] } = {
116-
'application/pdf': ['.pdf'],
117-
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': ['.docx'],
118-
'application/vnd.openxmlformats-officedocument.presentationml.presentation': ['.pptx'],
119-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': ['.xlsx'],
120-
'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.svg'],
121-
'text/html': ['.html'],
122-
'text/asciidoc': ['.adoc'],
123-
'text/markdown': ['.md']
124-
};
124+
// Define allowed file types. If doc conversion is not enabled, only allow markdown files.
125+
const allowedFileTypes: { [mime: string]: string[] } = enableDocConversion
126+
? {
127+
'application/pdf': ['.pdf'],
128+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': ['.docx'],
129+
'application/vnd.openxmlformats-officedocument.presentationml.presentation': ['.pptx'],
130+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': ['.xlsx'],
131+
'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.svg'],
132+
'text/html': ['.html'],
133+
'text/asciidoc': ['.adoc'],
134+
'text/markdown': ['.md']
135+
}
136+
: { 'text/markdown': ['.md'] };
125137

126138
// Handle drop (and re-drop) of files
127139
const handleFileDrop = (_event: DropEvent, files: File[]) => {
@@ -262,7 +274,11 @@ export const UploadFile: React.FunctionComponent<UploadFileProps> = ({ existingF
262274
<MultiFileUploadArea
263275
titleIcon={<UploadIcon />}
264276
titleText="Drag and drop files here or upload"
265-
infoText="Accepted file types include PDF, DOCX, PPTX, XLSX, HTML, AsciiDoc, Markdown, and images. All files will be converted to Markdown."
277+
infoText={
278+
enableDocConversion
279+
? 'Accepted file types include PDF, DOCX, PPTX, XLSX, HTML, AsciiDoc, Markdown, and images. All files will be converted to Markdown.'
280+
: 'Accepted file type: Markdown'
281+
}
266282
uploadText="Upload from device"
267283
manualUploadText="Upload from git repository"
268284
onManualUpload={() => setShowUploadFromGitModal(true)}

0 commit comments

Comments
 (0)