Skip to content

Commit

Permalink
fix: f
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren committed Jan 5, 2025
1 parent 2624a5d commit fe72a26
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
17 changes: 12 additions & 5 deletions keep-ui/app/(keep)/incidents/[id]/chat/incident-chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ Any time you're not sure about something, ask the user for clarification.
If you used some provider's method to get data, present the icon of the provider you used.
If you think your response is relevant for the root cause analysis, add a "root_cause" tag to the message and call the "enrichRCA" method to enrich the incident.`;

export function IncidentChat({ incident }: { incident: IncidentDto }) {
export function IncidentChat({
incident,
mutateIncident,
}: {
incident: IncidentDto;
mutateIncident: () => void;
}) {
const router = useRouter();
const { data: session } = useSession();
const { data: alerts, isLoading: alertsLoading } = useIncidentAlerts(
Expand Down Expand Up @@ -167,20 +173,21 @@ export function IncidentChat({ incident }: { incident: IncidentDto }) {
"The bullet you think should be added to the list of root cause analysis points",
},
{
name: "rcaProvider",
name: "providerType",
type: "string",
description:
"The provider you used to get the root cause analysis point",
"The provider you decided to use to get the root cause analysis point, in lower case. (This is only needed when you used a invokeProviderMethod action to get the root cause analysis point. For example: 'datadog' or 'github')",
},
],
handler: async ({ rootCausePoint, rcaProvider }) => {
handler: async ({ rootCausePoint, providerType }) => {
const rcaPoints = incident.enrichments["rca_points"] || [];
await enrichIncident(incident.id, {
rca_points: [
...rcaPoints,
{ content: rootCausePoint, providerType: rcaProvider },
{ content: rootCausePoint, providerType: providerType },
],
});
mutateIncident();
},
});
useCopilotAction({
Expand Down
4 changes: 3 additions & 1 deletion keep-ui/app/(keep)/incidents/[id]/chat/page.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";

export function IncidentChatClientPage({
incident,
mutateIncident,
}: {
incident: IncidentDto;
mutateIncident: () => void;
}) {
const { data: config } = useConfig();

Expand All @@ -21,7 +23,7 @@ export function IncidentChatClientPage({

return (
<CopilotKit showDevConsole={false} runtimeUrl="/api/copilotkit">
<IncidentChat incident={incident} />
<IncidentChat incident={incident} mutateIncident={mutateIncident} />
</CopilotKit>
);
}
7 changes: 5 additions & 2 deletions keep-ui/app/(keep)/incidents/[id]/incident-layout-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function IncidentLayoutClient({
initialIncident: IncidentDto;
AIEnabled: boolean;
}) {
const { data: incident } = useIncident(initialIncident.id, {
const { data: incident, mutate } = useIncident(initialIncident.id, {
fallbackData: initialIncident,
});

Expand All @@ -48,7 +48,10 @@ export function IncidentLayoutClient({
<ResizeHandle />
<Panel defaultSize={40} minSize={25}>
<div className="pl-2">
<IncidentChatClientPage incident={incident} />
<IncidentChatClientPage
mutateIncident={mutate}
incident={incident}
/>
</div>
</Panel>
</>
Expand Down
6 changes: 3 additions & 3 deletions keep-ui/app/(keep)/incidents/[id]/incident-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ export function IncidentOverview({ incident: initialIncidentData }: Props) {
<DateTimeField date={incident.start_time} />
</div>
)}
{incident?.enrichments && "rca_points" in incident.enrichments && (
<RootCauseAnalysis points={incident.enrichments.rca_points} />
)}
<div>
<FieldHeader>Resolve on</FieldHeader>
<Badge
Expand All @@ -406,9 +409,6 @@ export function IncidentOverview({ incident: initialIncidentData }: Props) {
{incident.resolve_on}
</Badge>
</div>
{incident?.enrichments && "rca_points" in incident.enrichments && (
<RootCauseAnalysis points={incident.enrichments.rca_points} />
)}
{!!incident.rule_fingerprint && (
<div>
<FieldHeader>Group by value</FieldHeader>
Expand Down
4 changes: 2 additions & 2 deletions keep/api/models/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pydantic import BaseModel

from keep.providers.models.provider_config import ProviderScope
from keep.providers.models.provider_method import ProviderMethod
from keep.providers.models.provider_method import ProviderMethodDTO


class ProviderAlertsCountResponseDTO(BaseModel):
Expand Down Expand Up @@ -36,7 +36,7 @@ class Provider(BaseModel):
oauth2_url: str | None = None
scopes: list[ProviderScope] = []
validatedScopes: dict[str, bool | str] | None = {}
methods: list[ProviderMethod] = []
methods: list[ProviderMethodDTO] = []
installed_by: str | None = None
installation_time: datetime | None = None
pulling_enabled: bool = True
Expand Down
12 changes: 8 additions & 4 deletions keep/providers/github_provider/github_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@ def __init__(
super().__init__(context_manager, provider_id, config)
self.client = self.__generate_client()

def get_last_commits(self, repository: str, count: int = 10):
def get_last_commits(self, repository: str, n: int = 10):
self.logger.info(f"Getting last {n} commits from {repository}")
repo = self.client.get_repo(repository)
commits = repo.get_commits()
return [commit.raw_data for commit in commits[:count]]
self.logger.info(f"Found {commits.totalCount} commits")
return [commit.raw_data for commit in commits[:n]]

def get_last_releases(self, repository: str, count: int = 10):
def get_last_releases(self, repository: str, n: int = 10):
self.logger.info(f"Getting last {n} releases from {repository}")
repo = self.client.get_repo(repository)
releases = repo.get_releases()
return [release.raw_data for release in releases[:count]]
self.logger.info(f"Found {releases.totalCount} releases")
return [release.raw_data for release in releases[:n]]

def __generate_client(self):
# Should get an access token once we have a real use case for GitHub provider
Expand Down

0 comments on commit fe72a26

Please sign in to comment.