Skip to content

Commit 16aa22a

Browse files
committed
Make fine-tune and chat eval feature Podman ready
Signed-off-by: Anil Vishnoi <[email protected]>
1 parent a6db80f commit 16aa22a

File tree

11 files changed

+252
-172
lines changed

11 files changed

+252
-172
lines changed

api-server/handlers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,8 @@ func (srv *ILabServer) serveModelHandler(modelPath, port string, w http.Response
807807
}
808808

809809
cmdArgs := []string{
810-
"serve", "model",
811-
"--model", modelPath,
810+
"serve",
811+
"--model-path", modelPath,
812812
"--host", "0.0.0.0",
813813
"--port", port,
814814
}

deploy/podman/native/instructlab-ui.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ spec:
120120
secretKeyRef:
121121
name: ui-env
122122
key: IL_ENABLE_DEV_MODE
123+
- name: NEXT_PUBLIC_API_SERVER
124+
valueFrom:
125+
secretKeyRef:
126+
name: ui-env
127+
key: NEXT_PUBLIC_API_SERVER
123128
ports:
124129
- containerPort: 3000
125130
hostPort: 3000

deploy/podman/native/secret.yaml.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ data:
88
NEXT_PUBLIC_TAXONOMY_ROOT_DIR: <TAXONOMY_ROOT_DIR>
99
NEXTAUTH_URL: <AUTH_URL>
1010
NEXTAUTH_SECRET: <AUTH_SECRET>
11+
NEXT_PUBLIC_API_SERVER: <API_SERVER_URL>
12+
1113
kind: Secret
1214
metadata:
1315
creationTimestamp: null

installers/podman/ilab-ui-native-installer.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare AUTH_SECRET="your_super_secret_random_string"
1717
declare DEV_MODE="false"
1818
declare EXPERIMENTAL_FEATURES=""
1919
declare PYENV_DIR=""
20+
declare API_SERVER_URL=""
2021

2122
BINARY_INSTALL_DIR=./
2223
IS_ILAB_INSTALLED="true"
@@ -350,6 +351,8 @@ if [[ "$COMMAND" == "install" ]]; then
350351
EXPERIMENTAL_FEATURES_B64=$(echo -n "false" | base64)
351352
fi
352353

354+
API_SERVER_URL_B64=$(echo -n "$API_SERVER_URL" | base64)
355+
353356
# Download secret.yaml file
354357
echo -e "${green}Downloading the secret.yaml sample file...${reset}\n"
355358
curl -o secret.yaml https://raw.githubusercontent.com/instructlab/ui/main/deploy/podman/native/secret.yaml.example
@@ -370,6 +373,7 @@ if [[ "$COMMAND" == "install" ]]; then
370373
sed -i "" "s|<AUTH_SECRET>|$AUTH_SECRET_B64|g" secret.yaml
371374
sed -i "" "s|<DEV_MODE>|$DEV_MODE_B64|g" secret.yaml
372375
sed -i "" "s|<EXPERIMENTAL_FEATURES>|$EXPERIMENTAL_FEATURES_B64|g" secret.yaml
376+
sed -i "" "s|<API_SERVER_URL>|$API_SERVER_URL_B64|g" secret.yaml
373377
else
374378
sed -i "s|<UI_DEPLOYMENT>|$UI_DEPLOYMENT_B64|g" secret.yaml
375379
sed -i "s|<USERNAME>|$USERNAME_B64|g" secret.yaml
@@ -379,6 +383,7 @@ if [[ "$COMMAND" == "install" ]]; then
379383
sed -i "s|<AUTH_SECRET>|$AUTH_SECRET_B64|g" secret.yaml
380384
sed -i "s|<DEV_MODE>|$DEV_MODE_B64|g" secret.yaml
381385
sed -i "s|<EXPERIMENTAL_FEATURES>|$EXPERIMENTAL_FEATURES_B64|g" secret.yaml
386+
sed -i "s|<API_SERVER_URL>|$API_SERVER_URL_B64|g" secret.yaml
382387
fi
383388

