Skip to content

Commit

Permalink
refactor keys to config
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarholt committed Oct 8, 2024
1 parent 0ee8209 commit b06f46b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/Extensions/SeoAICMSPageEditControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use voku\helper\HtmlDomParser;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Core\Config\Config;
use SilverStripe\SiteConfig\SiteConfig;

class SeoAICMSPageEditControllerExtension extends DataExtension
Expand Down Expand Up @@ -88,11 +89,12 @@ public function generatePrompt()
*/
public function promptAPICall($prompt)
{
$key = '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';
$openai = Config::inst()->get("openai");
$key = $openai->key;
$url = 'https://api.openai.com/v1/chat/completions';
$data = [
"model" => "gpt-4o-mini",
"temperature" => 0,
"model" => $openai->model,
"temperature" => $openai->temperature,
"messages" => [
[
"role" => "user",
Expand Down Expand Up @@ -162,4 +164,4 @@ public function populateMetaTagsFromAPI($response)

return false;
}
}
}
9 changes: 7 additions & 2 deletions src/Extensions/SeoAISiteConfigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class SeoAISiteConfigExtension extends DataExtension

public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.SEO', TextareaField::create('ContextPrompt', 'Brand Context Prompt')->setDescription('Additional information to give AI about your brand / content for more accurate metadata generation'), 'UseTitleAsMetaTitle');
$fields->addFieldToTab(
'Root.SEO',
TextareaField::create('ContextPrompt', 'Brand Context Prompt')
->setDescription('Additional information to give AI about your brand / content for more accurate metadata generation'),
'UseTitleAsMetaTitle'
);
}
}
}

0 comments on commit b06f46b

Please sign in to comment.