Skip to content

Commit 72ad4c8

Browse files
authored
Merge pull request #55 from newfold-labs/update/site-gen-classification
Pass site classification in `generatePageContent` payload
2 parents 0121890 + fb8ddd4 commit 72ad4c8

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

bootstrap.php

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function () {
1919
define( 'NFD_AI_SERVICE_BASE', 'https://hiive.cloud/workers/ai-proxy/v1/' );
2020
define( 'NFD_AI_BASE', 'https://hiive.cloud/workers/ai-sitegen-proxy/' );
2121
define( 'NFD_PATTERNS_BASE', 'https://patterns.hiive.cloud/' );
22+
define( 'NFD_CONTENT_GENERATION_BASE', 'https://patterns.hiive.cloud/api/v1/content-generation/' );
2223
define( 'NFD_SITEGEN_OPTION', 'nfd-ai-site-gen' );
2324
}
2425

includes/SiteGen/SiteGen.php

+34-11
Original file line numberDiff line numberDiff line change
@@ -552,24 +552,36 @@ public static function get_home_pages( $site_description, $content_style, $targe
552552
),
553553
'keywords'
554554
);
555+
556+
// Site classification: primary and secondary types
557+
$site_classification = self::get_sitegen_from_cache( 'siteclassification' );
558+
$primary_type = 'other';
559+
$secondary_type = 'other';
560+
if ( is_array( $site_classification ) ) {
561+
$primary_type = $site_classification['primaryType'] ?? 'other';
562+
$secondary_type = $site_classification['slug'] ?? 'other';
563+
}
564+
555565
if ( ! $generated_content_structures ) {
556566
$response = wp_remote_post(
557-
NFD_AI_BASE . 'generatePageContent',
567+
NFD_CONTENT_GENERATION_BASE . 'page',
558568
array(
559569
'headers' => array(
560-
'Content-Type' => 'application/json',
570+
'Content-Type' => 'application/json',
571+
'Authorization' => 'Bearer ' . HiiveConnection::get_auth_token(),
561572
),
562573
'timeout' => 60,
563574
'body' => wp_json_encode(
564575
array(
565-
'hiivetoken' => HiiveConnection::get_auth_token(),
566-
'prompt' => array(
576+
'prompt' => array(
567577
'site_description' => $site_description,
568578
'keywords' => wp_json_encode( $keywords ),
569579
'content_style' => wp_json_encode( $content_style ),
570580
'target_audience' => wp_json_encode( $target_audience ),
571581
),
572-
'page' => 'home',
582+
'page' => 'home',
583+
'primaryType' => $primary_type,
584+
'secondaryType' => $secondary_type,
573585
)
574586
),
575587
)
@@ -811,23 +823,34 @@ function ( $key ) use ( $menu_patterns_slugs ) {
811823
}
812824
}
813825

826+
// Site classification: primary and secondary types
827+
$site_classification = self::get_sitegen_from_cache( 'siteclassification' );
828+
$primary_type = 'other';
829+
$secondary_type = 'other';
830+
if ( is_array( $site_classification ) ) {
831+
$primary_type = $site_classification['primaryType'] ?? 'other';
832+
$secondary_type = $site_classification['slug'] ?? 'other';
833+
}
834+
814835
$response = wp_remote_post(
815-
NFD_AI_BASE . 'generatePageContent',
836+
NFD_CONTENT_GENERATION_BASE . 'page',
816837
array(
817838
'headers' => array(
818-
'Content-Type' => 'application/json',
839+
'Content-Type' => 'application/json',
840+
'Authorization' => 'Bearer ' . HiiveConnection::get_auth_token(),
819841
),
820842
'timeout' => 60,
821843
'body' => wp_json_encode(
822844
array(
823-
'hiivetoken' => HiiveConnection::get_auth_token(),
824-
'prompt' => array(
845+
'prompt' => array(
825846
'site_description' => $site_description,
847+
'keywords' => wp_json_encode( $keywords ),
826848
'content_style' => wp_json_encode( $content_style ),
827849
'target_audience' => wp_json_encode( $target_audience ),
828850
),
829-
'page' => $page,
830-
'keywords' => wp_json_encode( $keywords ),
851+
'page' => $page,
852+
'primaryType' => $primary_type,
853+
'secondaryType' => $secondary_type,
831854
)
832855
),
833856
)

0 commit comments

Comments
 (0)