|
|
@@ -1,4 +1,5 @@
|
|
|
import { Injectable, NotFoundException, BadRequestException, Inject, forwardRef } from '@nestjs/common';
|
|
|
+import { FFBLangChainService } from '../../FFB/services/ffb-langchain.service';
|
|
|
|
|
|
import { MongoCoreService } from '../../mongo/mongo-core.service';
|
|
|
import { BlockRepository } from '../repositories/block.repository';
|
|
|
@@ -17,6 +18,7 @@ export class BlockService {
|
|
|
private readonly mongoCore: MongoCoreService,
|
|
|
@Inject(forwardRef(() => FFBProductionService))
|
|
|
private readonly ffbService: FFBProductionService,
|
|
|
+ private readonly ffbLangChainService: FFBLangChainService,
|
|
|
) { }
|
|
|
|
|
|
|
|
|
@@ -92,4 +94,23 @@ export class BlockService {
|
|
|
// 2. Delete the block itself
|
|
|
await repo.delete(id);
|
|
|
}
|
|
|
+
|
|
|
+ async generateDescription(data: { name: string, phaseName?: string, size?: number, numOfTrees?: number }): Promise<{ description: string }> {
|
|
|
+ const prompt = `Write a realistic, professional description (2–4 sentences) for an oil palm plantation block named "${data.name}"${data.phaseName ? ` within phase "${data.phaseName}"` : ''}.${data.size ? ` It has a size of ${data.size} units` : ''}${data.numOfTrees ? ` and contains ${data.numOfTrees} trees` : ''}.
|
|
|
+
|
|
|
+Choose 1-2 aspects from the following to incorporate naturally:
|
|
|
+- Block health and maturity (e.g., trees at peak production age, healthy canopy development, consistent fruit set)
|
|
|
+- Field accessibility (e.g., easily accessible by tractor paths, slightly sloped area requiring specialized harvesting tools)
|
|
|
+- Environmental features (e.g., bordering primary forest, presence of natural irrigation channels, rich nutrient-holding soil)
|
|
|
+- Monitoring and care (e.g., subject to intensive pest monitoring, recently fertilized, under strict irrigation schedule)
|
|
|
+
|
|
|
+Guidelines:
|
|
|
+- Maintain a grounded, operational tone.
|
|
|
+- Do not mention the bullet points explicitly; weave them into the narrative.
|
|
|
+- Ensure the length is exactly 2-4 sentences.
|
|
|
+
|
|
|
+Description:`;
|
|
|
+ const description = await this.ffbLangChainService.chatStateless(prompt);
|
|
|
+ return { description: description.replace(/^Description:\s*/i, '').trim() };
|
|
|
+ }
|
|
|
}
|