Skip to content

Commit 8c76d69

Browse files
committed
generate code instead of json
1 parent 5ea5929 commit 8c76d69

File tree

4 files changed

+11
-39
lines changed

4 files changed

+11
-39
lines changed

src/Service/Agent/Intent/ActionIntent.php

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace Fusio\Impl\Service\Agent\Intent;
2222

2323
use Fusio\Impl\Service\Agent\IntentInterface;
24-
use Fusio\Impl\Service\Agent\JsonResultSerializer;
24+
use Fusio\Impl\Service\Agent\Serializer\ActionResultSerializer;
2525
use Fusio\Model\Backend\AgentMessage;
2626
use Symfony\AI\Platform\Result\ResultInterface;
2727

@@ -34,18 +34,14 @@
3434
*/
3535
readonly class ActionIntent implements IntentInterface
3636
{
37-
public function __construct(private JsonResultSerializer $resultSerializer)
37+
public function __construct(private ActionResultSerializer $resultSerializer)
3838
{
3939
}
4040

4141
public function getMessage(): string
4242
{
4343
$hint = 'The user has the intent to develop a new action.' . "\n";
44-
$hint.= 'Therefor you need generate a JSON configuration which is used to create a new action.' . "\n";
45-
$hint.= 'The format of this action is described in the provided JSON schema.' . "\n";
46-
$hint.= "\n";
47-
$hint.= 'Inside the configuration there is a code property where you need to generate PHP code.' . "\n";
48-
$hint.= 'For the PHP code you need to transform the provided business logic of the user message into PHP code.' . "\n";
44+
$hint.= 'Therefor you need to transform the provided business logic of the user message into PHP code.' . "\n";
4945
$hint.= 'The resulting PHP code must be wrapped into the following code:' . "\n";
5046
$hint.= "\n";
5147
$hint.= '<code>' . "\n";
@@ -56,6 +52,9 @@ public function getMessage(): string
5652
use Fusio\Engine;
5753
use Psr\Log\LoggerInterface;
5854
55+
/**
56+
* Action: [NAME]
57+
*/
5958
return function(Worker\ExecuteRequest \$request, Worker\ExecuteContext \$context, Engine\ConnectorInterface \$connector, Engine\Response\FactoryInterface \$response, Engine\DispatcherInterface \$dispatcher, LoggerInterface \$logger) {
6059
6160
// [INSERT_CODE_HERE]
@@ -66,6 +65,7 @@ public function getMessage(): string
6665
$hint.= '</code>' . "\n";
6766
$hint.= "\n";
6867
$hint.= 'Replace the line "// [INSERT_CODE_HERE]" with the code which you have generated.' . "\n";
68+
$hint.= 'Replace the line "[NAME]" with a short and precise name as lower case and separated by hyphens which summarizes the business logic of the user message.' . "\n";
6969
$hint.= "\n";
7070
$hint.= 'If the business logic wants to interact with an external service i.e. a database or remote HTTP endpoint, then you can use the getConnection method at the connector argument to access those external services.' . "\n";
7171
$hint.= 'You can get a list of all available connections through the "backend_connection_getAll" tool.' . "\n";
@@ -120,33 +120,7 @@ public function getTools(): array
120120

121121
public function getResponseSchema(): ?array
122122
{
123-
return [
124-
'type' => 'object',
125-
'properties' => [
126-
'name' => [
127-
'description' => 'A short and precise name as lower case and separated by hyphens which summarizes the business logic of the user message',
128-
'type' => 'string',
129-
],
130-
'class' => [
131-
'description' => 'The action class is always "Fusio.Adapter.Worker.Action.WorkerPHPLocal"',
132-
'type' => 'string',
133-
],
134-
'config' => [
135-
'description' => 'Config properties for this action',
136-
'type' => 'object',
137-
'properties' => [
138-
'code' => [
139-
'description' => 'The generated PHP code',
140-
'type' => 'string',
141-
],
142-
],
143-
'required' => ['code'],
144-
'additionalProperties' => false,
145-
],
146-
],
147-
'required' => ['name', 'class', 'config'],
148-
'additionalProperties' => false,
149-
];
123+
return null;
150124
}
151125

152126
public function transformResult(ResultInterface $result): AgentMessage

src/Service/Agent/Intent/GeneralIntent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace Fusio\Impl\Service\Agent\Intent;
2222

2323
use Fusio\Impl\Service\Agent\IntentInterface;
24-
use Fusio\Impl\Service\Agent\ResultSerializer;
24+
use Fusio\Impl\Service\Agent\Serializer\ResultSerializer;
2525
use Fusio\Model\Backend\AgentMessage;
2626
use Symfony\AI\Platform\Result\ResultInterface;
2727

src/Service/Agent/Intent/SchemaIntent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace Fusio\Impl\Service\Agent\Intent;
2222

2323
use Fusio\Impl\Service\Agent\IntentInterface;
24-
use Fusio\Impl\Service\Agent\JsonResultSerializer;
24+
use Fusio\Impl\Service\Agent\Serializer\JsonResultSerializer;
2525
use Fusio\Model\Backend\AgentMessage;
2626
use Symfony\AI\Platform\Result\ResultInterface;
2727

src/Service/Agent/Sender.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
namespace Fusio\Impl\Service\Agent;
2222

23-
use Fusio\Engine\Inflection\ClassName;
2423
use Fusio\Impl\Table;
2524
use Fusio\Model\Backend\AgentMessage;
2625
use Fusio\Model\Backend\AgentMessageBinary;
@@ -39,7 +38,6 @@
3938
use PSX\Sql\Condition;
4039
use PSX\Sql\OrderBy;
4140
use Symfony\AI\Agent\AgentInterface;
42-
use Symfony\AI\Platform\Message\Content\Document;
4341
use Symfony\AI\Platform\Message\Content\File;
4442
use Symfony\AI\Platform\Message\Message;
4543
use Symfony\AI\Platform\Message\MessageBag;
@@ -64,7 +62,7 @@
6462

6563
public function __construct(
6664
private IntentFactory $intentFactory,
67-
private MessageSerializer $messageSerializer,
65+
private Serializer\MessageSerializer $messageSerializer,
6866
private Table\Agent $agentTable,
6967
SchemaManager $schemaManager,
7068
) {

0 commit comments

Comments
 (0)