Skip to content

Commit

Permalink
feat(ai): add AI-based issue interpretation feature (#707)
Browse files Browse the repository at this point in the history
## What type of PR is this?

/kind feature

## What this PR does / why we need it:

This PR introduces a new AI-based issue interpretation feature to
enhance the diagnostic capabilities of the system.

Key changes include:
- Implementation of a new endpoint for AI-based issue interpretation.
- Addition of a new AI prompt type specifically for issue
interpretation.
- Updates to UI components to support the new AI interpretation feature.
- Addition of translations for the AI interpretation feature to ensure
localization support.
- Removal of a deprecated types file and refactoring of related code to
maintain code cleanliness.
- Updates to styling for the new AI interpretation panel to ensure a
consistent and user-friendly interface.

This feature allows users to gain AI-driven insights and interpretations
of scanner issues, improving the overall diagnostic experience.


![image](https://github.com/user-attachments/assets/256f5e67-032c-4834-82e8-8525344ec3e2)


![image](https://github.com/user-attachments/assets/8ac2787b-ae15-4a2f-b2da-bff5e3c3a4fd)

Demo:


![demo](https://github.com/user-attachments/assets/fd9ba3c0-e75c-46d2-82b2-b70a00a12d2c)

## Which issue(s) this PR fixes:

Fixes #632

---------

Co-authored-by: tianhai <wb-th358723@antgroup.com>
  • Loading branch information
elliotxx and hai-tian authored Jan 9, 2025
1 parent 61f5539 commit f78b99f
Show file tree
Hide file tree
Showing 24 changed files with 2,141 additions and 527 deletions.
159 changes: 127 additions & 32 deletions api/openapispec/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,70 @@ var doc = `{
}
}
},
"/insight/issue/interpret/stream": {
"post": {
"description": "This endpoint analyzes scanner issues using AI to provide detailed interpretation and insights",
"consumes": [
"application/json"
],
"produces": [
"text/event-stream"
],
"tags": [
"insight"
],
"summary": "Interpret scanner issues using AI",
"parameters": [
{
"description": "The audit data to interpret",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/scanner.InterpretRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/ai.InterpretEvent"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "string"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "string"
}
},
"429": {
"description": "Too Many Requests",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/insight/yaml/interpret/stream": {
"post": {
"description": "This endpoint analyzes YAML content using AI to provide detailed interpretation and insights",
Expand Down Expand Up @@ -413,6 +477,24 @@ var doc = `{
"type": "string"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "string"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "string"
}
},
"429": {
"description": "Too Many Requests",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
Expand Down Expand Up @@ -969,7 +1051,7 @@ var doc = `{
"200": {
"description": "Audit results",
"schema": {
"$ref": "#/definitions/scanner.AuditData"
"$ref": "#/definitions/ai.AuditData"
}
},
"400": {
Expand Down Expand Up @@ -2067,6 +2149,29 @@ var doc = `{
}
}
},
"ai.AuditData": {
"type": "object",
"properties": {
"bySeverity": {
"type": "object",
"additionalProperties": {
"type": "integer"
}
},
"issueGroups": {
"type": "array",
"items": {
"$ref": "#/definitions/ai.IssueGroup"
}
},
"issueTotal": {
"type": "integer"
},
"resourceTotal": {
"type": "integer"
}
}
},
"ai.DiagnosisEvent": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2116,6 +2221,20 @@ var doc = `{
}
}
},
"ai.IssueGroup": {
"type": "object",
"properties": {
"issue": {
"$ref": "#/definitions/scanner.Issue"
},
"resourceGroups": {
"type": "array",
"items": {
"$ref": "#/definitions/entity.ResourceGroup"
}
}
}
},
"cluster.ClusterPayload": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2296,26 +2415,16 @@ var doc = `{
}
}
},
"scanner.AuditData": {
"scanner.InterpretRequest": {
"type": "object",
"properties": {
"bySeverity": {
"type": "object",
"additionalProperties": {
"type": "integer"
}
},
"issueGroups": {
"type": "array",
"items": {
"$ref": "#/definitions/scanner.IssueGroup"
}
},
"issueTotal": {
"type": "integer"
"auditData": {
"description": "The audit data to interpret",
"$ref": "#/definitions/ai.AuditData"
},
"resourceTotal": {
"type": "integer"
"language": {
"description": "Language for interpretation",
"type": "string"
}
}
},
Expand All @@ -2340,20 +2449,6 @@ var doc = `{
}
}
},
"scanner.IssueGroup": {
"type": "object",
"properties": {
"issue": {
"$ref": "#/definitions/scanner.Issue"
},
"resourceGroups": {
"type": "array",
"items": {
"$ref": "#/definitions/entity.ResourceGroup"
}
}
}
},
"unstructured.Unstructured": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit f78b99f

Please sign in to comment.