new(basic.gblib): SEND FILE pdf as temporary images ViewOnce.

This commit is contained in:
me@rodrigorodriguez.com 2024-10-06 15:49:07 -03:00
parent ac6e7bc28c
commit d68feec33b
18 changed files with 21 additions and 35805 deletions

1
.gitignore vendored
View file

@ -30,3 +30,4 @@ yarn-lock.json
logo.svg
screenshot.png
data.db
.wwebjs_cache

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -650,7 +650,7 @@ export class DialogKeywords {
*
*/
public async sendTemplateTo({ pid, mobile, filename }) {
const { min, user, proc } = await DialogKeywords.getProcessInfo(pid);
const { min } = await DialogKeywords.getProcessInfo(pid);
GBLogEx.info(min, `SEND TEMPLATE TO '${mobile}',filename '${filename}'.`);
const service = new GBConversationalService(min.core);

View file

@ -1378,7 +1378,7 @@ export class GBMinService {
// a upload with no Dialog, so run Auto Save to .gbdrive.
const t = new SystemKeywords();
GBLogEx.info(min, `BASIC (${min.botId}): Upload done for ${attachmentData.filename}.`);
GBLogEx.info(min, `BASIC (${min.botId}): Upload2 done for ${attachmentData.filename}.`);
const handle = WebAutomationServices.cyrb53({ pid: 0, str: min.botId + attachmentData.filename });
let data = await fs.readFile(attachmentData.filename);

View file

@ -108,9 +108,11 @@ export class GBLLMOutputParser extends BaseLLMOutputParser<ExpectedOutput> {
private toolChain: RunnableSequence;
private min;
private user;
constructor(min, toolChain: RunnableSequence, documentChain: RunnableSequence) {
constructor(min, user, toolChain: RunnableSequence, documentChain: RunnableSequence) {
super();
this.user = user;
this.min = min;
this.toolChain = toolChain;
}
@ -150,8 +152,18 @@ export class GBLLMOutputParser extends BaseLLMOutputParser<ExpectedOutput> {
if (localName) {
const pngs = await GBUtil.pdfPageAsImage(this.min, localName, source.page);
text = `![alt text](${pngs[0].url})
${text}`;
if (!isNaN(this.user.userSystemId)){
await this.min.whatsAppDirectLine.sendFileToDevice(
this.user.userSystemId, pngs[0].url,
localName, null, undefined, true);
}
else
{
text = `![alt text](${pngs[0].url})
${text}`;
}
found = true;
source.file = localName;
}
@ -495,7 +507,7 @@ export class ChatServices {
},
combineDocumentsPrompt,
model,
new GBLLMOutputParser(min, null, null)
new GBLLMOutputParser(min, user, null, null)
] as any);
const conversationalToolChain = RunnableSequence.from([
@ -508,7 +520,7 @@ export class ChatServices {
},
questionGeneratorTemplate,
modelWithTools,
new GBLLMOutputParser(min, callToolChain, docsContext?.docstore?._docs.length > 0 ? combineDocumentsChain : null),
new GBLLMOutputParser(min, user, callToolChain, docsContext?.docstore?._docs.length > 0 ? combineDocumentsChain : null),
new StringOutputParser()
] as any);

View file

@ -743,7 +743,7 @@ export class WhatsappDirectLine extends GBService {
to = to + '@c.us';
}
}
GBLogEx.info(this.min, `WhatsApp isViewOnce 2${isViewOnce}`);
GBLogEx.info(this.min, `WhatsApp isViewOnce ${isViewOnce}`);
await this.customClient.sendMessage(to, attachment, { caption: caption, isViewOnce });
break;
}

File diff suppressed because one or more lines are too long