tuliovasconcelos / geminiphp
一个用于与Gemini API交互的PHP库。
dev-main
2024-05-21 17:08 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-25 16:45:00 UTC
README
GeminiPhp是一个用于集成Google人工智能的PHP库。此库允许您向Gemini API发送请求,并自动接收针对各种问题和上下文的响应。
安装
您可以通过Composer安装此库。在终端中执行以下命令
composer require tuliovasconcelos/geminiphp
如何使用
<?php require 'vendor/autoload.php'; use GeminiPhp\GeminiPhp; // Instanciar a biblioteca $PhpKey = "Sua-API-Key"; $systemInstruction = "Responda de forma clara e concisa com conceitos do PHP."; $question = "Como criar uma I.A?"; try { $geminiPhp = new GeminiPhp($PhpKey, $systemInstruction); $geminiPhp->setRequestData($question, 0.7, 50, 0.9, 2048); $response = $geminiPhp->sendRequest(); echo $response; } catch (Exception $e) { echo "Erro: " . $e->getMessage(); } ?>