Skip to content

Commit

Permalink
feat: add tags skill
Browse files Browse the repository at this point in the history
  • Loading branch information
marian2js committed Jan 22, 2024
1 parent ff5d258 commit 31ef32a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/api/src/chat/entities/assistant-skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { GraphQLJSONObject } from 'graphql-type-json'

export enum AssistantSkillKey {
api = 'api',
tags = 'tags',
}

@ObjectType()
Expand Down
13 changes: 13 additions & 0 deletions apps/api/src/chat/services/assistant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ export class AssistantService extends BaseService<Assistant> {
}
skill.inputs['key'] = camelCase(skill.inputs['name'])
break
case AssistantSkillKey.tags:
if (skills.filter((s) => s.key === AssistantSkillKey.tags).length > 1) {
throw new Error(`You can only have one Tags skill`)
}
if (!Array.isArray(skill.inputs?.['tags']) || !skill.inputs['tags'].length) {
throw new Error(`tags is required for the Tags skill`)
}
for (const tag of skill.inputs['tags']) {
if (!tag.name || !tag.description) {
throw new Error(`name and description are required for every tag`)
}
}
break
default:
assertNever(skill.key)
throw new Error(`Invalid skill key: ${skill.key}`)
Expand Down

0 comments on commit 31ef32a

Please sign in to comment.