Skip to content

Commit 9791156

Browse files
committed
rename operation intent to architect
1 parent e396aea commit 9791156

File tree

4 files changed

+90
-17
lines changed

4 files changed

+90
-17
lines changed

src/Service/Agent/Intent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ enum Intent: string
3131
{
3232
case ACTION = 'action';
3333
case SCHEMA = 'schema';
34-
case OPERATION = 'operation';
34+
case ARCHITECT = 'architect';
3535

3636
public function getInt(): int
3737
{
3838
return match ($this) {
3939
self::ACTION => 1,
4040
self::SCHEMA => 2,
41-
self::OPERATION => 3,
41+
self::ARCHITECT => 3,
4242
};
4343
}
4444
}

src/Service/Agent/Intent/ActionIntent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function getMessage(): string
8181
$hint.= '* Fusio.Adapter.Sql.Connection.SqlAdvanced = Connection from the Doctrine DBAL library' . "\n";
8282
$hint.= '* Fusio.Adapter.Stripe.Connection.Stripe = StripeClient from the Stripe PHP SDK' . "\n";
8383
$hint.= "\n";
84+
$hint.= 'If the business logic needs a database and there is no specific connection mentioned then use as default the "System" connection.' . "\n";
8485
$hint.= 'If the business logic needs to work with a database table you can get all available tables for a specific connection through the "backend_database_getTables" tool where you need to provide a connection id.' . "\n";
8586
$hint.= 'If you need to get a concrete table schema you can use the "backend_database_getTable" tool where you need to provide the connection id and table name.' . "\n";
8687
$hint.= 'To add logging you can use the "$logger" argument which is a PSR-3 compatible logging interface.' . "\n";

src/Service/Agent/Intent/OperationIntent.php renamed to src/Service/Agent/Intent/ArchitectIntent.php

Lines changed: 85 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
use Symfony\AI\Platform\Result\ResultInterface;
2727

