Skip to content

Commit

Permalink
Added placeholders to Ai Promt Fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiten14 committed Sep 26, 2024
1 parent 4bdaa62 commit 0918fad
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ All notable changes to `jitone-ai` will be documented in this file.
## v0.1.1 - 2024-09-19

- Added support for multiple OpenAI endpoints.

## v0.1.3 - 2024-09-26

- Added placeholders to Ai Promt Fields.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ Jitone AI follows semantic versioning:

- **v0.1.0**: Initial release.
- **v0.1.1**: Added support for multiple OpenAI endpoints.
- **v0.1.3**: Added placeholders to Ai Promt Fields.

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Expand Down
28 changes: 28 additions & 0 deletions config/jitone-ai.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
'video_script_intro' => 'Write an engaging introduction for a video script about [topic].',
'podcast_episode_summary' => 'Summarize the key points of a podcast episode about [topic].',
],

// Add Content Templates placeholders here
'template_placeholders' => [
'product_description' => 'Write your product name',
'blog_intro' => 'Write your blog topic',
'email_subject' => 'Write your email purpose',
'social_media_post' => 'Write the event or product',
'seo_meta_description' => 'Write the webpage topic',
'customer_service_reply' => 'Write the issue',
'faq_answer' => 'Write the FAQ question',
'press_release_headline' => 'Write the news item',
'video_script_intro' => 'Write the video topic',
'podcast_episode_summary' => 'Write the podcast topic',
],

'image_prompts' => [
'product_showcase' => 'A professional photo of [product] on a white background.',
Expand All @@ -34,4 +48,18 @@
'logo_concept' => 'A minimalist logo design for a company named [company name].',
'infographic_element' => 'A clean and modern infographic element representing [data or concept].',
],

// Add Image prompt placeholders here
'prompt_placeholders' => [
'product_showcase' => 'Write your product name',
'nature_scene' => 'Write natural elements',
'abstract_concept' => 'Write your concept',
'character_portrait' => 'Describe the character',
'food_photography' => 'Write the dish name',
'tech_illustration' => 'Write the technology name',
'fashion_design' => 'Write clothing items & style',
'book_cover' => 'Write Genre & Book name',
'logo_concept' => 'Write the company name',
'infographic_element' => 'Explain the data or concept',
],
];
5 changes: 4 additions & 1 deletion src/Forms/Actions/GenerateContentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function execute($field, $record, $data, array $options = [])
Textarea::make('ai_prompt')
->label('Enter your prompt')
->required()
->placeholder(fn ($get) => $get('ai_prompt_placeholder'))
->visible(fn (callable $get) => !$get('use_existing_content')),
Select::make('template')
->label('Or choose a template')
Expand All @@ -49,8 +50,10 @@ public function execute($field, $record, $data, array $options = [])
})
->reactive()
->afterStateUpdated(function ($state, callable $set) {
$placeholders = app(JitoneAi::class)->getTemplatesPlaceholders();
if ($state) {
$set('ai_prompt', $state);
$placeholder = $placeholders[$state] ?? 'Write your content here';
$set('ai_prompt_placeholder', $placeholder);
}
})
->visible(fn (callable $get) => !$get('use_existing_content')),
Expand Down
7 changes: 5 additions & 2 deletions src/Forms/Actions/GenerateImageAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ public function execute($field, $record, $data, array $options = [])
->form([
Textarea::make('ai_prompt')
->label('Describe the image you want to generate')
->required(),
->required()
->placeholder(fn ($get) => $get('ai_prompt_placeholder')),
Select::make('template')
->label('Or choose a template')
->options(function () {
return app(JitoneAi::class)->getImagePrompts();
})
->reactive()
->afterStateUpdated(function ($state, callable $set) {
$placeholders = app(JitoneAi::class)->getPromptsPlaceholders();
if ($state) {
$set('ai_prompt', $state);
$placeholder = $placeholders[$state] ?? 'Write your content here';
$set('ai_prompt_placeholder', $placeholder);
}
}),
])
Expand Down

0 comments on commit 0918fad

Please sign in to comment.