Skip to content

Commit 8d49728

Browse files
committed
feat: add tool support via DB
1 parent 400d6f2 commit 8d49728

27 files changed

+271
-1011
lines changed

_build/gpm.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,8 @@ systemSettings:
162162
build:
163163
scriptsAfter:
164164
- lit.gpm.php
165+
- seed.gpm.php
165166

166167
database:
167168
tables:
168-
- "modAI\\Model\\Conversation"
169-
- "modAI\\Model\\Message"
170169
- "modAI\\Model\\Tool"
171-
- "modAI\\Model\\ContextProvider"
172-
- "modAI\\Model\\Agent"
173-
- "modAI\\Model\\AgentContextProvider"
174-
- "modAI\\Model\\AgentTool"

_build/scripts/seed.gpm.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
return new class() {
4+
/**
5+
* @var \MODX\Revolution\modX
6+
*/
7+
private $modx;
8+
9+
/**
10+
* @var int
11+
*/
12+
private $action;
13+
14+
/**
15+
* @param \MODX\Revolution\modX $modx
16+
* @param int $action
17+
* @return bool
18+
*/
19+
public function __invoke(&$modx, $action)
20+
{
21+
$this->modx =& $modx;
22+
$this->action = $action;
23+
24+
if ($this->action === \xPDO\Transport\xPDOTransport::ACTION_UNINSTALL) {
25+
return true;
26+
}
27+
28+
$tools = [
29+
[
30+
'name' => \modAI\Tools\GetWeather::getSuggestedName(),
31+
'class' => \modAI\Tools\GetWeather::class,
32+
'config' => [],
33+
'enabled' => true,
34+
]
35+
];
36+
37+
foreach ($tools as $tool) {
38+
$exists = $this->modx->getCount(\modAI\Model\Tool::class, ['name' => $tool['name']]);
39+
if ($exists > 0) {
40+
continue;
41+
}
42+
43+
$toolObjects = $this->modx->newObject(\modAI\Model\Tool::class, $tool);
44+
$toolObjects->save();
45+
}
46+
47+
return true;
48+
}
49+
};

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"ext-curl": "*",
1616
"ext-simplexml": "*",
1717
"squizlabs/php_codesniffer": "3.*",
18-
"phpcompatibility/php-compatibility": "^9.3",
19-
"xpdo/xpdo": "^v3.1"
18+
"phpcompatibility/php-compatibility": "^9.3"
2019
},
2120
"suggest": {
2221
"ext-pcntl": "*"

0 commit comments

Comments
 (0)