[WordPress] 外掛分享: AI Services

WordPress 外掛 AI Services 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「AI Services」是 2024-10-08 上架。
  • 目前有 40 個安裝啟用數。
  • 上一次更新是 2025-04-22,距離現在已有 12 天。
  • 外掛最低要求 WordPress 6.0 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 7.2 以上。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

flixos90 |

外掛標籤

AI | multimodal | Text generation | function calling | image-generation |

內容簡介

**總結:**
- 這款AI服務外掛仍處於早期階段,功能有限,還有改進的空間。
- 這個外掛介紹了一個中央基礎架構,讓其他外掛能夠利用AI功能。
- 外掛的核心功能是提供統一的API,可在不同情境下使用AI功能。
- 它支持不同的AI服務,並且提供了內建的AI服務實現。
- 這款外掛不會內建特定的AI功能,只有一個可關閉的WordPress協助聊天機器人。
- 集中的AI基礎架構有助於開發者避免重複造輪,並且提供更多彈性和選擇。

**問題與答案:**
1. 這款AI服務外掛的狀態如何?
- 答:目前仍處於早期階段,功能有限,可能會存在一些變動。
2. 這個外掛的主要功能是什麼?
- 答:它提供一個中央基礎架構,讓其他外掛能夠利用AI功能,並且提供統一的API。
3. 這款外掛支持哪些AI服務?
- 答:支持Anthropic、Google、OpenAI等內建AI服務,也可以註冊其他AI服務的實現。
4. 這款外掛除了提供中央基礎架構外還有什麼內建功能?
- 答:除了一個關閉功能的WordPress協助聊天機器人外,沒有其他使用者界面功能。
5. 集中的AI基礎架構有什麼好處?
- 答:它有助於開發者避免重複造輪,並提供更多選擇,同時節省開發時間。

原文外掛簡介

This WordPress plugin introduces central infrastructure which allows other plugins to make use of AI capabilities. It exposes APIs that can be used in various contexts, whether you need to use AI capabilities in server-side or client-side code. Furthermore, the APIs are agnostic of the AI service – whether that’s Anthropic, Google, or OpenAI, to only name a few, you can use any of them in the same way. You can also register your own implementation of another service, if it is not supported out of the box.
The plugin does intentionally not come with specific AI driven features built-in, except for an AI Playground screen to explore AI capabilities as well as a settings screen to configure AI service credentials. The purpose of this plugin is to facilitate use of AI by other plugins. As such, it is a perfect use-case for plugin dependencies.
Here’s a (non-comprehensive) feature list:

Abstraction layer and APIs to communicate with any AI service in a uniform way

APIs are available in both PHP and in JavaScript, as well as via the WordPress REST API and WP-CLI commands
Currently supports the following AI capabilities (with more on the way!):

text generation (including text streaming for more immediate feedback to users)
text chats with history
multimodal input
function calling
image generation

AI Playground administration screen (in the Tools menu) allows exploring the different AI capabilities

Explore all AI capabilities supported by the plugin via user interface
Select which AI service and model to use and set a few advanced configuration parameters
Define your own function declarations used for AI function calling
Generate images and save them to the WordPress media library
Exchange the AI service or model on the fly to continue a chat started with one model with another one

AI Services settings screen to configure services with API credentials
Built-in AI service implementations

Anthropic (Claude)
Google (Gemini, Imagen)
OpenAI (GPT, Dall-E)
Browser (client-side only; experimental support for Chrome’s built-in AI APIs)

Additional AI service integrations can be registered and will then be available in the same way as built-in ones

Disclaimer: The AI Services plugin is still in its early stages, with a limited feature set and more being added. A crucial part of refining the plugin is shaping the APIs to make them easy to use and cover the different generative AI capabilities that the AI services offer in a uniform way. That’s why your feedback is much appreciated!
Why?

