UNPKG

@websolutespa/payload-plugin-bowl-llm

Version:

LLM plugin for Bowl PayloadCms plugin

44 lines (43 loc) 1.54 kB
'use client'; import { jsx as _jsx } from "react/jsx-runtime"; import { Button, toast, useField, useFormFields } from '@payloadcms/ui'; import React from 'react'; export const FineTune = ({ path })=>{ const appKey = useFormFields(([fields])=>fields['settings.credentials.appKey']); const apiKey = useFormFields(([fields])=>fields['settings.credentials.apiKey']); const { setValue } = useField({ path: 'settings.fineTuning.currentJobId' }); const appKeyValue = appKey?.initialValue; const apiKeyValue = apiKey?.initialValue; const handleClick = async ()=>{ if (!appKeyValue || !apiKeyValue) { return; } const httpResponse = await fetch((process.env.PAYLOAD_PUBLIC_BASE_PATH || '') + '/api/llm/fine-tuning?locale=it', { method: 'POST', headers: { 'Content-Type': 'application/json' }, referrer: '', body: JSON.stringify({ appKey: appKeyValue, apiKey: apiKeyValue }) }); const response = await httpResponse.json(); if (httpResponse.ok) { setValue(response.id); toast.success('Job avviato con successo'); } else { toast.error(response.message); } }; return /*#__PURE__*/ _jsx("div", { children: /*#__PURE__*/ _jsx(Button, { onClick: handleClick, children: "Avvia nuovo job" }) }); }; //# sourceMappingURL=FineTune.js.map