UNPKG

@websolutespa/payload-plugin-bowl-llm

Version:

LLM plugin for Bowl PayloadCms plugin

81 lines (80 loc) 2.4 kB
import { isRole, isTenant, roles } from '@websolutespa/payload-plugin-bowl'; import { options } from '../options'; const serverURL = process.env.PAYLOAD_PUBLIC_SERVER_URL || ''; const basePath = process.env.PAYLOAD_PUBLIC_BASE_PATH || ''; export const LlmThread = { type: 'withCollection', slug: options.slug.llmThread, admin: { group: options.group.llm, defaultColumns: [ 'id', 'createdAt', 'llmApp' ], preview: (doc, { locale, token })=>{ const app = doc.llmApp; return `${serverURL}${basePath}/api/llm/${app.settings.credentials.appKey}/${locale}?llmThreadId=${doc.id}`; } }, access: { create: (args)=>false, read: (args)=>isRole(roles.Admin)(args) || isTenant(options.slug.llmThread)(args), update: (args)=>false, delete: (args)=>isRole(roles.Admin)(args) }, fields: [ { type: 'withId' }, { name: 'llmApp', type: 'relationship', relationTo: options.slug.llmApp }, { name: 'message', type: 'array', fields: [ { name: 'messageId', type: 'withText' }, { name: 'role', type: 'withText', required: true }, { name: 'content', type: 'textarea', maxLength: 100000 }, { name: 'feedback', type: 'group', fields: [ { name: 'rating', type: 'number' }, { name: 'notes', type: 'textarea' } ] }, { name: 'createdAt', type: 'withDate', admin: { date: { pickerAppearance: 'dayAndTime' } } } ] } ] }; //# sourceMappingURL=LlmThread.js.map