A centralized AI infrastructure facilitates user choice. Users may prefer certain AI services over other ones, and for many common tasks, either of the popular AI services is suitable. Having a common API regardless of the AI service allows leaving the choice to the user, rather than the plugin author.
Since the centralized AI infrastructure comes with a common API that works the same for every AI service, it means plugin developers don’t have to spend as much time familiarizing themselves with different services, at least when it comes to simple tasks. For tasks where certain services may have advantages over others, there is still flexibility to focus on a specific AI service.
It also means no more reinventing the wheel: Since most AI services do not provide PHP SDKs for their APIs, many times this means WordPress plugins that want to leverage AI have to implement their own layer around the service’s API. Not only is that time consuming, it also distracts from working on the actual (AI driven) features that the plugin should offer to its users. In fact this directly facilitates the user choice aspect mentioned, as having APIs for various AI services already provided means you can simply make those available to your plugin users.
Having central AI infrastructure available unlocks AI capabilities for smaller plugins or features: It may not be worth the investment to implement a whole AI API layer for a simple AI driven feature, but when you already have it available, it can lead to more plugins (and thus more users) benefitting from AI capabilities.
Last but not least, a central AI infrastructure means users will only have to configure the AI API once, e.g. paste their API keys only in a single WordPress administration screen. Without central AI infrastructure, every plugin has to provide its own UI for pasting API keys, making the process more tedious for site owners the more AI capabilities their site uses.

Integration with third party services
While the plugin APIs allow registering custom AI services, the plugin comes with a few popular AI services built-in. These AI services rely on the respective third party API. Their use is optional and it is up to you to choose which third party service you would like to use or whether you would like to use multiple.
The use of the third party AI services is subject to the respective terms of service. The following third party services are supported out of the box:

Anthropic (Claude)

Anthropic Consumer Terms of Service
Anthropic Commercial Terms of Service
Anthropic Privacy Policy

Google (Gemini, Imagen)

Google Terms of Service
Google AI Terms of Service
Google Privacy Policy

OpenAI (GPT, Dall-E)

OpenAI Terms of Use
OpenAI Privacy Policy

Code examples for using the API
Generate the answer to a prompt in PHP code:
use Felix_Arntz\AI_Services\Services\API\Enums\AI_Capability;
use Felix_Arntz\AI_Services\Services\API\Helpers;

if ( ai_services()->has_available_services() ) {
$service = ai_services()->get_available_service();
try {
$candidates = $service
->get_model(
array(
'feature' => 'my-test-feature',
'capabilities' => array( AI_Capability::TEXT_GENERATION ),
)
)
->generate_text( 'What can I do with WordPress?' );

$text = Helpers::get_text_from_contents(
Helpers::get_candidate_contents( $candidates )
);

echo $text;
} catch ( Exception $e ) {
// Handle the exception.
}
}

Generate the answer to a prompt in JavaScript code:
const helpers = aiServices.ai.helpers;
const { hasAvailableServices, getAvailableService } = wp.data.select( 'ai-services/ai' );
if ( hasAvailableServices() ) {
const service = getAvailableService();
try {
const candidates = await service.generateText(
'What can I do with WordPress?',
{ feature: 'my-test-feature' }
);

const text = helpers.getTextFromContents(
helpers.getCandidateContents( candidates )
);

console.log( text );
} catch ( error ) {
// Handle the error.
}
}

Generate the answer to a prompt using WP-CLI:
wp ai-services generate-text "What can I do with WordPress?" --feature=my-test-feature

You can also use a specific AI service, if you have a preference, for example the google service.
Generate the answer to a prompt using a specific AI service, in PHP code:
use Felix_Arntz\AI_Services\Services\API\Enums\AI_Capability;
use Felix_Arntz\AI_Services\Services\API\Helpers;

if ( ai_services()->is_service_available( 'google' ) ) {
$service = ai_services()->get_available_service( 'google' );
try {
$candidates = $service
->get_model(
array(
'feature' => 'my-test-feature',
'capabilities' => array( AI_Capability::TEXT_GENERATION ),
)
)
->generate_text( 'What can I do with WordPress?' );

$text = Helpers::get_text_from_contents(
Helpers::get_candidate_contents( $candidates )
);

echo $text;
} catch ( Exception $e ) {
// Handle the exception.
}
}

Refer to the plugin documentation for granular examples including explainers.
For complete examples such as entire plugins built on top of the AI Services infrastructure, please see the examples directory on GitHub.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「AI Services」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


0.1.0 | 0.1.1 | 0.2.0 | 0.3.0 | 0.4.0 | 0.5.0 | 0.6.0 | 0.6.1 | trunk |

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Apply Filters
Mastodon