可以使用大模型实现
我们以gemini为例,先注册gemini并获取apikey
composer require google-gemini-php/clientcomposer require guzzlehttp/guzzle
注意,需要php8,1以上的环境才能使用
下面是php调用gemini的api实现问答代码
<?php declare(strict_types=1); require_once '../vendor/autoload.php'; $apiKey = 'AIzaSyAPxxxxxxxxxxxxxxx_uEpw'; $client = \Gemini::client($apiKey); $result = $client->geminiPro()->generateContent('PHP语言是什么?'); echo $result->text() . PHP_EOL;那么验证码图片识别如下:
<?php declare(strict_types=1); require_once '../vendor/autoload.php'; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; $apiKey = 'AIzaSyAPLiuNxxxxxxxxxxxxxxx_uEpw'; $client = \Gemini::factory() ->withApiKey($apiKey) ->withBaseUrl('https://gemini.ailard.com/v1/') ->withHttpClient($client = new \GuzzleHttp\Client([])) ->withStreamHandler(fn(RequestInterface $request): ResponseInterface => $client->send($request, [ 'stream' => true // Allows to provide a custom stream handler for the http client. ])) ->make(); $result = $client ->geminiProVision() ->generateContent([ 'I will provide you with an image CAPTCHA, please recognize the content inside the CAPTCHA and output the text', new \Gemini\Data\Blob( mimeType: \Gemini\Enums\MimeType::IMAGE_JPEG, data: base64_encode( file_get_contents('./captcha01.jpg') ) ) ]); echo $result->text() . PHP_EOL;
网友回复
python如何实现声纹识别用户进行验证?
在哪可找到各种影视经典角色的配音并克隆音色根据文本说话?
阿里通义大模型哪些是支持多模态的api的ai模型?
js如何实现浏览器中离线语音唤醒语音聊天小助手?
浏览器中如何将WebM视频转成mp4视频?
parlant如何改成qwen 的apikey与baseurl?
如何写一个chrome插件实现截屏自动生成步骤图文教程转成pdf或网页?
python如何通过阿里云的api对域名进行解析和ecs主机服务器进行启动停止等操作?
Tesla Robotaxi可以让特斯拉车自动无人驾驶跑滴滴为车主赚钱,国内以后也会这样吗?
有没有可以监控安卓手机上的app打开后偷偷摸摸做了啥的监控软件?