Add AI writing assistant plugin with local backend, brave search, and image generation support
- Implement local backend AI provider with Ollama integration - Add Brave Search API integration for real-time search suggestions - Add image generation manager with multiple AI providers - Create hybrid provider system with local/cloud fallback - Add comprehensive settings UI with provider management - Implement Gutenberg sidebar with writing assistance controls - Add SEO schema generation for AI-generated content - Multiple provider support: OpenRouter, local backend, Codex
This commit is contained in:
67
includes/interface-ai-provider.php
Normal file
67
includes/interface-ai-provider.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* AI Provider Interface
|
||||
*
|
||||
* Common contract for all AI providers (OpenRouter, Local Backend, Codex, etc.)
|
||||
*
|
||||
* @package WP_Agentic_Writer
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
interface WP_Agentic_Writer_AI_Provider_Interface {
|
||||
/**
|
||||
* Non-streaming chat completion
|
||||
*
|
||||
* @param array $messages Array of message objects with 'role' and 'content'.
|
||||
* @param array $options Optional parameters (temperature, max_tokens, etc.).
|
||||
* @param string $type Task type (chat, clarity, planning, writing, refinement).
|
||||
* @return array|WP_Error Response with content, model, tokens, cost, or error.
|
||||
*/
|
||||
public function chat( $messages, $options = array(), $type = 'planning' );
|
||||
|
||||
/**
|
||||
* Streaming chat completion
|
||||
*
|
||||
* @param array $messages Array of message objects.
|
||||
* @param array $options Optional parameters.
|
||||
* @param string $type Task type.
|
||||
* @param callable $callback Function to call with each chunk (chunk, is_complete, accumulated).
|
||||
* @return array|WP_Error Response with accumulated content, tokens, cost, or error.
|
||||
*/
|
||||
public function chat_stream( $messages, $options = array(), $type = 'planning', $callback = null );
|
||||
|
||||
/**
|
||||
* Generate image
|
||||
*
|
||||
* @param string $prompt Image generation prompt.
|
||||
* @param string $model Model to use (optional, uses provider default).
|
||||
* @param array $options Optional parameters (size, quality, n).
|
||||
* @return array|WP_Error Response with url, model, cost, or error.
|
||||
*/
|
||||
public function generate_image( $prompt, $model = null, $options = array() );
|
||||
|
||||
/**
|
||||
* Check if provider is properly configured
|
||||
*
|
||||
* @return bool True if configured and ready to use.
|
||||
*/
|
||||
public function is_configured();
|
||||
|
||||
/**
|
||||
* Test connection to provider
|
||||
*
|
||||
* @return array|WP_Error Success array or error details.
|
||||
*/
|
||||
public function test_connection();
|
||||
|
||||
/**
|
||||
* Check if provider supports a specific task type
|
||||
*
|
||||
* @param string $type Task type (chat, clarity, planning, writing, refinement, image).
|
||||
* @return bool True if supported.
|
||||
*/
|
||||
public function supports_task_type( $type );
|
||||
}
|
||||
Reference in New Issue
Block a user