diff --git a/pathservice/cmd/pathservice.go b/pathservice/cmd/pathservice.go index c752fcb..b0808e4 100644 --- a/pathservice/cmd/pathservice.go +++ b/pathservice/cmd/pathservice.go @@ -9,7 +9,6 @@ import ( "os" "os/signal" "path/filepath" - "strings" "sync" "syscall" "time" @@ -27,7 +26,7 @@ const ( repoDir = "/tmp/taxonomy" checkInterval = 1 * time.Minute // Interval for checking updates serviceLogLevel = "IL_UI_DEPLOYMENT" - SKILLS = "skills/" + SKILLS = "compositional_skills/" // Currently, we are only supporting compositional skills KNOWLEDGE = "knowledge/" ) @@ -148,47 +147,18 @@ func (ps *PathService) checkForUpdates(ctx context.Context, wg *sync.WaitGroup, } -func (ps *PathService) skillPathHandler(w http.ResponseWriter, r *http.Request) { - dirName := r.URL.Query().Get("dir_name") - - var subDirs []string - var levelOne bool - if dirName == "" { - levelOne = true - } - - dirPath := filepath.Join(repoDir, dirName) - entries, err := os.ReadDir(dirPath) - if err != nil { - http.Error(w, "Directory path doesn't exist", http.StatusInternalServerError) - return - } - - for _, entry := range entries { - if entry.IsDir() { - // If we are at root level, then only return directories ending with skills - if levelOne && !strings.HasSuffix(entry.Name(), "skills") { - continue - } - subDirs = append(subDirs, entry.Name()) - } - } - response, err := json.Marshal(subDirs) - if err != nil { - http.Error(w, "Error creating response", http.StatusInternalServerError) - return - } +func (ps *PathService) skillPathHandler(w http.ResponseWriter, r *http.Request){ + ps.pathHandler(w, r, SKILLS) +} - w.Header().Set("Content-Type", "application/json") - w.Header().Set("Access-Control-Allow-Origin", "*") - w.Write(response) +func (ps *PathService) knowledgePathHandler(w http.ResponseWriter, r *http.Request){ + ps.pathHandler(w, r, KNOWLEDGE) } -func (ps *PathService) knowledgePathHandler(w http.ResponseWriter, r *http.Request) { +func (ps *PathService) pathHandler(w http.ResponseWriter, r *http.Request, rootDir string) { dirName := r.URL.Query().Get("dir_name") - // Knowledge taxonomy tree is present in the knowledge directory - dirName = KNOWLEDGE + dirName + dirName = rootDir + dirName var subDirs []string dirPath := filepath.Join(repoDir, dirName) entries, err := os.ReadDir(dirPath) @@ -202,7 +172,6 @@ func (ps *PathService) knowledgePathHandler(w http.ResponseWriter, r *http.Reque subDirs = append(subDirs, entry.Name()) } } - response, err := json.Marshal(subDirs) if err != nil { http.Error(w, "Error creating response", http.StatusInternalServerError) diff --git a/src/app/api/pr/skill/route.ts b/src/app/api/pr/skill/route.ts index df92c63..c1dc723 100644 --- a/src/app/api/pr/skill/route.ts +++ b/src/app/api/pr/skill/route.ts @@ -7,6 +7,7 @@ import { SkillYamlData, AttributionData } from '@/types'; import { dumpYaml } from '@/utils/yamlConfig'; const GITHUB_API_URL = 'https://api.github.com'; +const SKILLS_DIR = 'compositional_skills'; const UPSTREAM_REPO_OWNER = process.env.NEXT_PUBLIC_TAXONOMY_REPO_OWNER!; const UPSTREAM_REPO_NAME = process.env.NEXT_PUBLIC_TAXONOMY_REPO!; const BASE_BRANCH = 'main'; @@ -42,8 +43,8 @@ export async function POST(req: NextRequest) { } const branchName = `skill-contribution-${Date.now()}`; - const newYamlFilePath = `${filePath}qna.yaml`; - const newAttributionFilePath = `${filePath}attribution.txt`; + const newYamlFilePath = `${SKILLS_DIR}/${filePath}qna.yaml`; + const newAttributionFilePath = `${SKILLS_DIR}/${filePath}attribution.txt`; const skillData = yaml.load(content) as SkillYamlData; const attributionData = attribution as AttributionData; diff --git a/src/app/edit-submission/knowledge/[id]/page.tsx b/src/app/edit-submission/knowledge/[id]/page.tsx index aa3b91e..2c09228 100644 --- a/src/app/edit-submission/knowledge/[id]/page.tsx +++ b/src/app/edit-submission/knowledge/[id]/page.tsx @@ -106,7 +106,7 @@ const EditKnowledgePage: React.FunctionComponent<{ params: { id: string } }> = ( }); knowledgeExistingFormData.seedExamples = seedExamples; - // Set the file path from the current YAML file + // Set the file path from the current YAML file (remove the root folder name from the path) const currentFilePath = foundYamlFile.filename.split('/').slice(1, -1).join('/'); knowledgeEditFormData.knowledgeFormData.filePath = currentFilePath + '/'; diff --git a/src/app/edit-submission/skill/[id]/page.tsx b/src/app/edit-submission/skill/[id]/page.tsx index efc933d..9144901 100644 --- a/src/app/edit-submission/skill/[id]/page.tsx +++ b/src/app/edit-submission/skill/[id]/page.tsx @@ -88,7 +88,7 @@ const EditSkillPage: React.FunctionComponent<{ params: { id: string } }> = ({ pa skillExistingFormData.seedExamples = seedExamples; // Set the file path from the current YAML file (Note: skills root directory starts from the repo root) - const currentFilePath = foundYamlFile.filename.split('/').slice(0, -1).join('/'); + const currentFilePath = foundYamlFile.filename.split('/').slice(1, -1).join('/'); skillEditFormData.skillFormData.filePath = currentFilePath + '/'; // Fetch and parse attribution file if it exists diff --git a/src/components/Contribute/Skill/AttributionInformation/AttributionInformation.tsx b/src/components/Contribute/Skill/AttributionInformation/AttributionInformation.tsx index 4ac42de..57eb6f8 100644 --- a/src/components/Contribute/Skill/AttributionInformation/AttributionInformation.tsx +++ b/src/components/Contribute/Skill/AttributionInformation/AttributionInformation.tsx @@ -92,7 +92,7 @@ const AttributionInformation: React.FC = ({ titleText={{ text: (

- Attribution Info * + Attribution Information *

), id: 'attribution-info-id' diff --git a/src/components/Contribute/Skill/AuthorInformation/AuthorInformation.tsx b/src/components/Contribute/Skill/AuthorInformation/AuthorInformation.tsx index ac46577..e958b19 100644 --- a/src/components/Contribute/Skill/AuthorInformation/AuthorInformation.tsx +++ b/src/components/Contribute/Skill/AuthorInformation/AuthorInformation.tsx @@ -58,7 +58,7 @@ const AuthorInformation: React.FC = ({ reset, skillFormData, setDisableAc titleText={{ text: (

- Author Info * + Author Information *

), id: 'author-info-id' diff --git a/src/components/Contribute/Skill/FilePathInformation/FilePathInformation.tsx b/src/components/Contribute/Skill/FilePathInformation/FilePathInformation.tsx index 16d39bf..d0ee109 100644 --- a/src/components/Contribute/Skill/FilePathInformation/FilePathInformation.tsx +++ b/src/components/Contribute/Skill/FilePathInformation/FilePathInformation.tsx @@ -18,12 +18,12 @@ const FilePathInformation: React.FC = ({ reset, path, setFilePath }) => { titleText={{ text: (

- File Path Info * + Taxonomy Directory Path *

), id: 'file-path-info-id' }} - titleDescription="Specify the file path for the QnA and Attribution files." + titleDescription="Specify the directory location within taxonomy repository structure for the QnA Yaml and Attribution files." /> } > diff --git a/src/components/Contribute/Skill/SkillsDescription/SkillsDescriptionContent.tsx b/src/components/Contribute/Skill/SkillsDescription/SkillsDescriptionContent.tsx index e275836..ae1bbcb 100644 --- a/src/components/Contribute/Skill/SkillsDescription/SkillsDescriptionContent.tsx +++ b/src/components/Contribute/Skill/SkillsDescription/SkillsDescriptionContent.tsx @@ -7,14 +7,18 @@ const SkillsDescriptionContent: React.FunctionComponent = () => {

-

Skills in InstructLab come in two main types:

- 1) Compositional Skills - These are skills that are performative and you are teaching the model how to do tasks like "write me a - song" or "summarize an email".
- 2) Core Skills - Core skills are foundational like math, reasoning and coding. - + Skills are performative. When you create a skill for the model, you are teaching it how to do something: "write me a song," + "rearrange words in a sentence" or "summarize an email." + + + + diff --git a/src/components/Contribute/Skill/SkillsInformation/SkillsInformation.tsx b/src/components/Contribute/Skill/SkillsInformation/SkillsInformation.tsx index 2e0c4ce..8eca1bc 100644 --- a/src/components/Contribute/Skill/SkillsInformation/SkillsInformation.tsx +++ b/src/components/Contribute/Skill/SkillsInformation/SkillsInformation.tsx @@ -76,7 +76,7 @@ const SkillsInformation: React.FC = ({ titleText={{ text: (

- Skills Info * + Skill Information *

), id: 'skills-info-id' diff --git a/src/components/Contribute/Skill/SkillsSeedExample/SkillsSeedExample.tsx b/src/components/Contribute/Skill/SkillsSeedExample/SkillsSeedExample.tsx index 0bdb7d3..b599c8c 100644 --- a/src/components/Contribute/Skill/SkillsSeedExample/SkillsSeedExample.tsx +++ b/src/components/Contribute/Skill/SkillsSeedExample/SkillsSeedExample.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup, FormHelperText } from '@patternfly/react-core/dist/dynamic/components/Form'; import { Button } from '@patternfly/react-core/dist/dynamic/components/Button'; -import { TrashIcon, PlusCircleIcon, ExclamationCircleIcon } from '@patternfly/react-icons/dist/dynamic/icons/'; +import { TrashIcon, PlusCircleIcon, ExclamationCircleIcon, ExternalLinkAltIcon } from '@patternfly/react-icons/dist/dynamic/icons/'; import { SeedExample } from '..'; import { TextArea } from '@patternfly/react-core/dist/esm/components/TextArea'; import { ValidatedOptions } from '@patternfly/react-core/dist/esm/helpers/constants'; @@ -32,6 +32,7 @@ const SkillsSeedExample: React.FC = ({ }) => { return ( = ({ ), id: 'seed-examples-id' }} - titleDescription="Add seed examples with Q&A pair and context (optional). Minimum 5 seed examples are required." + titleDescription={ +

+ Add seed examples with question and answer pair and related context (optional). Minimum 5 seed examples are required.{' '} + + {' '} + Learn more about seed examples + + +

+ } /> } > @@ -58,12 +68,11 @@ const SkillsSeedExample: React.FC = ({ titleText={{ text: (

- Skill Seed Example {seedExampleIndex + 1} {seedExample.immutable && *} + Seed Example {seedExampleIndex + 1} {seedExample.immutable && *}

), id: 'nested-field-group1-titleText-id' }} - titleDescription="Please enter question and answer for the seed example. Context is recommended but not required." actions={ !seedExample.immutable && ( +
+ +
); }; diff --git a/src/components/Contribute/Skill/Submit/Submit.tsx b/src/components/Contribute/Skill/Submit/Submit.tsx index 623a817..6edadc6 100644 --- a/src/components/Contribute/Skill/Submit/Submit.tsx +++ b/src/components/Contribute/Skill/Submit/Submit.tsx @@ -88,7 +88,7 @@ const Submit: React.FC = ({ disableAction, skillFormData, setActionGroupA }; return ( ); }; diff --git a/src/components/Contribute/Skill/Update/Update.tsx b/src/components/Contribute/Skill/Update/Update.tsx index ce2e5f1..ab904d5 100644 --- a/src/components/Contribute/Skill/Update/Update.tsx +++ b/src/components/Contribute/Skill/Update/Update.tsx @@ -8,6 +8,7 @@ import { amendCommit, getGitHubUsername, updatePullRequest } from '@/utils/githu import { useSession } from 'next-auth/react'; import { useRouter } from 'next/navigation'; +const SKILLS_DIR = 'compositional_skills/'; interface Props { disableAction: boolean; skillFormData: SkillFormData; @@ -75,8 +76,9 @@ Creator names: ${attributionData.creator_names} const commitMessage = `Amend commit with updated content\n\nSigned-off-by: ${skillFormData.name} <${skillFormData.email}>`; // Ensure proper file paths for the edit - const finalYamlPath = skillFormData.filePath.replace(/^\//, '').replace(/\/?$/, '/') + yamlFile.filename.split('/').pop(); - const finalAttributionPath = skillFormData.filePath.replace(/^\//, '').replace(/\/?$/, '/') + attributionFile.filename.split('/').pop(); + const finalYamlPath = SKILLS_DIR + skillFormData.filePath.replace(/^\//, '').replace(/\/?$/, '/') + yamlFile.filename.split('/').pop(); + const finalAttributionPath = + SKILLS_DIR + skillFormData.filePath.replace(/^\//, '').replace(/\/?$/, '/') + attributionFile.filename.split('/').pop(); const origFilePath = yamlFile.filename.split('/').slice(0, -1).join('/'); const oldFilePath = { diff --git a/src/components/Contribute/Skill/validation.tsx b/src/components/Contribute/Skill/validation.tsx index 84a45ab..38ab435 100644 --- a/src/components/Contribute/Skill/validation.tsx +++ b/src/components/Contribute/Skill/validation.tsx @@ -61,7 +61,7 @@ export const validateFields = ( const { duplicate, index } = hasDuplicateSeedExamples(skillFormData.seedExamples); if (duplicate) { skillFormData.seedExamples[index].isQuestionValid = ValidatedOptions.error; - skillFormData.seedExamples[index].questionValidationError = 'This is duplicate question, please provide unique contexts.'; + skillFormData.seedExamples[index].questionValidationError = 'This is duplicate question, please provide unique questions.'; const actionGroupAlertContent: ActionGroupAlertContent = { title: `Seed example issue!`, message: `Seed example ${index + 1} question is duplicate. Please provide unique questions.`,