new(basic.gblib): CHART PROMPT and chart mode.

This commit is contained in:
Rodrigo Rodriguez 2024-09-05 14:26:08 -03:00
parent 58b7127491
commit c51ceb649c
4 changed files with 23 additions and 31 deletions

View file

@ -341,7 +341,6 @@ export class GBConversationalService {
}
public async sendEvent(min: GBMinInstance, step: GBDialogStep, name: string, value: Object): Promise<any> {
if (step.context.activity.channelId !== 'msteams' && step.context.activity.channelId !== 'omnichannel') {
GBLogEx.info(
min,
@ -642,30 +641,32 @@ export class GBConversationalService {
});
}
public async fillAndBroadcastTemplate(min: GBMinInstance, template, mobile: string, text) {
template = template.replace(/\-/gi, '_')
template = template.replace(/\./gi, '_')
template = template.replace(/\-/gi, '_');
template = template.replace(/\./gi, '_');
let isMedia =
text.toLowerCase().endsWith('.jpg') ||
text.toLowerCase().endsWith('.jpeg') ||
text.toLowerCase().endsWith('.png');
text.toLowerCase().endsWith('.png') ||
text.toLowerCase().endsWith('.mp4') ||
text.toLowerCase().endsWith('.mov');
let image = !isMedia ? /(.*)\n/gim.exec(text)[0].trim() : text;
let mediaFile = !isMedia ? /(.*)\n/gim.exec(text)[0].trim() : text;
const gbaiName = DialogKeywords.getGBAIPath(min.botId);
const fileUrl = urlJoin(process.env.BOT_URL, 'kb', gbaiName, `${min.botId}.gbkb`, 'images', image);
const fileUrl = urlJoin(process.env.BOT_URL, 'kb', gbaiName, `${min.botId}.gbkb`, 'media', mediaFile);
let urlImage = image.startsWith('http') ? image : fileUrl;
let urlMedia = mediaFile.startsWith('http') ? mediaFile : fileUrl;
if (!isMedia) {
text = text.substring(image.length + 1).trim();
text = text.substring(mediaFile.length + 1).trim();
text = text.replace(/\n/g, '\\n');
}
template = isMedia ? image.replace(/\.[^/.]+$/, '') : template;
template = isMedia ? mediaFile.replace(/\.[^/.]+$/, '') : template;
let mediaType = text.toLowerCase().endsWith('.mp4') || text.toLowerCase().endsWith('.mov') ? 'video' : 'image';
let data: any = {
name: template,
@ -674,9 +675,9 @@ export class GBConversationalService {
type: 'header',
parameters: [
{
type: 'image',
image: {
link: urlImage
type: mediaType,
media: {
link: urlMedia
}
}
]
@ -685,8 +686,9 @@ export class GBConversationalService {
};
await this.sendToMobile(min, mobile, data, null);
GBLogEx.info(min, `Sending answer file to mobile: ${mobile}. Header: ${urlImage}`);
GBLogEx.info(min, `Sending answer file to mobile: ${mobile}. Header: ${urlMedia}`);
}
// tslint:enable:no-unsafe-any
public async sendMarkdownToMobile(min: GBMinInstance, step: GBDialogStep, mobile: string, text: string) {

View file

@ -16,5 +16,5 @@ POST TO INSTAGRAM username, password, image, caption
# Postar no Facebook
POST TO FACEBOOK username, password, image, caption
# Postar no Twitter
TWEET username, password, image, caption
# Postar no BlueSky
BLUESKY username, password, image, caption

View file

@ -1,10 +0,0 @@
data = FIND "products.csv"
BEGIN SYSTEM PROMPT
Engage users effectively as if you're a sales assistant in the virtual store.
Begin by welcoming them warmly and encouraging them to explore our range of products.
Provide clear instructions on how to inquire about specific items or browse
categories. Ensure the tone is friendly, helpful, and inviting to encourage
interaction. Use prompts to guide users through the purchasing process and offer
assistance whenever needed. Offer them this products: ${ TOJSON (data) }
END SYSTEM PROMPT

View file

@ -1,4 +1,4 @@
name,value
Answer Mode,chart
llm File,northwind.db
llm Driver,sqlite
name,value
Answer Mode,sql
llm File,northwind.db
llm Driver,sqlite
1 name value
2 Answer Mode chart sql
3 llm File northwind.db
4 llm Driver sqlite