384389
if [[ "$IS_ILAB_INSTALLED" == "true" ]]; then
@@ -420,7 +425,7 @@ if [[ "$COMMAND" == "install" ]]; then
420425
# Check if VARIANT_ID is "rhel_ai"
421426
if [ "$VARIANT_ID" == "rhel_ai" ]; then
422427
echo -e "${green}Starting API server on OS: RHEL AI running on arch $ARCH ${reset}\n"
423-
nohup ./ilab-apiserver --taxonomy-path "$SELECTED_TAXONOMY_DIR" --rhelai "$CUDA_FLAG" >$ILAB_APISERVER_LOG_FILE 2>&1 &
428+
nohup ./ilab-apiserver --taxonomy-path "$SELECTED_TAXONOMY_DIR" --rhelai --vllm "$CUDA_FLAG" >$ILAB_APISERVER_LOG_FILE 2>&1 &
424429
else
425430
echo -e "${green}Starting API server on OS: $OS running on arch $ARCH ${reset}\n"
426431
nohup ./ilab-apiserver --base-dir "$DISCOVERED_PYENV_DIR" --taxonomy-path "$SELECTED_TAXONOMY_DIR" "$CUDA_FLAG" >$ILAB_APISERVER_LOG_FILE 2>&1 &
@@ -479,7 +484,7 @@ elif [[ "$COMMAND" == "uninstall" ]]; then
479484

480485
read -r -p "Are you sure you want to uninstall the InstructLab UI stack? (yes/no): " CONFIRM
481486
if [[ "$CONFIRM" != "yes" && "$CONFIRM" != "y" ]]; then
482-
echo -e "${green}Uninstallation aborted.${reset}\n"
487+
echo -e "${red}Uninstallation aborted.${reset}\n"
483488
exit 0
484489
fi
485490

src/app/api/envConfig/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export async function GET() {
1818
ENABLE_DEV_MODE: process.env.IL_ENABLE_DEV_MODE || 'false',
1919
EXPERIMENTAL_FEATURES: process.env.NEXT_PUBLIC_EXPERIMENTAL_FEATURES || '',
2020
TAXONOMY_ROOT_DIR: process.env.NEXT_PUBLIC_TAXONOMY_ROOT_DIR || '',
21-
TAXONOMY_KNOWLEDGE_DOCUMENT_REPO: process.env.NEXT_PUBLIC_TAXONOMY_DOCUMENTS_REPO || 'github.com/instructlab-public/taxonomy-knowledge-docs'
21+
TAXONOMY_KNOWLEDGE_DOCUMENT_REPO:
22+
process.env.NEXT_PUBLIC_TAXONOMY_DOCUMENTS_REPO || 'https://github.com/instructlab-public/taxonomy-knowledge-docs',
23+
API_SERVER: process.env.NEXT_PUBLIC_API_SERVER
2224
};
2325

2426
return NextResponse.json(envConfig);

src/app/api/fine-tune/git/branches/route.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import fs from 'fs';
55
import path from 'path';
66

77
const REMOTE_TAXONOMY_ROOT_DIR = process.env.NEXT_PUBLIC_TAXONOMY_ROOT_DIR || '';
8+
const REMOTE_TAXONOMY_REPO_CONTAINER_MOUNT_DIR = '/tmp/.instructlab-ui';
89

