|
|
@@ -11,27 +11,22 @@ class AIGatewayService{
|
|
|
* - api_url:对应功能的服务端地址
|
|
|
*/
|
|
|
protected $config = [
|
|
|
- //图生文
|
|
|
+ //图生文-gemini-2.5-flash-preview
|
|
|
'imgtotxt' => [
|
|
|
'api_key' => 'sk-LVcDfTx5SYK6pWiGpfcAN2KA0LunymnMiYSVfzUKQXrjlkZv',
|
|
|
'api_url' => 'https://chatapi.onechats.top/v1/chat/completions'
|
|
|
],
|
|
|
- //文生文
|
|
|
- // 'txttotxt' => [
|
|
|
- // 'api_key' => 'sk-fxlawqVtbbQbNW0wInR3E4wsLo5JHozDC2XOHzMa711su6ss',
|
|
|
- // 'api_url' => 'https://one.opengptgod.com/v1/chat/completions'
|
|
|
- // ],
|
|
|
- //文生文
|
|
|
- 'txttotxt' => [
|
|
|
+ //文生文-gtp-4
|
|
|
+ 'txttotxtgtp' => [
|
|
|
'api_key' => 'sk-fxlawqVtbbQbNW0wInR3E4wsLo5JHozDC2XOHzMa711su6ss',
|
|
|
'api_url' => 'https://chatapi.onechats.top/v1/chat/completions'
|
|
|
],
|
|
|
-// //文生图
|
|
|
-// 'txttoimg' => [
|
|
|
-// 'api_key' => 'sk-Bhos1lXTRpZiAAmN06624a219a874eCd91Dc068b902a3e73',
|
|
|
-// 'api_url' => 'https://one.opengptgod.com/v1/chat/completions'
|
|
|
-// ]
|
|
|
-// //文生图
|
|
|
+ //文生文-gemini-2.0-flash
|
|
|
+ 'txttotxtgemini' => [
|
|
|
+ 'api_key' => 'sk-cqfCZFiiSIdpDjIHLMBbH6uWfeg7iVsASvlubjrNEmfUXbpX',
|
|
|
+ 'api_url' => 'https://chatapi.onechats.top/v1/chat/completions'
|
|
|
+ ],
|
|
|
+ //文生图-dall-e-3
|
|
|
'txttoimg' => [
|
|
|
'api_key' => 'sk-MB6SR8qNaTjO80U7HJl4ztivX3zQKPgKVka9oyfVSXIkHSYZ',
|
|
|
'api_url' => 'https://chatapi.onechats.top/v1/images/generations'
|
|
|
@@ -84,32 +79,42 @@ class AIGatewayService{
|
|
|
* 文生文
|
|
|
* @param string $prompt 用户输入的文本提示内容
|
|
|
*/
|
|
|
- public function txtGptApi($prompt)
|
|
|
+ public function txtGptApi($prompt,$txttotxt_selectedOption)
|
|
|
{
|
|
|
if (empty($prompt)) {
|
|
|
throw new \Exception("Prompt 不允许为空");
|
|
|
}
|
|
|
- //方式一
|
|
|
- // $data = [
|
|
|
- // 'prompt' => $prompt,
|
|
|
- // 'model' => 'gpt-4',
|
|
|
- // 'session_id' => null,
|
|
|
- // 'context_reset' => true
|
|
|
- // ];
|
|
|
- //方式二
|
|
|
- $data = [
|
|
|
- 'model' => 'gpt-4',
|
|
|
- 'messages' => [
|
|
|
- ['role' => 'user', 'content' => $prompt]
|
|
|
- ],
|
|
|
- 'temperature' => 0.7,
|
|
|
- 'max_tokens' => 1024
|
|
|
- ];
|
|
|
- return $this->callApi(
|
|
|
- $this->config['txttotxt']['api_url'],
|
|
|
- $this->config['txttotxt']['api_key'],
|
|
|
- $data
|
|
|
- );
|
|
|
+ //判断使用模型
|
|
|
+ if ($txttotxt_selectedOption === 'gemini-2.0-flash') {
|
|
|
+ $data = [
|
|
|
+ 'model' => 'gemini-2.0-flash',
|
|
|
+ 'messages' => [
|
|
|
+ ['role' => 'user', 'content' => $prompt]
|
|
|
+ ],
|
|
|
+ 'temperature' => 0.7,
|
|
|
+ 'max_tokens' => 1024
|
|
|
+ ];
|
|
|
+ return $this->callApi(
|
|
|
+ $this->config['txttotxtgemini']['api_url'],
|
|
|
+ $this->config['txttotxtgemini']['api_key'],
|
|
|
+ $data
|
|
|
+ );
|
|
|
+ }else if ($txttotxt_selectedOption === 'gpt-4') {
|
|
|
+ $data = [
|
|
|
+ 'model' => 'gpt-4',
|
|
|
+ 'messages' => [
|
|
|
+ ['role' => 'user', 'content' => $prompt]
|
|
|
+ ],
|
|
|
+ 'temperature' => 0.7,
|
|
|
+ 'max_tokens' => 1024
|
|
|
+ ];
|
|
|
+ return $this->callApi(
|
|
|
+ $this->config['txttotxtgtp']['api_url'],
|
|
|
+ $this->config['txttotxtgtp']['api_key'],
|
|
|
+ $data
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|