feat(KeywordsExpressions): add support for posting to Instagram with parameters
All checks were successful
GBCI / build (push) Successful in 2m2s

refactor(GBAdminService): improve folder name extraction logic
refactor(ImageProcessingServices): clean up whitespace and enhance image generation options
refactor(SystemKeywords): simplify rewrite prompt and logging
fix(ChatServices): correct spacing in model invocation
delete(marketing.gbai): remove outdated marketing poster template
add(marketing.gbai): create new marketing poster template with Instagram posting functionality
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-05-09 21:19:14 -03:00
parent e3992b34af
commit 1ef6cbb032
7 changed files with 38 additions and 34 deletions

View file

@ -168,7 +168,7 @@ export class GBAdminService implements IGBAdminService {
) { ) {
const packageName = text.split(' ')[1]; const packageName = text.split(' ')[1];
const folderName = text.split(' ')[2]; const folderName = text.substring(text.indexOf(packageName) + packageName.length + 1);
const packageType = path.extname(folderName).substr(1); const packageType = path.extname(folderName).substr(1);
const gbaiPath = GBUtil.getGBAIPath(min.instance.botId, packageType, null); const gbaiPath = GBUtil.getGBAIPath(min.instance.botId, packageType, null);
const localFolder = path.join('work', gbaiPath); const localFolder = path.join('work', gbaiPath);

View file

@ -113,7 +113,7 @@ export class ImageProcessingServices {
const azureOpenAIEndpoint = await min.core.getParam(min.instance, 'Azure Open AI Endpoint', null, true); const azureOpenAIEndpoint = await min.core.getParam(min.instance, 'Azure Open AI Endpoint', null, true);
const azureOpenAIVersion = await (min.core as any)['getParam'](min.instance, 'Azure Open AI Version', null, true); const azureOpenAIVersion = await (min.core as any)['getParam'](min.instance, 'Azure Open AI Version', null, true);
const azureOpenAIImageModel = await (min.core as any)['getParam'](min.instance, 'Azure Open AI Image Model', null, true); const azureOpenAIImageModel = await (min.core as any)['getParam'](min.instance, 'Azure Open AI Image Model', null, true);
if (azureOpenAIKey) { if (azureOpenAIKey) {
// Initialize the Azure OpenAI client // Initialize the Azure OpenAI client
@ -124,16 +124,17 @@ export class ImageProcessingServices {
apiVersion: azureOpenAIVersion, apiVersion: azureOpenAIVersion,
apiKey: azureOpenAIKey apiKey: azureOpenAIKey
}); });
// Make a request to the image generation endpoint
const response = await client.images.generate({
model: '',
prompt: prompt,
n: 1,
size: '1024x1024'
});
// Make a request to the image generation endpoint
const response = await client.images.generate({
prompt: prompt,
n: 1, // Don't include for DALL-E 3 (always generates 1 image)
style: 'vivid', // optional ('natural' or 'vivid')
size: '1024x1024',
quality: 'standard', // optional
});
const gbaiName = GBUtil.getGBAIPath(min.botId); const gbaiName = GBUtil.getGBAIPath(min.botId);
const localName = path.join('work', gbaiName, 'cache', `DALL-E${GBAdminService.getRndReadableIdentifier()}.png`); const localName = path.join('work', gbaiName, 'cache', `DALL-E${GBAdminService.getRndReadableIdentifier()}.png`);

View file

@ -906,6 +906,15 @@ export class KeywordsExpressions {
} }
]; ];
keywords[i++] = [
/^\s*(POST TO INSTAGRAM)(\s*)(.*)/gim,
($0, $1, $2, $3) => {
const params = this.getParams($3, ['username', 'password', 'imagePath', 'caption']);
return `await sys.postToInstagram ({pid: pid, ${params}})`;
}
];
keywords[i++] = [ keywords[i++] = [
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*(datediff)(\s*)(.*)/gim, /^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*(datediff)(\s*)(.*)/gim,
($0, $1, $2, $3, $4) => { ($0, $1, $2, $3, $4) => {

View file

@ -2616,6 +2616,8 @@ export class SystemKeywords {
return answer.answer; return answer.answer;
} }
/** /**
* HEAR description * HEAR description
* text = REWRITE description * text = REWRITE description
@ -2623,9 +2625,9 @@ export class SystemKeywords {
*/ */
public async rewrite({ pid, text }) { public async rewrite({ pid, text }) {
const { min, user } = await DialogKeywords.getProcessInfo(pid); const { min, user } = await DialogKeywords.getProcessInfo(pid);
const prompt = `Rewrite this sentence in a better way: ${text}`; const prompt = `${text}`;
const answer = await ChatServices.invokeLLM(min, prompt); const answer = await ChatServices.invokeLLM(min, prompt);
GBLogEx.info(min, `REWRITE ${text} TO ${answer}`); GBLogEx.info(min, `REWRITE ${text} TO ${answer.text}`);
return answer; return answer;
} }

View file

@ -250,7 +250,7 @@ export class ChatServices {
model = await ChatServices.getModel(min); model = await ChatServices.getModel(min);
return await model.invoke(text); return await model .invoke(text);
} }
public static memoryMap = {}; public static memoryMap = {};

View file

@ -1,20 +0,0 @@
REM SET SCHEDULE "* 8 * * * *"
user = "user@domain.com"
pass = "*************"
o = get "https://oooooooooo"
# Criar a legenda para o post
caption = REWRITE "Crie um post sobre produtos, no estilo dica do dia, incluindo 10 hashtags, estilo Instagram o texto! Importante, retorne só a saída de texto pronta"
# Obter uma imagem relacionada ao conteúdo
image = GET IMAGE caption
# Postar no Instagram
POST TO INSTAGRAM username, password, image, caption
# Postar no Facebook
POST TO FACEBOOK username, password, image, caption
# Postar no BlueSky
BLUESKY username, password, image, caption

View file

@ -0,0 +1,12 @@
' SET SCHEDULE "* 8 * * * *"
' Criar a legenda para o post
caption = REWRITE "Crie um post sobre produtos, no estilo dica do dia, incluindo 10 hashtags, estilo Instagram o texto! Importante, retorne só a saída de texto pronta"
' Obter uma imagem relacionada ao conteúdo
image = GET IMAGE caption
' Postar no Instagram
POST TO INSTAGRAM username, password, image, caption