910
export async function GET() {
10-
const REPO_DIR = path.join(REMOTE_TAXONOMY_ROOT_DIR, '/taxonomy');
11+
const REPO_DIR = findTaxonomyRepoPath();
1112
try {
1213
console.log(`Checking local taxonomy directory for branches: ${REPO_DIR}`);
1314

@@ -63,3 +64,28 @@ export async function GET() {
6364
return NextResponse.json({ error: 'Failed to list branches from local taxonomy (fine-tune)' }, { status: 500 });
6465
}
6566
}
67+
68+
function findTaxonomyRepoPath(): string {
69+
let remoteTaxonomyRepoDirFinal: string = '';
70+
71+
const remoteTaxonomyRepoContainerMountDir = path.join(REMOTE_TAXONOMY_REPO_CONTAINER_MOUNT_DIR, '/taxonomy');
72+
const remoteTaxonomyRepoDir = path.join(REMOTE_TAXONOMY_ROOT_DIR, '/taxonomy');
73+
74+
// Check if there is taxonomy repository mounted in the container
75+
if (fs.existsSync(remoteTaxonomyRepoContainerMountDir) && fs.readdirSync(remoteTaxonomyRepoContainerMountDir).length !== 0) {
76+
remoteTaxonomyRepoDirFinal = remoteTaxonomyRepoContainerMountDir;
77+
console.log('Remote taxonomy repository ', remoteTaxonomyRepoDir, ' is mounted at:', remoteTaxonomyRepoDirFinal);
78+
} else {
79+
// If remote taxonomy is not mounted, it means it's local deployment and we can directly use the paths
80+
if (fs.existsSync(remoteTaxonomyRepoDir) && fs.readdirSync(remoteTaxonomyRepoDir).length !== 0) {
81+
remoteTaxonomyRepoDirFinal = remoteTaxonomyRepoDir;
82+
}
83+
}
84+
if (remoteTaxonomyRepoDirFinal === '') {
85+
console.warn('Remote taxonomy repository path does not exist.');
86+
return remoteTaxonomyRepoDirFinal;
87+
}
88+
89+
console.log('Remote taxonomy repository path:', remoteTaxonomyRepoDirFinal);
90+
return remoteTaxonomyRepoDirFinal;
91+
}

src/app/api/github/knowledge-files/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from 'next/server';
33
import { getToken } from 'next-auth/jwt';
44

55
const GITHUB_API_URL = 'https://api.github.com';
6-
const TAXONOMY_DOCUMENTS_REPO = process.env.NEXT_PUBLIC_TAXONOMY_DOCUMENTS_REPO || 'github.com/instructlab-public/taxonomy-knowledge-docs';
6+
const TAXONOMY_DOCUMENTS_REPO = process.env.NEXT_PUBLIC_TAXONOMY_DOCUMENTS_REPO || 'https://github.com/instructlab-public/taxonomy-knowledge-docs';
77
const BASE_BRANCH = 'main';
88

99
// Interface for the response

src/app/api/native/git/knowledge-files/route.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import http from 'isomorphic-git/http/node';
1010
// Constants for repository paths
1111
const TAXONOMY_DOCS_ROOT_DIR = process.env.NEXT_PUBLIC_TAXONOMY_ROOT_DIR || '';
1212
const TAXONOMY_DOCS_CONTAINER_MOUNT_DIR = '/tmp/.instructlab-ui';
13-
const TAXONOMY_KNOWLEDGE_DOCS_REPO_URL = process.env.NEXT_PUBLIC_TAXONOMY_DOCUMENTS_REPO || 'github.com/instructlab-public/taxonomy-knowledge-docs';
13+
const TAXONOMY_KNOWLEDGE_DOCS_REPO_URL =
14+
process.env.NEXT_PUBLIC_TAXONOMY_DOCUMENTS_REPO || 'https://github.com/instructlab-public/taxonomy-knowledge-docs';
1415
const BASE_BRANCH = 'main';
1516

1617
// Interface for the response
@@ -223,10 +224,10 @@ async function cloneTaxonomyDocsRepo() {
223224
const taxonomyDocsDirectoryPath = path.join(remoteTaxonomyRepoDirFinal, '/taxonomy-knowledge-docs');
224225

225226
if (fs.existsSync(taxonomyDocsDirectoryPath)) {
226-
console.log(`Using existing taxonomy knowledge docs repository at ${remoteTaxonomyRepoDir}/taxonomy-knowledge-docs.`);
227+
console.log(`Using existing taxonomy knowledge docs repository at ${TAXONOMY_DOCS_ROOT_DIR}/taxonomy-knowledge-docs.`);
227228
return taxonomyDocsDirectoryPath;
228229
} else {
229-
console.log(`Taxonomy knowledge docs repository not found at ${taxonomyDocsDirectoryPath}. Cloning...`);
230+
console.log(`Taxonomy knowledge docs repository not found at ${TAXONOMY_DOCS_ROOT_DIR}/taxonomy-knowledge-docs. Cloning...`);
230231
}
231232

232233
try {

src/app/api/playground/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function POST(req: NextRequest) {
2222

2323
const requestData = {
2424
model: modelName,
25-
messages,
25+
messages: messages,
2626
stream: true
2727
};
2828

src/components/Contribute/Knowledge/Native/DocumentInformation/DocumentInformation.tsx

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ const DocumentInformation: React.FC<Props> = ({
5353
const [isModalOpen, setIsModalOpen] = useState(false);
5454
const [modalText, setModalText] = useState<string | undefined>();
5555

56+
const [successAlertTitle, setSuccessAlertTitle] = useState<string | undefined>();
57+
const [successAlertMessage, setSuccessAlertMessage] = useState<string | undefined>();
58+
const [successAlertLink, setSuccessAlertLink] = useState<string | undefined>();
59+
60+
const [failureAlertTitle, setFailureAlertTitle] = useState<string | undefined>();
61+
const [failureAlertMessage, setFailureAlertMessage] = useState<string | undefined>();
5662
const [alertInfo, setAlertInfo] = useState<AlertInfo | undefined>();
5763

5864
const [validRepo, setValidRepo] = useState<ValidatedOptions>(ValidatedOptions.default);
@@ -142,34 +148,38 @@ const DocumentInformation: React.FC<Props> = ({
142148
const result = await response.json();
143149
console.log('Files uploaded result:', result);
144150

145-
const alertInfo: AlertInfo = {
146-
type: 'success',
147-
title: 'Document uploaded successfully!',
148-
message: 'Documents have been submitted to local taxonomy knowledge docs repo to be referenced in the knowledge submission.'
149-
};
150-
setAlertInfo(alertInfo);
151+
setSuccessAlertTitle('Document uploaded successfully!');
152+
setSuccessAlertMessage('Documents have been uploaded to your repo to be referenced in the knowledge submission.');
153+
if (result.prUrl && result.prUrl.trim() !== '') {
154+
setSuccessAlertLink(result.prUrl);
155+
} else {
156+
setSuccessAlertLink(undefined);
157+
}
151158
} else {
152-
console.error('Knowledge document upload failed:', response.statusText);
153-
const alertInfo: AlertInfo = {
154-
type: 'danger',
155-
title: 'Failed to upload document!',
156-
message: `This upload failed. ${response.statusText}`
157-
};
158-
setAlertInfo(alertInfo);
159+
console.error('Upload failed:', response.statusText);
160+
setFailureAlertTitle('Failed to upload document');
161+
setFailureAlertMessage(`This upload failed. ${response.statusText}`);
159162
}
160163
} catch (error) {
161-
console.error('Knowledge document upload encountered an error:', error);
162-
const alertInfo: AlertInfo = {
163-
type: 'danger',
164-
title: 'Failed to upload document!',
165-
message: `This upload failed. ${(error as Error).message}`
166-
};
167-
setAlertInfo(alertInfo);
164+
console.error('Upload error:', error);
165+
setFailureAlertTitle('Failed to upload document');
166+
setFailureAlertMessage(`This upload failed. ${(error as Error).message}`);
168167
}
169168
}
170169
}
171170
};
172171

172+
const onCloseSuccessAlert = () => {
173+
setSuccessAlertTitle(undefined);
174+
setSuccessAlertMessage(undefined);
175+
setSuccessAlertLink(undefined);
176+
};
177+
178+
const onCloseFailureAlert = () => {
179+
setFailureAlertTitle(undefined);
180+
setFailureAlertMessage(undefined);
181+
};
182+
173183
const handleAutomaticUpload = () => {
174184
if (knowledgeDocumentRepositoryUrl.length > 0 || knowledgeDocumentCommit.length > 0 || documentName.length > 0) {
175185
setModalText('Switching to automatic upload will clear the document information. Are you sure you want to continue?');
@@ -333,6 +343,30 @@ const DocumentInformation: React.FC<Props> = ({
333343
</Alert>
334344
</AlertGroup>
335345
)}
346+
{successAlertTitle && successAlertMessage && (
347+
<AlertGroup isToast isLiveRegion>
348+
<Alert
349+
timeout
350+
variant="success"
351+
title={successAlertTitle}
352+
actionClose={<AlertActionCloseButton onClose={onCloseSuccessAlert} />}
353+
actionLinks={
354+
successAlertLink ? (
355+
<AlertActionLink component="a" href={successAlertLink} target="_blank" rel="noopener noreferrer">
356+
View it here
357+
</AlertActionLink>
358+
) : null
359+
}
360+
>
361+
{successAlertMessage}
362+
</Alert>
363+
</AlertGroup>
364+
)}
365+
{failureAlertTitle && failureAlertMessage && (
366+
<Alert variant="danger" title={failureAlertTitle} actionClose={<AlertActionCloseButton onClose={onCloseFailureAlert} />}>
367+
{failureAlertMessage}
368+
</Alert>
369+
)}
336370
</div>
337371
);
338372
};

0 commit comments

Comments
 (0)