UNPKG

@websolutespa/payload-plugin-bowl-llm

Version:

LLM plugin for Bowl PayloadCms plugin

20 lines (19 loc) 1.02 kB
import { fetchRobot } from '../../utils/robot'; export async function pythonKnowledgeBaseHandler(request) { for (const endpoint of request.endpoints ?? []){ endpoint.authentication = endpoint.authentication || 'none'; endpoint.authSecret = endpoint.authSecret || ''; } const serverURL = process.env.PAYLOAD_PUBLIC_LLM_WEBHOOK_URL || process.env.PAYLOAD_PUBLIC_SERVER_URL || 'http://localhost:4000'; const basePath = process.env.PAYLOAD_PUBLIC_BASE_PATH || ''; const metadataExtraHeader = Object.entries(request.metadata).map(([key, value])=>`${key}=${value}`).join(','); const response = await fetchRobot('api/llm/kb/task', 'POST', request, { // todo: better define type 'X-ws-bom-msg-type': 'create.kb', 'X-ws-bom-msg-id': request.taskId, 'X-ws-bom-webhooks': `${serverURL}${basePath}/api/llm/kb/webhook`, 'X-ws-bom-msg-extra': metadataExtraHeader }); return response.id; } //# sourceMappingURL=pythonKnowledgeBase.handler.js.map