refactor(core): call copilot in tools (#13024)

fix AI-298

#### PR Dependency Tree


* **PR #13024** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Document and code artifact generation tools now use a single prompt
field for user input, enabling more flexible content creation powered by
AI.

* **Bug Fixes**
* Improved error handling for missing prompt templates or providers
during document and code artifact generation.

* **Refactor**
* Simplified input schemas for document and code artifact tools,
consolidating multiple input fields into a single prompt.
* Output schemas updated to remove metadata and other unused fields for
a cleaner result.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Peng Xiao
2025-07-04 15:23:09 +08:00
committed by GitHub
parent 24f1181069
commit d0beab9638
4 changed files with 81 additions and 86 deletions
@@ -14,6 +14,7 @@ import { AccessController } from '../../../core/permission';
import { Models } from '../../../models';
import { IndexerService } from '../../indexer';
import { CopilotContextService } from '../context';
import { PromptService } from '../prompt';
import {
buildContentGetter,
buildDocContentGetter,
@@ -201,11 +202,23 @@ export abstract class CopilotProvider<C = any> {
break;
}
case 'docCompose': {
tools.doc_compose = createDocComposeTool();
const promptService = this.moduleRef.get(PromptService, {
strict: false,
});
tools.doc_compose = createDocComposeTool(
promptService,
this.factory
);
break;
}
case 'codeArtifact': {
tools.code_artifact = createCodeArtifactTool();
const promptService = this.moduleRef.get(PromptService, {
strict: false,
});
tools.code_artifact = createCodeArtifactTool(
promptService,
this.factory
);
break;
}
}