Skip to content

Commit

Permalink
askdb and prose fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Dec 15, 2024
1 parent 93bebc2 commit d39d83e
Show file tree
Hide file tree
Showing 201 changed files with 1,864 additions and 1,859 deletions.
9 changes: 7 additions & 2 deletions app/Services/AskDbService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EchoLabs\Prism\ValueObjects\Messages\UserMessage;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -92,7 +93,7 @@ private function getTablesTool()
$tables = $this->getTablesForTools();
$resp = implode(PHP_EOL, $tables);
if (strlen($resp) > TOOLS_RESPONSE_MAX_CHARACTERS) {
throw new \Exception('[Tools: get_tables_schema] response is too big to send to AI.');
throw new \Exception('[AskDB][Tools: get_tables_schema] response is too big to send to AI.');
}
return $resp;
});
Expand All @@ -106,15 +107,19 @@ private function queryDatabaseTool()
1. Only support sql_mode=only_full_group_by
2. Need to get schema with get_tables_schema first
3. You have read-only access to the database. Don't use DML queries.
4. Database structure follow Laravel recommendations. (is for Laravel based project)
5. Some relationship uses pivot table, Eg: players -> player_user -> users, define which player belongs to which user.
6. Remember, `players` table have little changes in naming convension of columns compared to other player related tables, Eg: It has `uuid` instead of `player_uuid`, `username` instead of `player_username`.
"
)
->withStringParameter('query', 'SQL query to execute')
->using(function (string $query): string {
Log::info("[AskDB: query_database]: $query");
$this->ensureQueryIsSafe($query);
$result = $this->evaluateQueryForTools($query);
$resp = json_encode($result);
if (strlen($resp) > TOOLS_RESPONSE_MAX_CHARACTERS) {
throw new \Exception('[Tools: query_database] response is too big to send to AI.');
throw new \Exception('[AskDB][Tools: query_database] response is too big to send to AI.');
}
return $resp;
});
Expand Down

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

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

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions public/build/default/assets/AfterCreateSteps-23ad8be8.js

This file was deleted.

7 changes: 7 additions & 0 deletions public/build/default/assets/AfterCreateSteps-7b844958.js

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

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

Loading

0 comments on commit d39d83e

Please sign in to comment.