WordPress is an open source content management system (CMS) that allows users to create and manage their own websites. WordPress offers many plugins and themes that extend its functionality and adapt it to various website needs. It's easy to use and has many community-supported resources available. Therefore, it has become the tool of choice for many individuals and small businesses to create websites.
Link:WordPress official website
# integrates Baidu’s Wenxin Qianfan large model into WordPress and compares it with GPT
Last weekend, Baidu’s Wenxin Qianfan model was integrated into WordPress.
1. Basic process:
1. First apply to experience the Wenxin Qianfan large model on Baidu, which requires certification first.
2. After passing, activate the large model, because Baidu's large model is charged for use and is charged by token. You need to have a balance in your account to activate it.
3. Then, create an application so that it has appid, api key and secret key
4. Then, read the documentation and connect the corresponding interface.
Basically, you get the access token through the api key and secret key, and then submit the question and get the answer.
2. Key code
1. Obtain the key code of the access token
"`php
private function getAccessToken(){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => “https://aip.baidubce.com/oauth/2.0/token?client_id=”.$this->client_id.”&client_secret=”.$this->client_secret.”&grant_type=client_credentials”,
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$rtn = json_decode($response);
return $rtn->access_token;
}
“`
2. Call the key code of Ernie Bot large model
"`php
public function runErnieBot($message) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => “https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions?access_token={$this->getAccessToken()}”,
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$message,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
“`
3. Call the key code of Ernie Bot Turbo large model
"`php
public function runErnieBotTurbo($message) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => “https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token={$this->getAccessToken()}”,
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$message,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
“`
In the past few days of testing, the performance of Baidu Wenxin Qianfan's large model in Chinese is indeed much better than GPT.
The Chinese level of GPT is the level of "explanatory text".
The Chinese level of Baidu Wenxin Qianfan Large Model is at least better than the "explanatory text".
For WordPress theme authors and plugin authors, translating their own themes and plugins cannot avoid po files and […]
I've been iterating my own wordpress theme recently.
It is very common to obtain the term data of category and post-tag, two existing WordPress taxonomies, in the archive, and both have ready-made parameters and functions.
How to get the term data of custom taxonomy in archive?
get_queried_object()
This function can not only obtain the term data of custom taxonomy, but also the data of category and post-tag. Even if it is an archive of a custom post type, you can also get the current post type data.
$term_data = get_queried_object();//In archive.php, use it directly.
URL on wordpress official website: https://developer.wordpress.org/reference/functions/get_queried_object/
You can also get the current post and user data. However, I haven't tried these two.
Recently, for one of my websites, Baseon WordPress, the Gutenberg editor could not be used. When I opened it, the page was blank. I always thought it was caused by upgrading wordpress to v6.2 some time ago. I just figured it out today. It turns out that there is an extra "}" in a js file I wrote myself.
After removing this "}", the Gutenberg editor returns to normal.
1. Configuration of WordPress system roles and permissions. This configuration is stored in the wp_options table. You can get […]
Fires before the page loads on the 'Edit User' screen.
This hook is executed before the user profile page of the admin panel is opened.
This hook will also be used to extend the user management panel. But sometimes it doesn't work.
Fires immediately after an existing user is updated.
This hook is executed after the profile is updated.
Commonly used to extend user management panels.
wp_set_object_terms( int $object_id, str […]
cms (content management system) is a philosophical question. Because cms has already reached the philosophical level. We analyze some of the world’s best now and once […]