ai-assistant.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import type { HasObjectId, IGrantedGroup, IUserHasId, Ref } from '@growi/core';
  2. import type { IVectorStore } from './vector-store';
  3. /*
  4. * Objects
  5. */
  6. export const AiAssistantShareScope = {
  7. SAME_AS_ACCESS_SCOPE: 'sameAsAccessScope',
  8. PUBLIC_ONLY: 'publicOnly', // TODO: Rename to "PUBLIC"
  9. OWNER: 'owner',
  10. GROUPS: 'groups',
  11. } as const;
  12. export const AiAssistantAccessScope = {
  13. PUBLIC_ONLY: 'publicOnly',
  14. OWNER: 'owner',
  15. GROUPS: 'groups',
  16. } as const;
  17. /*
  18. * Interfaces
  19. */
  20. export type AiAssistantShareScope =
  21. (typeof AiAssistantShareScope)[keyof typeof AiAssistantShareScope];
  22. export type AiAssistantAccessScope =
  23. (typeof AiAssistantAccessScope)[keyof typeof AiAssistantAccessScope];
  24. export interface AiAssistant {
  25. name: string;
  26. description: string;
  27. additionalInstruction: string;
  28. pagePathPatterns: string[];
  29. vectorStore: Ref<IVectorStore>;
  30. owner: Ref<IUserHasId>;
  31. grantedGroupsForShareScope?: IGrantedGroup[];
  32. grantedGroupsForAccessScope?: IGrantedGroup[];
  33. shareScope: AiAssistantShareScope;
  34. accessScope: AiAssistantAccessScope;
  35. isDefault: boolean;
  36. }
  37. export type AiAssistantHasId = AiAssistant & HasObjectId;
  38. export type UpsertAiAssistantData = Omit<
  39. AiAssistant,
  40. 'owner' | 'vectorStore' | 'isDefault'
  41. >;
  42. export type AccessibleAiAssistants = {
  43. myAiAssistants: AiAssistant[];
  44. teamAiAssistants: AiAssistant[];
  45. };
  46. export type AccessibleAiAssistantsHasId = {
  47. myAiAssistants: AiAssistantHasId[];
  48. teamAiAssistants: AiAssistantHasId[];
  49. };