1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- use HaoZiTeam\ChatGPT\V1;
- $accessToken = getenv('OPENAI_ACCESS_TOKEN');
- $chatGPT = new V1();
- $chatGPT->addAccount($accessToken, 0, 'gpt-4');
- $test = $chatGPT->ask('Hello');
- foreach ($test as $answer) {
- $conversationId = $answer['conversation_id'];
- $parentId = $answer['id'];
- }
- it('should get a new conversation', function () use ($chatGPT) {
- $return = $chatGPT->ask('Hello');
- foreach ($return as $answer) {
- $this->assertArrayHasKey('answer', $answer);
- }
- })->group('working');
- it('should get a conversations array', function () use ($chatGPT) {
- $return = $chatGPT->getConversations();
- $this->assertIsArray($return);
- })->group('working');
- it('should get an array of a conversation', function () use ($chatGPT, $conversationId, $parentId) {
- $return = $chatGPT->getConversationMessages($conversationId);
- $this->assertIsArray($return);
- })->group('working');
- it('should auto generate conversation title', function () use ($chatGPT, $conversationId, $parentId) {
- $return = $chatGPT->generateConversationTitle($conversationId, $parentId);
- $this->assertTrue($return);
- })->group('working');
- it('should setting conversation title', function () use ($chatGPT, $conversationId, $parentId) {
- $return = $chatGPT->updateConversationTitle($conversationId, 'test');
- $this->assertTrue($return);
- })->group('working');
- it('should delete conversation', function () use ($chatGPT, $conversationId, $parentId) {
- $return = $chatGPT->deleteConversation($conversationId);
- $this->assertTrue($return);
- })->group('working');
- it('should delete conversations', function () use ($chatGPT) {
- $return = $chatGPT->clearConversations();
- $this->assertTrue($return);
- })->group('working');
- it('should return plugins list', function () use ($chatGPT) {
- $return = $chatGPT->getPlugins();
- $this->assertIsArray($return);
- })->group('working');
- it('should change history and training status', function () use ($chatGPT) {
- $return = $chatGPT->setChatHistoryAndTraining(true);
- $this->assertTrue($return);
- })->group('working');
|