Skip to content

Commit

Permalink
this should be a first stab at open ai functions now for claude
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Apr 5, 2024
1 parent 6b148b8 commit dbf4468
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
5 changes: 1 addition & 4 deletions tests/Feature/Http/Controllers/ChatControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Models\Chat;
use App\Models\Collection;
use App\Models\Message;
use App\Models\User;
use Facades\App\LlmDriver\Orchestrate;
use Tests\TestCase;
Expand Down Expand Up @@ -67,9 +66,7 @@ public function test_kick_off_chat_makes_system()
'system_prompt' => 'Foo',
'input' => 'user input',
])->assertOk();
$this->assertDatabaseCount('messages', 4);
$this->assertDatabaseCount('messages', 3);

$this->assertTrue(Message::whereRole('system')->exists());
$this->assertTrue(Message::where('is_chat_ignored', true)->exists());
}
}
4 changes: 2 additions & 2 deletions tests/Feature/MockClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_tools(): void

$this->assertCount(1, $results);

$this->assertEquals('search_and_summarize', $results[0]['name']);
$this->assertEquals('summarize_collection', $results[0]['name']);
}

public function test_tool_with_limit(): void
Expand All @@ -28,7 +28,7 @@ public function test_tool_with_limit(): void

$results = $client->functionPromptChat(['test'], ['search_and_summarize']);

$this->assertCount(0, $results);
$this->assertCount(1, $results);
}

public function test_embeddings(): void
Expand Down
19 changes: 19 additions & 0 deletions tests/fixtures/openai_client_get_functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
"function": {
"name": "search_and_summarize",
"description": "Used to embed users prompt, search database and return summarized results.",
"parameters": {
"type": "object",
"properties": {
"prompt": {
"description": "This is the prompt the user is using to search the database and may or may not assist the results.",
"type": "string",
"enum": [],
"default": ""
}
}
},
"required": []
}
},
{
"type": "function",
"function": {
"name": "summarize_collection",
"description": "This is used when the prompt wants to summarize the entire collection of documents",
"parameters": {
"type": "object",
"properties": {
Expand Down

0 comments on commit dbf4468

Please sign in to comment.