Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f7bdcc568 |
@@ -21,6 +21,7 @@ public class AIController : ControllerBase
|
||||
private readonly ICodeIntelligenceService _codeIntelligenceService;
|
||||
private readonly IIssueService _issueService;
|
||||
private readonly IDocumentationService _documentationService;
|
||||
private readonly IWorkflowService _workflowService;
|
||||
private readonly IAIProviderFactory _providerFactory;
|
||||
private readonly ILicenseValidator _licenseValidator;
|
||||
private readonly ILogger<AIController> _logger;
|
||||
@@ -30,6 +31,7 @@ public class AIController : ControllerBase
|
||||
ICodeIntelligenceService codeIntelligenceService,
|
||||
IIssueService issueService,
|
||||
IDocumentationService documentationService,
|
||||
IWorkflowService workflowService,
|
||||
IAIProviderFactory providerFactory,
|
||||
ILicenseValidator licenseValidator,
|
||||
ILogger<AIController> logger)
|
||||
@@ -38,6 +40,7 @@ public class AIController : ControllerBase
|
||||
_codeIntelligenceService = codeIntelligenceService;
|
||||
_issueService = issueService;
|
||||
_documentationService = documentationService;
|
||||
_workflowService = workflowService;
|
||||
_providerFactory = providerFactory;
|
||||
_licenseValidator = licenseValidator;
|
||||
_logger = logger;
|
||||
@@ -490,6 +493,41 @@ public class AIController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a generic AI task
|
||||
/// </summary>
|
||||
[HttpPost("execute-task")]
|
||||
public async Task<IActionResult> ExecuteTask([FromBody] ExecuteTaskDto request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var protoRequest = new Proto.ExecuteTaskRequest
|
||||
{
|
||||
RepoId = request.RepoId,
|
||||
Task = request.Task ?? ""
|
||||
};
|
||||
foreach (var kvp in request.Context ?? new Dictionary<string, string>())
|
||||
{
|
||||
protoRequest.Context[kvp.Key] = kvp.Value;
|
||||
}
|
||||
protoRequest.AllowedTools.AddRange(request.AllowedTools ?? []);
|
||||
|
||||
var response = await _workflowService.ExecuteTaskAsync(protoRequest, cancellationToken);
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success = response.Success,
|
||||
result = response.Result,
|
||||
error = response.Error
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to execute task");
|
||||
return StatusCode(500, new { error = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
private static object MapReviewResponse(Proto.ReviewPullRequestResponse response)
|
||||
{
|
||||
return new
|
||||
@@ -659,6 +697,18 @@ public class IssueCommentDto
|
||||
public string? CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public class ExecuteTaskDto
|
||||
{
|
||||
[System.Text.Json.Serialization.JsonPropertyName("provider_config")]
|
||||
public ProviderConfigDto? ProviderConfig { get; set; }
|
||||
[System.Text.Json.Serialization.JsonPropertyName("repo_id")]
|
||||
public long RepoId { get; set; }
|
||||
public string? Task { get; set; }
|
||||
public Dictionary<string, string>? Context { get; set; }
|
||||
[System.Text.Json.Serialization.JsonPropertyName("allowed_tools")]
|
||||
public List<string>? AllowedTools { get; set; }
|
||||
}
|
||||
|
||||
public class InspectWorkflowDto
|
||||
{
|
||||
[System.Text.Json.Serialization.JsonPropertyName("provider_config")]
|
||||
|
||||
Reference in New Issue
Block a user