App-SpreadRevolutionaryDate
view release on metacpan or search on metacpan
--targets=Bluesky
# Spread Gemini generating an illustrated joke on Mastodon
# NB: usually prompts are defined in configuration file along
# with api_key, while --gemini-process is passed on command line
# to choose which prompt to process
$ spread-revolutionary-date \
--targets=Mastodon \
--msgmaker=Gemini \
--gemini_api_key=ApiKey \
--gemini_process=MacronJokeColuche \
--gemini_prompt 'MacronJokeColuche=Invente-moi une blague \
dans le style de Coluche sur Emmanuel Macron. Pas besoin \
de dire "D\'accord, voici une blague" ou "Bien sûr, \
voici une blague dans le style de Coluche sur Emmanuel \
Macron" avant la blague.' \
--gemini_img_path "MacronJokeColuche='/my/path/to/image.png'" \
--gemini_img_alt "MacronJokeColuche='Caricature de Coluche \
disant : « Câest lâhistoire dâun mec⦠» avec une caricature \
de macron'" \
# Spread Gemini searching for real time weather on Mastodon
# NB: usually prompts are defined in configuration file along
# with api_key, while --gemini-process is passed on command line
# to choose which prompt to process
$ spread-revolutionary-date \
--targets=Mastodon \
--msgmaker=Gemini \
This way, you can setup different prompts in your configuration file.
Here is an example with 4 different prompts configured:
[Gemini]
# See https://ai.google.dev/gemini-api/docs/api-key
api_key = 'GEMINI_API_KEY'
prompt FamousBirthday = 'Which famous people have their birthday on $month_name $day? Give a list of up to 6 people, then after the list give the unformatted URL of the Wikipedia page of only one of them, no comments and no need for an i...
intro FamousBirthday = 'FamousBirthday=Famous people born on $month_name $day for better or for worse:'
prompt MacronJokeColuche = 'Invente-moi une blague dans le style de Coluche sur Emmanuel Macron. Pas besoin de dire "D\'accord, voici une blague" ou "Bien sûr, voici une blague dans le style de Coluche sur Emmanuel Macron" avant la blague....
img_path MacronJokeColuche = '/usr/local/share/perl/5.32.1/auto/share/dist/App-SpreadRevolutionaryDate/images/coluche_macron.png'
img_alt MacronJokeColuche = 'Caricature de Coluche disant : « Câest lâhistoire dâun mec⦠» avec une caricature de macron'
prompt BlanquiRevival = 'Invente-moi un dicton révolutionnaire dans le style d\'Auguste Blanqui. Ne fais pas d\'introduction.'
img_url BlanquiRevival = 'https://example.com/imgs/my_image.jgp'
prompt MeteoParis = 'Quelle est la météo aujourd\'hui à Paris, avec la température, selon meteo-paris.com, ne devine pas, va chercher l\'information.'
search MeteoParis = 1
and, then choose the prompt to use at execution time, like:
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=FamousBirthday --locale=en
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=MacronJokeColuche
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=BlanquiRevival
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=MeteoParis
These examples show how you can tweak your message to be spread. Let's
review all these options:
First, you have to define credentials to use the Gemini API, by
defining the "api_key" option. For this you need to get a Gemini API
key, by following instructions on
https://ai.google.dev/gemini-api/docs/api-key.
Then for each prompt, you have to choose an identifier, which is one
word in camel case, like FamousBirthday, MacronJokeColuche,
BlanquiRevival or MeteoParis. This prompt identifier should be the
value of the --gemini_process <ThisPrompt> command line parameter.
All other options are relative to one particular prompt, and therefore
prefixed with the corresponding identifier. Under the hood, these
options are hashes keyed with prompt identifiers:
"prompt"
This is the option where you can define your prompt. It is advised to
bin/spread-revolutionary-date view on Meta::CPAN
--targets=Bluesky
# Spread Gemini generating an illustrated joke on Mastodon
# NB: usually prompts are defined in configuration file along
# with api_key, while --gemini-process is passed on command line
# to choose which prompt to process
$ spread-revolutionary-date \
--targets=Mastodon \
--msgmaker=Gemini \
--gemini_api_key=ApiKey \
--gemini_process=MacronJokeColuche \
--gemini_prompt 'MacronJokeColuche=Invente-moi une blague \
dans le style de Coluche sur Emmanuel Macron. Pas besoin \
de dire "D\'accord, voici une blague" ou "Bien sûr, \
voici une blague dans le style de Coluche sur Emmanuel \
Macron" avant la blague.' \
--gemini_img_path "MacronJokeColuche='/my/path/to/image.png'" \
--gemini_img_alt "MacronJokeColuche='Caricature de Coluche \
disant : « Câest lâhistoire dâun mecâ¦Â » avec une caricature \
de macron'" \
# Spread Gemini searching for real time weather on Mastodon
# NB: usually prompts are defined in configuration file along
# with api_key, while --gemini-process is passed on command line
# to choose which prompt to process
$ spread-revolutionary-date \
--targets=Mastodon \
--msgmaker=Gemini \
bin/spread-revolutionary-date view on Meta::CPAN
From version 0.45, a new message maker is included which requests I<Gemini> AI. This allows to extend C<spread-revolutionary-date> just by configuring a few options. The most practical way to configure these options is to prepare everything by settin...
This way, you can setup different prompts in your configuration file. Here is an example with 4 different prompts configured:
[Gemini]
# See https://ai.google.dev/gemini-api/docs/api-key
api_key = 'GEMINI_API_KEY'
prompt FamousBirthday = 'Which famous people have their birthday on $month_name $day? Give a list of up to 6 people, then after the list give the unformatted URL of the Wikipedia page of only one of them, no comments and no need for an intro...
intro FamousBirthday = 'FamousBirthday=Famous people born on $month_name $day for better or for worse:'
prompt MacronJokeColuche = 'Invente-moi une blague dans le style de Coluche sur Emmanuel Macron. Pas besoin de dire "D\'accord, voici une blague" ou "Bien sûr, voici une blague dans le style de Coluche sur Emmanuel Macron" avant la blague.'
img_path MacronJokeColuche = '/usr/local/share/perl/5.32.1/auto/share/dist/App-SpreadRevolutionaryDate/images/coluche_macron.png'
img_alt MacronJokeColuche = 'Caricature de Coluche disant : « Câest lâhistoire dâun mecâ¦Â » avec une caricature de macron'
prompt BlanquiRevival = 'Invente-moi un dicton révolutionnaire dans le style d\'Auguste Blanqui. Ne fais pas d\'introduction.'
img_url BlanquiRevival = 'https://example.com/imgs/my_image.jgp'
prompt MeteoParis = 'Quelle est la météo aujourd\'hui à Paris, avec la température, selon meteo-paris.com, ne devine pas, va chercher l\'information.'
search MeteoParis = 1
and, then choose the prompt to use at execution time, like:
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=FamousBirthday --locale=en
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=MacronJokeColuche
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=BlanquiRevival
$ spread-revolutionary-date --msgmaker=Gemini --gemini_process=MeteoParis
These examples show how you can tweak your message to be spread. Let's review all these options:
First, you have to define credentials to use the I<Gemini API>, by defining the L</api_key> option. For this you need to get a I<Gemini API key>, by following instructions on L<https://ai.google.dev/gemini-api/docs/api-key>.
Then for each prompt, you have to choose an identifier, which is one word in camel case, like C<FamousBirthday>, C<MacronJokeColuche>, C<BlanquiRevival> or C<MeteoParis>. This prompt identifier should be the value of the C<< --gemini_process <ThisPro...
All other options are relative to one particular prompt, and therefore prefixed with the corresponding identifier. Under the hood, these options are hashes keyed with prompt identifiers:
=over
=item L</prompt>
This is the option where you can define your prompt. It is advised to test this prompt to have I<Gemini> answer as you wish. For instance, I<Gemini> often start its answers to your prompt by: âSure, here is âwhat you've asked forâ, and you woul...
You can test your prompt with interactive form to I<Gemini> at L<https://gemini.google.com/app> or with C<spread-revolutionary-date> with options C<--test> and C<--targets=Mastodon> for example.
etc/sample-spread-revolutionary-date.conf view on Meta::CPAN
[RevolutionaryDate]
acab
[Gemini]
# See https://ai.google.dev/gemini-api/docs/api-key
api_key = 'api_key'
prompt FamousBirthday = 'Which famous people have their birthday on $month_name $day ? Give a list of up to 6 people, then after the list give the unformatted URL of the Wikipedia page of only one of them, no comments and no need for an introducti...
intro FamousBirthday = 'FamousBirthday=Famous people born on $month_name $day for better or for worse:'
prompt MacronJokeColuche = 'Invente-moi une blague dans le style de Coluche sur Emmanuel Macron. Pas besoin de dire "D\'accord, voici une blague" ou "Bien sûr, voici une blague dans le style de Coluche sur Emmanuel Macron" avant la blague.'
img_path MacronJokeColuche = '/usr/local/share/perl/5.32.1/auto/share/dist/App-SpreadRevolutionaryDate/images/coluche_macron.png'
img_alt MacronJokeColuche = 'Caricature de Coluche disant : « Câest lâhistoire dâun mecâ¦Â » avec une caricature de macron'
prompt BlanquiRevival = 'Invente-moi un dicton révolutionnaire dans le style d\'Auguste Blanqui. Ne fais pas d\'introduction.'
img_url BlanquiRevival = 'https://example.com/imgs/my_image.jgp'
prompt MeteoParis = 'Quelle est la météo aujourd\'hui à Paris, avec la température, selon meteo-paris.com, ne devine pas, va chercher l\'information.'
search MeteoParis = 1
seek DATA, $data_start, 0;
eval { my $spread_gemini_no_prompt = App::SpreadRevolutionaryDate->new(\*DATA); };
chomp $@;
like($@, qr/Process NoPrompt has no prompt/, 'Gemini without process option');
@ARGV = ('--msgmaker=Gemini', '--test', '--gemini_process=AnniversairePeople');
seek DATA, $data_start, 0;
my $spread_gemini = App::SpreadRevolutionaryDate->new(\*DATA);
is($spread_gemini->config->gemini_process, 'AnniversairePeople', 'Gemini process option value');
my @gemini_prompt_keys = sort keys %{$spread_gemini->config->gemini_prompt};
is_deeply(\@gemini_prompt_keys, ['AnniversairePeople', 'MacronJokeColuche'], 'Gemini prompt option keys');
like($spread_gemini->config->gemini_prompt->{AnniversairePeople}, qr/^Quelles sont les personalit.s ayant leurs anniversaire le /, 'Gemini promt option value');
ok($spread_gemini->config->gemini_search->{MacronJokeColuche}, 'Gemini search set');
ok(!$spread_gemini->config->gemini_search->{AnniversairePeople}, 'Gemini search unset');
is($spread_gemini->config->gemini_img_path->{MacronJokeColuche}, '~/Images/coluche_macron.png', 'Gemini img path');
is($spread_gemini->config->gemini_img_url->{MacronJokeColuche}, 'https://upload.wikimedia.org/wikipedia/commons/3/38/Emmanuel_Macron_-_Caricature_%2840366024295%29.jpg', 'Gemini img url');
is($spread_gemini->config->gemini_img_alt->{MacronJokeColuche}, 'Caricature de Coluche disant : « Câest lâhistoire dâun mecâ¦Â » avec une caricature de macron', 'Gemini img alt');
__DATA__
[bluesky]
# Get these values from https://bsky.app/
identifier = 'Identifier'
password = 'Password'
[twitter]
# Get these values from https://apps.twitter.com/
consumer_key = 'ConsumerKey'
password = 'Password'
test_channels = '#TestChannel1'
test_channels = '#TestChannel2'
channels = '#Channel1'
channels = '#Channel2'
channels = '#Channel3'
[Gemini]
api_key = APIKEY
prompt AnniversairePeople = "Quelles sont les personalités ayant leurs anniversaire le $day $month ? Donne une liste d'au maximum 6 personnes, puis après la liste donne l'URL sans formattage de la fiche wikipédia d'une seule d'entre elles, ne com...
prompt MacronJokeColuche = "Je veux envoyer chaque jour une blague différente sur les réseaux sociaux Mastodon et Bluesky. La blague doit être chaque fois suffisamment différente, toujours dans le style de Coluche et toujours sur Emmanuel Macro...
search MacronJokeColuche = 1
img_path MacronJokeColuche = '~/Images/coluche_macron.png'
img_url MacronJokeColuche = 'https://upload.wikimedia.org/wikipedia/commons/3/38/Emmanuel_Macron_-_Caricature_%2840366024295%29.jpg'
img_alt MacronJokeColuche = 'Caricature de Coluche disant : « Câest lâhistoire dâun mecâ¦Â » avec une caricature de macron'
( run in 0.677 second using v1.01-cache-2.11-cpan-49f99fa48dc )