Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
492 changes: 258 additions & 234 deletions CHANGELOG.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

declare(strict_types=1);
//Credits to https://github.com/bootstrapguru/dexor
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
return new class extends Migration
{
public function up(): void
{
Schema::create('agent_memories', function (Blueprint $table) {
Schema::create('synapse_agent_memories', function (Blueprint $table) {

$table->uuid('id');
$table->uuid('id')->primary();
$table->string('type')->nullable();
$table->timestamps();
});
}

public function down(): void
{
Schema::dropIfExists('agents');
Schema::dropIfExists('synapse_agent_memories');
}
};
14 changes: 7 additions & 7 deletions database/migrations/2024_07_06_132319_create_messages_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

declare(strict_types=1);
//Credits to https://github.com/bootstrapguru/dexor
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
return new class extends Migration
{
public function up(): void
{
Schema::create('messages', function (Blueprint $table) {
Schema::create('synapse_messages', function (Blueprint $table) {
$table->id();
$table->foreignUuid('agent_memory_id')->constrained('agent_memories')->onDelete('cascade');
$table->foreignUuid('agent_memory_id')->constrained('synapse_agent_memories')->onDelete('cascade');
$table->string('role');
$table->text('content')->nullable();
$table->string('tool_name')->nullable();
Expand All @@ -26,6 +26,6 @@ public function up(): void

public function down(): void
{
Schema::dropIfExists('messages');
Schema::dropIfExists('synapse_messages');
}
};
9 changes: 1 addition & 8 deletions docs/tools/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ Tools allow your agent to interact with your application or external APIs. Essen
Tools are inherently part of all agents, but they are not invoked unless the `resolveTools` method returns an array of tools that the agent can use. Below is an example where the `SerperTool` is added to an agent, allowing it to perform Google searches.

```php
use UseTheFork\Synapse\Agent;
use UseTheFork\Synapse\Contracts\Agent\HasOutputSchema;
use UseTheFork\Synapse\Contracts\Integration;
use UseTheFork\Synapse\Contracts\Tool;
use UseTheFork\Synapse\Integrations\OpenAIIntegration;
use UseTheFork\Synapse\Tools\SerperTool;
use UseTheFork\Synapse\Traits\Agent\ValidatesOutputSchema;
use UseTheFork\Synapse\ValueObject\SchemaRule;
use UseTheFork\Synapse\Agent;use UseTheFork\Synapse\Contracts\Agent\HasOutputSchema;use UseTheFork\Synapse\Contracts\Integration;use UseTheFork\Synapse\Integrations\OpenAIIntegration;use UseTheFork\Synapse\Tools\Search\SerperTool;use UseTheFork\Synapse\Traits\Agent\ValidatesOutputSchema;use UseTheFork\Synapse\ValueObject\SchemaRule;

class SerperAgent extends Agent implements HasOutputSchema
{
Expand Down
7 changes: 3 additions & 4 deletions docs/tools/packaged-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SERPER_API_KEY=
Then, include the `SerperTool` in your agent:

```php
use UseTheFork\Synapse\Tools\SerperTool;
use UseTheFork\Synapse\Tools\Search\SerperTool;

protected function resolveTools(): array
{
Expand All @@ -38,8 +38,7 @@ SERPAPI_API_KEY=
Then, include either the `SerpAPIGoogleSearchTool` or the `SerpAPIGoogleNewsTool` in your agent:

```php
use UseTheFork\Synapse\Tools\SerpAPIGoogleNewsTool;
use UseTheFork\Synapse\Tools\SerpAPIGoogleSearchTool;
use UseTheFork\Synapse\Tools\Search\SerpAPIGoogleNewsTool;use UseTheFork\Synapse\Tools\Search\SerpAPIGoogleSearchTool;

protected function resolveTools(): array
{
Expand All @@ -64,7 +63,7 @@ FIRECRAWL_API_KEY=
Then, include the `FirecrawlTool` in your agent:

```php
use UseTheFork\Synapse\Tools\FirecrawlTool;
use UseTheFork\Synapse\Tools\Scrape\FirecrawlTool;

protected function resolveTools(): array
{
Expand Down
98 changes: 42 additions & 56 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
};

services = {
aider.enable = true;
};

integrations = {
Expand Down
13 changes: 9 additions & 4 deletions resources/views/Prompts/Rat/GetQueryPrompt.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<message type="user">
## User input: {{ $question }}
### Question: {{ $question }}

## Response
### Content
{{ $answer }}

## Instruction
Summarize the content with a focus on the last sentences to create a concise search query for Bing. Use search syntax to make the query specific and relevant for content verification.
### Instruction
I want to verify the content correctness of the given question, especially the last sentences.
Please summarize the content with the corresponding question.
This summarization will be used as a query to search with Bing search engine.
The query should be short but need to be specific to promise Bing can find related knowledge or pages.
You can also use search syntax to make the query short and clear enough for the search engine to find relevant language data.
Try to make the query as relevant as possible to the last few sentences in the content.

@include('synapse::Parts.OutputSchema')
</message>
16 changes: 16 additions & 0 deletions resources/views/Prompts/Rat/ReflectAnswerPrompt.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<message type="user">
### Question: {{ $question }}

### Answer:
{{ $answer }}

### Instruction
Give a title for the answer of the question.
And add a subtitle to each paragraph in the answer and output the final answer using markdown format.
This will make the answer to this question look more structured for better understanding.

**IMPORTANT**
Try to keep the structure (multiple paragraphs with its subtitles) in the response and make it more structural for understanding.

@include('synapse::Parts.OutputSchema')
</message>
25 changes: 25 additions & 0 deletions resources/views/Prompts/Rat/ReviseAnswerPrompt.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<message type="user">
### Existing Text in Wiki Web:
```
{{ $content }}
```

### Question: {{ $question }}

### Answer:
{{ $answer }}

### Instruction
I want to revise the answer according to retrieved related text of the question in WIKI pages.
You need to check whether the answer is correct.
If you find some errors in the answer, revise the answer to make it better.
If you find some necessary details are ignored, add it to make the answer more plausible according to the related text.
If you find the answer is right and do not need to add more details, just output the original answer directly.

**IMPORTANT**
Try to keep the structure (multiple paragraphs with its subtitles) in the revised answer and make it more structural for understanding.
Add more details from retrieved text to the answer.
Split the paragraphs with \n\n characters.

@include('synapse::Parts.OutputSchema')
</message>
Loading