@websolutespa/payload-plugin-bowl-llm
Version:
LLM plugin for Bowl PayloadCms plugin
40 lines (39 loc) • 1.17 kB
JavaScript
import { ResponseOptions, ResponseSuccess, withCors } from '@websolutespa/payload-utils/server';
import { addDataAndFileToRequest } from 'payload';
import { appHandler } from './app.handler';
import { errorHandler } from './error.handler';
import { threadHandler } from './thread.handler';
export const infoHandler = async (req)=>{
if (req.method === 'OPTIONS') {
return ResponseOptions();
}
const headers = withCors({
req,
cors: '*'
});
try {
await addDataAndFileToRequest(req);
const app = await appHandler(req);
const info = {
contents: app.contents
};
const { threadId } = req.body;
if (app && threadId) {
const thread = await threadHandler(req, app.id);
info.thread = {
messages: thread.message.map((x)=>({
...x
})),
threadId
};
}
return ResponseSuccess(info, {
headers
});
} catch (error) {
return errorHandler(error, {
headers
});
}
};
//# sourceMappingURL=info.handler.js.map