- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: add page for ai-bridge interception logs#20331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
cfc4aa9134495a6cd08191f9fddf0231d38bc717826e05475afab507828d381ba289ecb7280f55abbac5811d0c56a74e80ebf2e9137df869f2824704f09456baad81632ae2920d4bd155dc367903467608ef4207c0113b9ecdc47bec5f26f0a556a0126c72ae7d32a2a47a885cec12d3256f66f614651840aef12d3eb97523719e6125097e18edcdb0b4bb3412bdc9aec05db5930e9afac869e1e18640d7d6f8b3a47f2bbaeb7f2932e877734156359d09f5ab00b43f067a361e762a6c347aa147a4bf511b883f313a0cc9f5909e5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { API } from "api/api"; | ||
| import type { AIBridgeListInterceptionsResponse } from "api/typesGenerated"; | ||
| import { useFilterParamsKey } from "components/Filter/Filter"; | ||
| import type { UsePaginatedQueryOptions } from "hooks/usePaginatedQuery"; | ||
| export const paginatedInterceptions = ( | ||
| searchParams: URLSearchParams, | ||
| ): UsePaginatedQueryOptions<AIBridgeListInterceptionsResponse, string> => { | ||
| return { | ||
| queryPayload: () => searchParams.get(useFilterParamsKey) ?? "", | ||
| queryKey: ({ payload, pageNumber }) => { | ||
| return ["aiBridgeInterceptions", payload, pageNumber] as const; | ||
| }, | ||
| queryFn: ({ limit, offset, payload }) => | ||
| API.experimental.getAIBridgeInterceptions({ | ||
| offset, | ||
| limit, | ||
| q: payload, | ||
| }), | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,6 +25,8 @@ export const Navbar: FC = () => { | ||
| featureVisibility.audit_log && permissions.viewAnyAuditLog; | ||
| const canViewConnectionLog = | ||
| featureVisibility.connection_log && permissions.viewAnyConnectionLog; | ||
| const canViewAIGovernance = | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| featureVisibility.aibridge && permissions.viewAnyAIBridgeInterception; | ||
| const uniqueLinks = new Map<string, LinkConfig>(); | ||
| for (const link of appearance.support_links ?? []) { | ||
| @@ -44,6 +46,7 @@ export const Navbar: FC = () => { | ||
| canViewHealth={canViewHealth} | ||
| canViewAuditLog={canViewAuditLog} | ||
| canViewConnectionLog={canViewConnectionLog} | ||
| canViewAIGovernance={canViewAIGovernance} | ||
| proxyContextValue={proxyContextValue} | ||
| /> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import{ | ||
| HelpTooltip, | ||
| HelpTooltipContent, | ||
| HelpTooltipIconTrigger, | ||
| HelpTooltipLink, | ||
| HelpTooltipLinksGroup, | ||
| HelpTooltipText, | ||
| HelpTooltipTitle, | ||
| }from"components/HelpTooltip/HelpTooltip"; | ||
| importtype{FC}from"react"; | ||
| import{docs}from"utils/docs"; | ||
| exportconstAIGovernanceHelpTooltip:FC=()=>{ | ||
| return( | ||
| <HelpTooltip> | ||
| <HelpTooltipIconTrigger/> | ||
| <HelpTooltipContent> | ||
| <HelpTooltipTitle>What is AI Governance?</HelpTooltipTitle> | ||
| <HelpTooltipText> | ||
| AI Governance is a proxy that unifies and audits LLM usage across your | ||
| organization. | ||
| </HelpTooltipText> | ||
| <HelpTooltipLinksGroup> | ||
| <HelpTooltipLinkhref={docs("/docs/ai-coder/ai-bridge")}> | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| What we track | ||
| </HelpTooltipLink> | ||
| </HelpTooltipLinksGroup> | ||
| </HelpTooltipContent> | ||
| </HelpTooltip> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import{Margins}from"components/Margins/Margins"; | ||
| import{ | ||
| PageHeader, | ||
| PageHeaderSubtitle, | ||
| PageHeaderTitle, | ||
| }from"components/PageHeader/PageHeader"; | ||
| importtype{FC,PropsWithChildren}from"react"; | ||
| import{Outlet}from"react-router"; | ||
| import{AIGovernanceHelpTooltip}from"./AIGovernanceHelpTooltip"; | ||
| constAIGovernanceLayout:FC<PropsWithChildren>=({ | ||
| children=<Outlet/>, | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| })=>{ | ||
| return( | ||
| <MarginsclassName="pb-12"> | ||
| <PageHeader> | ||
| <PageHeaderTitle> | ||
| <divclassName="flex items-center gap-2"> | ||
| <span>AI Governance</span> | ||
| <AIGovernanceHelpTooltip/> | ||
| </div> | ||
| </PageHeaderTitle> | ||
| <PageHeaderSubtitle> | ||
| Manage usage for your organization. | ||
| </PageHeaderSubtitle> | ||
| </PageHeader> | ||
| {children} | ||
| </Margins> | ||
| ); | ||
| }; | ||
| exportdefaultAIGovernanceLayout; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { paginatedInterceptions } from "api/queries/aiBridge"; | ||
| import { useFilter } from "components/Filter/Filter"; | ||
| import { useUserFilterMenu } from "components/Filter/UserFilter"; | ||
| import { usePaginatedQuery } from "hooks/usePaginatedQuery"; | ||
| import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility"; | ||
| import type { FC } from "react"; | ||
| import { useSearchParams } from "react-router"; | ||
| import { pageTitle } from "utils/page"; | ||
| import { useProviderFilterMenu } from "./filter/filter"; | ||
| import { RequestLogsPageView } from "./RequestLogsPageView"; | ||
| const RequestLogsPage: FC = () => { | ||
| const feats = useFeatureVisibility(); | ||
| const isRequestLogsVisible = Boolean(feats.aibridge); | ||
| const [searchParams, setSearchParams] = useSearchParams(); | ||
| const interceptionsQuery = usePaginatedQuery( | ||
| paginatedInterceptions(searchParams), | ||
| ); | ||
| const filter = useFilter({ | ||
| searchParams, | ||
| onSearchParamsChange: setSearchParams, | ||
| onUpdate: interceptionsQuery.goToFirstPage, | ||
| }); | ||
| const userMenu = useUserFilterMenu({ | ||
| value: filter.values.initiator, | ||
| onChange: (option) => | ||
| filter.update({ | ||
| ...filter.values, | ||
| initiator: option?.value, | ||
| }), | ||
| }); | ||
| const providerMenu = useProviderFilterMenu({ | ||
| value: filter.values.provider, | ||
| onChange: (option) => | ||
| filter.update({ | ||
| ...filter.values, | ||
| provider: option?.value, | ||
| }), | ||
| }); | ||
| return ( | ||
| <> | ||
| <title>{pageTitle("Request Logs", "AI Governance")}</title> | ||
| <RequestLogsPageView | ||
| isLoading={interceptionsQuery.isLoading} | ||
| isRequestLogsVisible={isRequestLogsVisible} | ||
| interceptions={interceptionsQuery.data?.results} | ||
| interceptionsQuery={interceptionsQuery} | ||
| filterProps={{ | ||
| filter, | ||
| error: interceptionsQuery.error, | ||
| menus: { | ||
| user: userMenu, | ||
| provider: providerMenu, | ||
| }, | ||
| }} | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
| export default RequestLogsPage; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import{MockInterception}from"testHelpers/entities"; | ||
| importtype{Meta,StoryObj}from"@storybook/react-vite"; | ||
| import{ | ||
| getDefaultFilterProps, | ||
| MockMenu, | ||
| }from"components/Filter/storyHelpers"; | ||
| import{ | ||
| mockInitialRenderResult, | ||
| mockSuccessResult, | ||
| }from"components/PaginationWidget/PaginationContainer.mocks"; | ||
| importtype{UsePaginatedQueryResult}from"hooks/usePaginatedQuery"; | ||
| importtype{ComponentProps}from"react"; | ||
| import{RequestLogsPageView}from"./RequestLogsPageView"; | ||
| typeFilterProps=ComponentProps<typeofRequestLogsPageView>["filterProps"]; | ||
| constdefaultFilterProps=getDefaultFilterProps<FilterProps>({ | ||
| query:"owner:me", | ||
| values:{ | ||
| username:undefined, | ||
| provider:undefined, | ||
| }, | ||
| menus:{ | ||
| user:MockMenu, | ||
| provider:MockMenu, | ||
| }, | ||
| }); | ||
| constinterceptions=[MockInterception,MockInterception,MockInterception]; | ||
| constmeta:Meta<typeofRequestLogsPageView>={ | ||
| title:"pages/AIGovernancePage/RequestLogsPageView", | ||
| component:RequestLogsPageView, | ||
| args:{}, | ||
| }; | ||
| exportdefaultmeta; | ||
| typeStory=StoryObj<typeofRequestLogsPageView>; | ||
| exportconstPaywall:Story={ | ||
| args:{ | ||
| isRequestLogsVisible:false, | ||
| }, | ||
| }; | ||
| exportconstLoaded:Story={ | ||
| args:{ | ||
| isRequestLogsVisible:true, | ||
| interceptions, | ||
| filterProps:{ | ||
| ...defaultFilterProps, | ||
| }, | ||
| interceptionsQuery:{ | ||
| ...mockSuccessResult, | ||
| totalRecords:interceptions.length, | ||
| data:{ interceptions,total:interceptions.length}, | ||
| }asUsePaginatedQueryResult, | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| }, | ||
| }; | ||
| exportconstEmpty:Story={ | ||
| args:{ | ||
| isRequestLogsVisible:true, | ||
| interceptions:[], | ||
| filterProps:{ | ||
| ...defaultFilterProps, | ||
| }, | ||
| interceptionsQuery:{ | ||
| ...mockSuccessResult, | ||
| totalRecords:0, | ||
| data:{interceptions:[],total:0}, | ||
| }asUsePaginatedQueryResult, | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| }, | ||
| }; | ||
| exportconstLoading:Story={ | ||
| args:{ | ||
| isLoading:true, | ||
| isRequestLogsVisible:true, | ||
| interceptions:[], | ||
| filterProps:{ | ||
| ...defaultFilterProps, | ||
| }, | ||
| interceptionsQuery:{ | ||
| ...mockInitialRenderResult, | ||
| }asUsePaginatedQueryResult, | ||
jakehwll marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| }, | ||
| }; | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.