2828
/**
29-
* OperationIntent
29+
* ArchitectIntent
3030
*
3131
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
3232
* @license http://www.apache.org/licenses/LICENSE-2.0
3333
* @link https://www.fusio-project.org
3434
*/
35-
readonly class OperationIntent implements IntentInterface
35+
readonly class ArchitectIntent implements IntentInterface
3636
{
3737
public function __construct(private JsonResultSerializer $resultSerializer)
3838
{
@@ -41,10 +41,11 @@ public function __construct(private JsonResultSerializer $resultSerializer)
4141
public function getMessage(): string
4242
{
4343
$hint = 'The user has the intent to design new API endpoints to solve the provided task.' . "\n";
44-
$hint.= 'Therefor you need generate a list of operations following the provided JSON schema.' . "\n";
44+
$hint.= 'Therefor you need generate a list of operations and optional tables following the provided JSON schema.' . "\n";
4545
$hint.= 'You should think like an REST API expert which has deep knowledge in describing API endpoints.' . "\n";
4646
$hint.= 'The action of the operation should be described as text which is used later on by a different agent to generate the actual code.' . "\n";
4747
$hint.= 'The incoming/outgoing schemas of the operation should be described as text which is used later on by a different agent to generate the actual schema.' . "\n";
48+
$hint.= 'If the logic needs to persist data you also need to generate a fitting database table schemas.' . "\n";
4849
$hint.= "\n";
4950

5051
return $hint;
@@ -53,12 +54,6 @@ public function getMessage(): string
5354
public function getTools(): array
5455
{
5556
return [
56-
'backend_operation_getAll',
57-
'backend_operation_get',
58-
'backend_action_getAll',
59-
'backend_action_get',
60-
'backend_schema_getAll',
61-
'backend_schema_get',
6257
];
6358
}
6459

@@ -124,7 +119,7 @@ public function getResponseSchema(): ?array
124119
],
125120
'httpCode' => [
126121
'description' => 'The HTTP success status code, normally this is 200 but for create operations it should be 201',
127-
'type' => 'string',
122+
'type' => 'integer',
128123
],
129124
'parameters' => [
130125
'description' => 'Describes all query parameters for this operation',
@@ -146,10 +141,87 @@ public function getResponseSchema(): ?array
146141
'required' => ['name', 'active', 'public', 'stability', 'description', 'httpMethod', 'httpPath', 'httpCode', 'outgoing', 'action'],
147142
'additionalProperties' => false,
148143
],
144+
'Table' => [
145+
'description' => 'Represents a table on a relational database',
146+
'type' => 'object',
147+
'properties' => [
148+
'name' => [
149+
'description' => 'Name of the table',
150+
'type' => 'string'
151+
],
152+
'columns' => [
153+
'description' => 'List of table columns',
154+
'type' => 'object',
155+
'additionalProperties' => [
156+
'$ref' => '#/$defs/Column',
157+
],
158+
],
159+
'primaryKey' => [
160+
'description' => 'The name of the primary key column',
161+
'type' => 'string'
162+
],
163+
],
164+
],
165+
'Column' => [
166+
'description' => 'Represents a column on a table',
167+
'type' => 'object',
168+
'properties' => [
169+
'name' => [
170+
'description' => 'Name of the column',
171+
'type' => 'string'
172+
],
173+
'type' => [
174+
'description' => 'Type of the column',
175+
'type' => 'string',
176+
'enum' => ['smallint', 'integer', 'bigint', 'string', 'text', 'guid', 'binary', 'blob', 'boolean', 'date', 'datetime', 'time', 'simple_array', 'json'],
177+
],
178+
'length' => [
179+
'description' => 'Optional the max column length for string types',
180+
'type' => 'integer'
181+
],
182+
'notNull' => [
183+
'description' => 'Indicates whether null is not allowed',
184+
'type' => 'boolean'
185+
],
186+
'autoIncrement' => [
187+
'description' => 'Indicates whether the column is autoincrement, should be only used at the primary-key column',
188+
'type' => 'boolean'
189+
],
190+
'precision' => [
191+
'description' => 'Optional for integer types a precision',
192+
'type' => 'integer'
193+
],
194+
'scale' => [
195+
'description' => 'Optional for integer types a scale',
196+
'type' => 'integer'
197+
],
198+
'default' => [
199+
'description' => 'Optional the default value for the column',
200+
'type' => 'string'
201+
],
202+
'comment' => [
203+
'description' => 'Optional a comment for the column',
204+
'type' => 'string'
205+
],
206+
],
207+
],
149208
],
150-
'type' => 'array',
151-
'items' => [
152-
'$ref' => '#/$defs/Operation',
209+
'type' => 'object',
210+
'properties' => [
211+
'operations' => [
212+
'description' => 'List of operations',
213+
'type' => 'array',
214+
'items' => [
215+
'$ref' => '#/$defs/Operation',
216+
],
217+
],
218+
'tables' => [
219+
'description' => 'List of tables',
220+
'type' => 'array',
221+
'items' => [
222+
'$ref' => '#/$defs/Table',
223+
],
224+
],
153225
],
154226
];
155227
}

src/Service/Agent/IntentFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public function __construct(
3333
private Intent\ActionIntent $actionIntent,
3434
private Intent\SchemaIntent $schemaIntent,
35-
private Intent\OperationIntent $operationIntent,
35+
private Intent\ArchitectIntent $architectIntent,
3636
private Intent\GeneralIntent $generalIntent
3737
) {
3838
}
@@ -42,7 +42,7 @@ public function factory(?Intent $intent): IntentInterface
4242
return match($intent) {
4343
Intent::ACTION => $this->actionIntent,
4444
Intent::SCHEMA => $this->schemaIntent,
45-
Intent::OPERATION => $this->operationIntent,
45+
Intent::ARCHITECT => $this->architectIntent,
4646
default => $this->generalIntent,
4747
};
4848
}

0 commit comments

Comments
 (0)