chore: remove prisma
This commit is contained in:
@@ -3,13 +3,8 @@ import { Tool } from './tool';
|
||||
import { BaseTool, makeRequest } from '@anthropic';
|
||||
import { generatePrompt } from './prompt';
|
||||
import { Consumer } from '@consumer/types';
|
||||
import prisma from '@prisma';
|
||||
|
||||
export async function generate(
|
||||
id: number | undefined,
|
||||
editedConsumer: Consumer,
|
||||
date: Date
|
||||
) {
|
||||
export async function generate(editedConsumer: Consumer, date: Date) {
|
||||
const consumerPrompt = await generatePrompt(
|
||||
editedConsumer,
|
||||
parseInt(process.env.PURCHASE_REFLECTION_THRESHOLD ?? '50'),
|
||||
@@ -17,10 +12,6 @@ export async function generate(
|
||||
parseInt(process.env.NUMBER_OF_WEEKS ?? '4')
|
||||
);
|
||||
|
||||
console.info(
|
||||
`Generating new purchase list for consumer with id ${id ?? 'N/A'}`
|
||||
);
|
||||
|
||||
try {
|
||||
const result = (await makeRequest(
|
||||
consumerPrompt,
|
||||
@@ -39,31 +30,7 @@ export async function generate(
|
||||
);
|
||||
|
||||
console.info(
|
||||
`Generated ${totalPurchases} purchases for new purchase list for consumer wth id ${id}`
|
||||
);
|
||||
|
||||
const [consumer, purchaseList] = await prisma.$transaction(async tx => {
|
||||
const consumer = id
|
||||
? await tx.consumer.update({
|
||||
where: { id },
|
||||
data: { editedValue: editedConsumer }
|
||||
})
|
||||
: await tx.consumer.create({
|
||||
data: { editedValue: editedConsumer }
|
||||
});
|
||||
|
||||
const purchaseList = await tx.purchaseList.create({
|
||||
data: {
|
||||
consumerId: consumer.id,
|
||||
value: validPurchases.data
|
||||
}
|
||||
});
|
||||
|
||||
return [consumer, purchaseList];
|
||||
});
|
||||
|
||||
console.info(
|
||||
`Purchase list with id ${purchaseList.id} for consumer with id ${consumer.id} stored in database.`
|
||||
`Generated ${totalPurchases} purchases for new purchase list for consumer`
|
||||
);
|
||||
|
||||
return validPurchases.data;
|
||||
|
||||
Reference in New Issue
Block a user