🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.7 KiB
PHP
Executable File
46 lines
1.7 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
/**
|
|
|
|
title=测试 aiModel::complete();
|
|
timeout=0
|
|
cid=0
|
|
|
|
- 执行aiTest模块的completeTest方法,参数是1, 'Hello, world!', 512 @0
|
|
- 执行aiTest模块的completeTest方法,参数是2, 'Complete this text:', 256, array @0
|
|
- 执行aiTest模块的completeTest方法,参数是1, '', 512 @0
|
|
- 执行aiTest模块的completeTest方法,参数是999, 'Hello, world!', 512 @0
|
|
- 执行aiTest模块的completeTest方法,参数是1, 'Hello, world!', 10000 @0
|
|
|
|
*/
|
|
|
|
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
|
include dirname(__FILE__, 2) . '/lib/ai.unittest.class.php';
|
|
|
|
$ai_model = zenData('ai_model');
|
|
$ai_model->id->range('1-5');
|
|
$ai_model->type->range('openai{2},ernie{2},claude{1}');
|
|
$ai_model->vendor->range('openai{2},baidu{2},anthropic{1}');
|
|
$ai_model->credentials->range('{"api_key":"test_key_1"},{"api_key":"test_key_2"},{"api_key":"test_key_3"},{"api_key":"test_key_4"},{"api_key":"test_key_5"}');
|
|
$ai_model->name->range('GPT-3.5,GPT-4,ERNIE-Bot,ERNIE-Turbo,Claude-3');
|
|
$ai_model->createdBy->range('admin{5}');
|
|
$ai_model->createdDate->range('`2024-01-01`{5}');
|
|
$ai_model->enabled->range('1{5}');
|
|
$ai_model->deleted->range('0{5}');
|
|
$ai_model->gen(5);
|
|
|
|
su('admin');
|
|
|
|
$aiTest = new aiTest();
|
|
|
|
// 设置模型配置以避免配置错误
|
|
$config = new stdclass();
|
|
$config->type = 'openai-gpt35';
|
|
$aiTest->setModelConfigTest($config);
|
|
|
|
r($aiTest->completeTest(1, 'Hello, world!', 512)) && p() && e('0');
|
|
r($aiTest->completeTest(2, 'Complete this text:', 256, array('temperature' => 0.7))) && p() && e('0');
|
|
r($aiTest->completeTest(1, '', 512)) && p() && e('0');
|
|
r($aiTest->completeTest(999, 'Hello, world!', 512)) && p() && e('0');
|
|
r($aiTest->completeTest(1, 'Hello, world!', 10000)) && p() && e('0'); |