PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / AI / AIServices / GeminiAdapter.php

GeminiAdapter.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at app/AI/AIServices/GeminiAdapter.php

68 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace RadiusTheme\SB\AI\AIServices;
4
5 use RadiusTheme\SB\AI\AIFns;
6 use RadiusTheme\SB\AI\AIServices\Interface\AIServiceInterface;
7
8 /**
9 * Class GeminiAdapter
10 *
11 * Providing a standardized interface for generating AI-based responses,
12 * keyword suggestions, and form field data.
13 */
14 class GeminiAdapter implements AIServiceInterface {
15
16 /**
17 * The Gemini client instance.
18 *
19 * @var object
20 */
21 private $geminiClient;
22
23 /**
24 * Constructor.
25 *
26 * Initializes the adapter with a Gemini client instance.
27 *
28 * @param object $geminiClient An instance of the Gemini client.
29 */
30 public function __construct( $geminiClient ) {
31 $this->geminiClient = $geminiClient;
32 }
33
34 /**
35 * Generate a general AI response using the Gemini client.
36 *
37 * @param string $content_type The type of content to generate (title, description, short_description).
38 * @param string $instruction The product information or user instruction.
39 *
40 * @return string The AI-generated response text.
41 */
42 public function generateResponse( string $content_type, string $instruction ): string {
43 $system_prompt = AIFns::build_prompt( $content_type, $instruction );
44 return $this->geminiClient->ask( $instruction, $system_prompt );
45 }
46
47 /**
48 * Generate keyword-based AI suggestions or responses using the Gemini client.
49 *
50 * @param mixed $data Input data for keyword generation.
51 *
52 * @return mixed The AI-generated keyword response.
53 */
54 public function generateKeywordResponse( $data ) {
55 return $this->geminiClient->askKeyword( $data );
56 }
57 /**
58 * Generate text embeddings using the Google Gemini API.
59 *
60 * @param mixed $data Input text or data to generate semantic embeddings for.
61 *
62 * @return mixed The embedding vector or API response from Gemini.
63 */
64 public function generateEmbedding( $data ) {
65 return $this->geminiClient->generateEmbedding( $data );
66 }
67 }
68