Skip to content

Commit 997974d

Browse files
authored
Merge pull request #20 from MaestroError/issue-19-ide-helper
Fix for ide helper issue +note in docs
2 parents bd5858d + 7bb8272 commit 997974d

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Stay tuned! We're constantly working on making LarAgent the most versatile AI ag
170170

171171
## Table of Contents
172172

173+
#### 📚 We're working hard on the official documentation website. Thanks for your patience and support!
174+
173175
- [📖 Introduction](#introduction)
174176
- [🚀 Getting Started](#getting-started)
175177
- [Requirements](#requirements)
@@ -233,7 +235,7 @@ return [
233235
'providers' => [
234236

235237
'default' => [
236-
'name' => 'openai',
238+
'label' => 'openai',
237239
'api_key' => env('OPENAI_API_KEY'),
238240
'default_context_window' => 50000,
239241
'default_max_completion_tokens' => 100,
@@ -252,7 +254,7 @@ You can configure the package by editing the `config/laragent.php` file. Here is
252254
// Example custom provider with all possible configurations
253255
'custom_provider' => [
254256
// Just name for reference, changes nothing
255-
'name' => 'mini',
257+
'label' => 'mini',
256258
'model' => 'gpt-3.5-turbo',
257259
'api_key' => env('CUSTOM_API_KEY'),
258260
'api_url' => env('CUSTOM_API_URL'),
@@ -904,7 +906,7 @@ You can use the drivers by setting them in the configuration file:
904906
```php
905907
'providers' => [
906908
'default' => [
907-
'name' => 'openai',
909+
'label' => 'openai',
908910
'api_key' => env('OPENAI_API_KEY'),
909911
// ...
910912
'driver' => \LarAgent\Drivers\OpenAi\OpenAiDriver::class,
@@ -934,7 +936,7 @@ Driver that can be used with any OpenAI-compatible provider. For example configu
934936
'providers' => [
935937

936938
'ollama' => [
937-
'name' => 'ollama-local',
939+
'label' => 'ollama-local',
938940
'driver' => \LarAgent\Drivers\OpenAi\OpenAiCompatible::class,
939941
'api_key' => 'ollama',
940942
'api_url' => "http://localhost:11434/v1",
@@ -951,7 +953,7 @@ Or any other LLM API which uses the same standards as OpenAI, such as **OpenRout
951953
'providers' => [
952954

953955
'openrouter' => [
954-
'name' => 'some-label', // Name is only for internal use like a label, you can use any name
956+
'label' => 'some-label', // Name is only for internal use like a label, you can use any name
955957
'driver' => \LarAgent\Drivers\OpenAi\OpenAiCompatible::class,
956958
'api_key' => env('OPENROUTER_API_KEY'),
957959
'api_url' => "https://api.openrouter.ai/api/v1",

config/laragent.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22

33
// config for Maestroerror/LarAgent
44
return [
5-
'default_driver' => \LarAgent\Drivers\OpenAi\OpenAiDriver::class,
5+
6+
/**
7+
* Default driver to use, binded in service provider
8+
* with \LarAgent\Core\Contracts\LlmDriver interface
9+
*/
10+
'default_driver' => \LarAgent\Drivers\OpenAi\OpenAiCompatible::class,
11+
12+
/**
13+
* Default chat history to use, binded in service provider
14+
* with \LarAgent\Core\Contracts\ChatHistory interface
15+
*/
616
'default_chat_history' => \LarAgent\History\InMemoryChatHistory::class,
717

18+
/**
19+
* Always keep provider named 'default'
20+
* You can add more providers in array
21+
* by copying the 'default' provider
22+
* and changing the name and values
23+
*/
824
'providers' => [
9-
1025
'default' => [
11-
'name' => 'openai',
26+
'label' => 'openai',
1227
'api_key' => env('OPENAI_API_KEY'),
1328
'default_context_window' => 50000,
1429
'default_max_completion_tokens' => 10000,

src/LarAgentServiceProvider.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace LarAgent;
44

5+
use Illuminate\Support\Str;
56
use LarAgent\Commands\AgentChatClearCommand;
67
use LarAgent\Commands\AgentChatCommand;
78
use LarAgent\Commands\AgentChatRemoveCommand;
89
use LarAgent\Commands\MakeAgentCommand;
10+
use LarAgent\Core\Contracts\ChatHistory;
11+
use LarAgent\Core\Contracts\LlmDriver;
912
use Spatie\LaravelPackageTools\Package;
1013
use Spatie\LaravelPackageTools\PackageServiceProvider;
1114

@@ -27,5 +30,25 @@ public function configurePackage(Package $package): void
2730
AgentChatClearCommand::class,
2831
AgentChatRemoveCommand::class,
2932
]);
33+
34+
}
35+
36+
public function register()
37+
{
38+
parent::register();
39+
40+
$this->app->singleton(LlmDriver::class, function ($app) {
41+
$config = $app['config']->get('laragent.providers.default');
42+
$defaultDriver = $app['config']->get('laragent.default_driver');
43+
44+
return new $defaultDriver($config);
45+
});
46+
47+
$this->app->bind(ChatHistory::class, function ($app) {
48+
$name = Str::random(10);
49+
$defaultChatHistory = $app['config']->get('laragent.default_chat_history');
50+
51+
return new $defaultChatHistory($name, []);
52+
});
3053
}
3154
}

test-agent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function config(string $key): mixed
1212
'laragent.default_driver' => LarAgent\Drivers\OpenAi\OpenAiDriver::class,
1313
'laragent.default_chat_history' => LarAgent\History\InMemoryChatHistory::class,
1414
'laragent.providers.default' => [
15-
'name' => 'openai',
15+
'label' => 'openai',
1616
'model' => 'gpt-4o',
1717
'api_key' => $yourApiKey,
1818
'default_context_window' => 50000,

0 commit comments

Comments
 (0)