| 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 DeepSeekAdapter |
| 10 |
* |
| 11 |
* Providing standardized methods for generating AI responses, |
| 12 |
* keyword suggestions, and form field data. |
| 13 |
*/ |
| 14 |
class DeepSeekAdapter implements AIServiceInterface { |
| 15 |
|
| 16 |
/** |
| 17 |
* The DeepSeek client instance. |
| 18 |
* |
| 19 |
* @var object |
| 20 |
*/ |
| 21 |
private $deepSeekClient; |
| 22 |
|
| 23 |
/** |
| 24 |
* Constructor. |
| 25 |
* |
| 26 |
* Initializes the adapter with a DeepSeek client instance. |
| 27 |
* |
| 28 |
* @param object $deepSeekClient An instance of the DeepSeek client. |
| 29 |
*/ |
| 30 |
public function __construct( $deepSeekClient ) { |
| 31 |
$this->deepSeekClient = $deepSeekClient; |
| 32 |
} |
| 33 |
/** |
| 34 |
* Generate a general AI response using the DeepSeek client. |
| 35 |
* |
| 36 |
* @param string $content_type The type of content to generate (title, description, short_description). |
| 37 |
* @param string $instruction The product information or user instruction. |
| 38 |
* |
| 39 |
* @return string The AI-generated response text. |
| 40 |
*/ |
| 41 |
public function generateResponse( string $content_type, string $instruction ): string { |
| 42 |
$system_prompt = AIFns::build_prompt( $content_type, $instruction ); |
| 43 |
return $this->deepSeekClient->ask( $instruction, $system_prompt ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Generate keyword-based AI suggestions or responses using the DeepSeek client. |
| 48 |
* |
| 49 |
* @param mixed $data Input data for keyword generation. |
| 50 |
* |
| 51 |
* @return mixed The AI-generated keyword response. |
| 52 |
*/ |
| 53 |
public function generateKeywordResponse( $data ) { |
| 54 |
return $this->deepSeekClient->askKeyword( $data ); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Generate semantic text embeddings using the DeepSeek API. |
| 59 |
* |
| 60 |
* @param mixed $data The input text or data used to create embeddings. |
| 61 |
* |
| 62 |
* @return mixed The embedding vector array or DeepSeek API response. |
| 63 |
*/ |
| 64 |
public function generateEmbedding( $data ) { |
| 65 |
return []; |
| 66 |
} |
| 67 |
} |
| 68 |
|