Skip to content

Commit

Permalink
Merge pull request #215 from vishnoianil/fix-knowledge-1.0.0
Browse files Browse the repository at this point in the history
Fix knowledge submission issue
  • Loading branch information
aevo98765 authored Sep 27, 2024
2 parents b4ebdf8 + 508699a commit 49243ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions deploy/k8s/overlays/openshift/prod/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ patches:
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: quay.io/instructlab-ui/ui:v1.0.0-beta # Override this image if you want to use a different UI image
value: quay.io/instructlab-ui/ui:latest #Override this image if you want to use a different UI image
# Override the pathservice image for Openshift production deployment
- target:
Expand All @@ -45,4 +45,4 @@ patches:
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: quay.io/instructlab-ui/pathservice:v1.0.0-beta # Override this image if you want to use a different pathservice image
value: quay.io/instructlab-ui/pathservice:latest #Override this image if you want to use a different pathservice image
36 changes: 18 additions & 18 deletions src/components/Contribute/Knowledge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,46 +225,46 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
const contextStr = context.trim();
if (contextStr.length == 0) {
setDisableAction(true);
return { errorMsg: 'Context is required', context: ValidatedOptions.error };
return { msg: 'Context is required', status: ValidatedOptions.error };
}
const tokens = contextStr.split(/\s+/);
if (tokens.length > 0 && tokens.length <= 500) {
setDisableAction(!checkKnowledgeFormCompletion(knowledgeFormData));
return { errorMsg: '', context: ValidatedOptions.success };
return { msg: 'Valid Input', status: ValidatedOptions.success };
}
setDisableAction(true);
const errorMsg = 'Context must be less than 500 words. Current word count: ' + tokens.length;
return { errorMsg: errorMsg, context: ValidatedOptions.error };
return { msg: errorMsg, status: ValidatedOptions.error };
};

const validateQuestion = (question: string) => {
const questionStr = question.trim();
if (questionStr.length == 0) {
setDisableAction(true);
return { errorMsg: 'Question is required', context: ValidatedOptions.error };
return { msg: 'Question is required', status: ValidatedOptions.error };
}
const tokens = questionStr.split(/\s+/);
if (tokens.length > 0 && tokens.length < 250) {
setDisableAction(!checkKnowledgeFormCompletion(knowledgeFormData));
return { errorMsg: '', context: ValidatedOptions.success };
return { msg: 'Valid input', status: ValidatedOptions.success };
}
setDisableAction(true);
return { errorMsg: 'Question must be less than 250 words. Current word count: ' + tokens.length, context: ValidatedOptions.error };
return { msg: 'Question must be less than 250 words. Current word count: ' + tokens.length, status: ValidatedOptions.error };
};

const validateAnswer = (answer: string) => {
const answerStr = answer.trim();
if (answerStr.length == 0) {
setDisableAction(true);
return { errorMsg: 'Answer is required', context: ValidatedOptions.error };
return { msg: 'Answer is required', status: ValidatedOptions.error };
}
const tokens = answerStr.split(/\s+/);
if (tokens.length > 0 && tokens.length < 250) {
setDisableAction(!checkKnowledgeFormCompletion(knowledgeFormData));
return { errorMsg: '', context: ValidatedOptions.success };
return { msg: 'Valid input', status: ValidatedOptions.success };
}
setDisableAction(true);
return { errorMsg: 'Answer must be less than 250 words. Current word count: ' + tokens.length, context: ValidatedOptions.error };
return { msg: 'Answer must be less than 250 words. Current word count: ' + tokens.length, status: ValidatedOptions.error };
};

const handleContextInputChange = (seedExampleIndex: number, contextValue: string): void => {
Expand All @@ -283,11 +283,11 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
const handleContextBlur = (seedExampleIndex: number): void => {
const updatedSeedExamples = seedExamples.map((seedExample: SeedExample, index: number): SeedExample => {
if (index === seedExampleIndex) {
const { errorMsg, context } = validateContext(seedExample.context);
const { msg, status } = validateContext(seedExample.context);
return {
...seedExample,
isContextValid: context,
validationError: errorMsg
isContextValid: status,
validationError: msg
};
}
return seedExample;
Expand Down Expand Up @@ -323,11 +323,11 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
...seedExample,
questionAndAnswers: seedExample.questionAndAnswers.map((questionAndAnswerPair: QuestionAndAnswerPair, index: number) => {
if (index === questionAndAnswerIndex) {
const { errorMsg, context } = validateQuestion(questionAndAnswerPair.question);
const { msg, status } = validateQuestion(questionAndAnswerPair.question);
return {
...questionAndAnswerPair,
isQuestionValid: context,
questionValidationError: errorMsg
isQuestionValid: status,
questionValidationError: msg
};
}
return questionAndAnswerPair;
Expand Down Expand Up @@ -366,11 +366,11 @@ export const KnowledgeForm: React.FunctionComponent<KnowledgeFormProps> = ({ kno
...seedExample,
questionAndAnswers: seedExample.questionAndAnswers.map((questionAndAnswerPair: QuestionAndAnswerPair, index: number) => {
if (index === questionAndAnswerIndex) {
const { errorMsg, context } = validateAnswer(questionAndAnswerPair.answer);
const { msg, status } = validateAnswer(questionAndAnswerPair.answer);
return {
...questionAndAnswerPair,
isAnswerValid: context,
answerValidationError: errorMsg
isAnswerValid: status,
answerValidationError: msg
};
}
return questionAndAnswerPair;
Expand Down

0 comments on commit 49243ca

Please sign in to comment.