mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 18:44:05 +02:00
# Description of Changes Redesign AI engine so that it autogenerates the `tool_models.py` file from the OpenAPI spec so the Python has access to the Java API parameters and the full list of Java tools that it can run. CI ensures that whenever someone modifies a tool endpoint that the AI enigne tool models get updated as well (the dev gets told to run `task engine:tool-models`). There's loads of advantages to having the Java be the one that actually executes the tools, rather than the frontend as it was previously set up to theoretically use: - The AI gets much better descriptions of the params from the API docs - It'll be usable headless in the future so a Java daemon could run to execute ops on files in a folder without the need for the UI to run - The Java already has all the logic it needs to execute the tools - We don't need to parse the TypeScript to find the API (which is hard because the TS wasn't designed to be computer-read to extract the API) I've also hooked up the prototype frontend to ensure it's working properly, and have built it in a way that all the tool names can be translated properly, which was always an issue with previous prototypes of this. --------- Co-authored-by: Anthony Stirling <[email protected]> Co-authored-by: EthanHealy01 <[email protected]>
105 lines
3.3 KiB
YAML
105 lines
3.3 KiB
YAML
name: AI Engine CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
jobs:
|
|
engine:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
with:
|
|
enable-cache: true
|
|
|
|
- name: Set up JDK 25
|
|
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
|
with:
|
|
java-version: "25"
|
|
distribution: "temurin"
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # v5.0.1
|
|
with:
|
|
gradle-version: 9.3.1
|
|
|
|
- name: Install Task
|
|
uses: go-task/setup-task@3be4020d41929789a01026e0e427a4321ce0ad44 # v2.0.0
|
|
|
|
- name: Regenerate tool models
|
|
run: task engine:tool-models
|
|
|
|
- name: Verify tool models are up to date
|
|
run: |
|
|
if ! git diff --exit-code engine/src/stirling/models/tool_models.py; then
|
|
echo "tool_models.py is out of date."
|
|
echo "Run 'task engine:tool-models' locally and commit the updated file."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Run fixers
|
|
run: task engine:fix
|
|
|
|
- name: Verify fixes are committed
|
|
id: fixer_changes
|
|
run: |
|
|
if ! git diff --quiet; then
|
|
git --no-pager diff --stat
|
|
echo "::error::There are issues with your Python code that will need to be fixed before they can be merged in. Run 'task engine:fix' to auto-fix what can be fixed automatically, then run 'task engine:check' to see what still needs fixing manually."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Comment on fixer failures
|
|
if: steps.fixer_changes.outcome == 'failure' && github.event_name == 'pull_request'
|
|
continue-on-error: true
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const marker = '<!-- engine-check -->';
|
|
const body = [
|
|
marker,
|
|
'### Engine Check Failed',
|
|
'',
|
|
'There are issues with your Python code that will need to be fixed before they can be merged in.',
|
|
'',
|
|
'Run `task engine:fix` to auto-fix what can be fixed automatically, then run `task engine:check` to see what still needs fixing manually.',
|
|
].join('\n');
|
|
const { data: comments } = await github.rest.issues.listComments({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
});
|
|
const existing = comments.find(c => c.body.includes(marker));
|
|
if (existing) {
|
|
await github.rest.issues.updateComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: existing.id,
|
|
body,
|
|
});
|
|
} else {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body,
|
|
});
|
|
}
|
|
|
|
- name: Run linting
|
|
run: task engine:lint
|
|
|
|
- name: Run type checking
|
|
run: task engine:typecheck
|
|
|
|
- name: Run tests
|
|
run: task engine:test
|