Skip to content

Commit

Permalink
Merge pull request #1 from use-the-fork/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
use-the-fork authored Oct 16, 2024
2 parents 4d9a2fd + 21d5a41 commit 2881237
Show file tree
Hide file tree
Showing 49 changed files with 1,278 additions and 281 deletions.
Empty file added CHANGELOG.md
Empty file.
3 changes: 3 additions & 0 deletions config/synapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

declare(strict_types=1);

use UseTheFork\Synapse\Integrations\OpenAIIntegration;

return [
'integrations' => [
'default' => OpenAIIntegration::class,
'openai' => [
'key' => env('OPENAI_API_KEY'),
'chat_model' => env('OPENAI_API_CHAT_MODEL', 'gpt-4-turbo'),
Expand Down
35 changes: 24 additions & 11 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ export default defineConfig({
sidebar: [
{
text: 'Introduction',
items: [{ text: 'Getting Started', link: '/' }],
},
{
text: 'Agents',
items: [
{ text: 'Introduction', link: '/agents/' },
{ text: 'Lifecycle', link: '/agents/agent-lifecycle' },
{ text: 'Integrations', link: '/agents/integrations' },
{ text: 'Prompts', link: '/agents/prompts' },
{ text: 'Traits', link: '/agents/agent-traits' },
{ text: 'Getting Started', link: '/' },
{
text: 'Artisan Agent Tutorial',
link: '/tutorials/artisan-agent.md',
},
],
},
{
Expand All @@ -51,8 +47,22 @@ export default defineConfig({
text: 'Chat Rephrase',
link: '/prebuilt-agents/chat-rephrase-agent',
},
{
text: 'SQL Tool',
link: '/prebuilt-agents/sql-tool-agent',
},
],
},
{
text: 'Agents',
items: [
{ text: 'Introduction', link: '/agents/' },
{ text: 'Lifecycle', link: '/agents/agent-lifecycle' },
{ text: 'Integrations', link: '/agents/integrations' },
{ text: 'Prompts', link: '/agents/prompts' },
{ text: 'Traits', link: '/agents/agent-traits' },
],
},
{
text: 'Prompts',
items: [
Expand All @@ -75,7 +85,10 @@ export default defineConfig({
{ text: 'Introduction', link: '/memory/' },
{ text: 'Collection Memory', link: '/memory/collection' },
{ text: 'Database Memory', link: '/memory/database' },
{ text: 'Conversation Summary Memory', link: '/memory/conversation-summary' },
{
text: 'Conversation Summary Memory',
link: '/memory/conversation-summary',
},
],
},
{
Expand All @@ -90,7 +103,7 @@ export default defineConfig({
{ text: 'Logs', link: '/traits/log-trait' },
{ text: 'Hooks', link: '/traits/hook-trait' },
],
}
},
],

socialLinks: [
Expand Down
10 changes: 8 additions & 2 deletions docs/agents/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ It's recommended to define a standard location for your Agents. In Laravel, a go

Create a new class that extends the abstract `Agent` class.

You will need to define a few methods and variables:
You will need to define a few methods, interfaces, and variables:

- **`$promptView`**: The Blade view that the agent uses as its prompt template. See the [Prompts section](/agents/prompts) for more details.
- **`HasIntegration`**: This interface tells the agent to look for the `resolveIntegration` method when booting. See the [Integrations section](/agents/integrations) for more details.
- **`resolveIntegration`**: The API connection the agent should use when invoked. See the [Integrations section](/agents/integrations) for more details.

> [!TIP]
> If you set a default integration in your config file, you do not need to add the `resolveIntegration` method or the `HasIntegration` interface to your agent.
```php
<?php

use UseTheFork\Synapse\Agent;
use UseTheFork\Synapse\Contracts\Integration;
use UseTheFork\Synapse\Integrations\OpenAIIntegration;
use UseTheFork\Synapse\Contracts\Agent\HasIntegration;

class SimpleAgent extends Agent
class SimpleAgent extends Agent implements HasIntegration
{
protected string $promptView = 'synapse::Prompts.SimplePrompt';

Expand Down
20 changes: 19 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## AI Agents for All!

Synapse allows you to easily create and manage AI agents in your Laravel application. Inspired by Langchain and Laravel Saloon, this package simplifies AI integration and enables scalability.
Synapse allows you to easily create and manage AI agents in your Laravel application. Inspired by Langchain and Saloon, this package simplifies AI integration and enables scalability.

## Installation

Expand Down Expand Up @@ -65,4 +65,22 @@ return [
];
```

### 3. If you are not using OpenAI as your default integration:
Open the `config/synapse.php` file and modify the default integration to the one you prefer:

```php
'integrations' => [
'default' => UseTheFork\Synapse\Integrations\OpenAIIntegration::class, // [!code highlight]
'openai' => [
'key' => env('OPENAI_API_KEY'),
'chat_model' => env('OPENAI_API_CHAT_MODEL', 'gpt-4-turbo'),
'embedding_model' => env('OPENAI_API_EMBEDDING_MODEL', 'text-embedding-ada-002'),
],
'claude' => [
'key' => env('ANTHROPIC_API_KEY'),
'chat_model' => env('ANTHROPIC_API_CHAT_MODEL', 'claude-3-5-sonnet-20240620'),
],
],
```

You're now ready to use Synapse.
2 changes: 1 addition & 1 deletion docs/prebuilt-agents/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prebuilt Agents

Synapse includes several prebuilt agents that you can use right out of the box. If you're using OpenAI as your integration, simply include the agent in your code, and you're all set.
Synapse includes several prebuilt agents that you can use right out of the box. If you have set a `default` integration in your `synapse` config, simply include the agent in your code, and you're all set.

```php
<?php
Expand Down
31 changes: 31 additions & 0 deletions docs/prebuilt-agents/sql-tool-agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SQL Tool Agent

The `SQLToolAgent` has access to the `ListSQLDatabaseTool`, `InfoSQLDatabaseTool`, and `QuerySQLDataBaseTool` tools. Given user input, it will use these tools to attempt to answer the provided question based on the database.

## Usage

To use this agent, include it in your code as shown below. The `handle` method requires one input:
- **`input`**: The question you would like answered based on the database.

```php
<?php

use UseTheFork\Synapse\Agents\SQLToolAgent;

$agent = new SQLToolAgent;
$agentResponse = $agent->handle(['input' => 'How many organizations are operating and what is the average number of funding rounds for them?']);
```

### Example Output

The above code will produce the following output:

```php
array:3 [
"role" => "assistant"
"finish_reason" => "stop"
"content" => array:1 [
"answer" => "There are 100 organizations currently operating, and the average number of funding rounds for them is 5."
]
]
```
Loading

0 comments on commit 2881237

Please sign in to comment.