Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
arielweinberger committed Dec 31, 2023
1 parent f55fb17 commit f35572e
Show file tree
Hide file tree
Showing 37 changed files with 209 additions and 188 deletions.
3 changes: 2 additions & 1 deletion .nxignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.github
.next
.next
volumes
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
libs/common/src/version.json
**/.next
/docs
volumes
2 changes: 1 addition & 1 deletion apps/console/src/components/metrics/StatisticBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface Props {
const getProperties = (
currentValue: number,
previousValue: number,
reverseColors: boolean,
reverseColors: boolean
) => {
const diff = currentValue - previousValue;
// Handle case where previousValue is 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import AnthropicLogo from "~/assets/providers/anthropic-logo.png";

export const providersList: ProviderProps[] = [
{
image: (
<img
alt="OpenAI"
src={OpenAILogo}
className="w-6 rounded-sm"
/>
),
image: <img alt="OpenAI" src={OpenAILogo} className="w-6 rounded-sm" />,
value: PromptService.OpenAiChatCompletion,
label: promptProvidersMapping[PromptService.OpenAiChatCompletion].name,
},
Expand All @@ -32,11 +26,7 @@ export const providersList: ProviderProps[] = [
},
{
image: (
<img
alt="Anthropic"
src={AnthropicLogo}
className=" w-6 rounded-sm"
/>
<img alt="Anthropic" src={AnthropicLogo} className=" w-6 rounded-sm" />
),
value: PromptService.AnthropicCompletion,
label: promptProvidersMapping[PromptService.AnthropicCompletion].name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ interface Props {
responseBody: OpenAI.ChatCompletion;
}

export const RequestResponseViewJsonView = ({ requestBody, responseBody }: Props) => {
export const RequestResponseViewJsonView = ({
requestBody,
responseBody,
}: Props) => {
return (
<div className="flex flex-col gap-4">
<div>
Expand Down
14 changes: 8 additions & 6 deletions apps/console/src/graphql/definitions/queries/metrics.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { graphql } from "~/@generated/graphql";

export const GET_GENERIC_PROJECT_METRIC_HISTOGRAM = graphql(/* GraphQL */ `
query getGenericProjectMetricHistogram($data: GetProjectGenericHistogramInput!) {
query getGenericProjectMetricHistogram(
$data: GetProjectGenericHistogramInput!
) {
genericProjectMetricHistogram(data: $data) {
data
}
}
`);

export const GET_PROJECT_METRIC_DELTA = graphql(/* GraphQL */ `
query getProjectMetricDelta($data: GetProjectMetricDeltaInput!) {
projectMetricDelta(data: $data) {
currentValue,
previousValue
query getProjectMetricDelta($data: GetProjectMetricDeltaInput!) {
projectMetricDelta(data: $data) {
currentValue
previousValue
}
}
}
`);
14 changes: 7 additions & 7 deletions apps/console/src/graphql/hooks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
GetProjectMetricDeltaQueryVariables,
GetProjectMetricDeltaQuery,
GetReportQuery,
GetReportQueryVariables
GetReportQueryVariables,
} from "~/@generated/graphql/graphql";
import { GraphQLErrorResponse } from "../types";
import { GET_PROMPT, GET_PROMPT_VERSION } from "../definitions/queries/prompts";
Expand Down Expand Up @@ -141,10 +141,7 @@ export const useGetRequestReports = (

export const useReport = (
data: GetReportQueryVariables["data"],
options: UseQueryOptions<
GetReportQuery,
GraphQLErrorResponse
> = {}
options: UseQueryOptions<GetReportQuery, GraphQLErrorResponse> = {}
) => {
const result = useQuery({
queryKey: ["report", data.reportId],
Expand All @@ -155,7 +152,7 @@ export const useReport = (
...options,
});

return { ...result, report: result.data?.report as SerializedReport};
return { ...result, report: result.data?.report as SerializedReport };
};

export const useGenericProjectMetricHistogram = <T>(
Expand All @@ -174,7 +171,10 @@ export const useGenericProjectMetricHistogram = <T>(
...options,
});

return { ...result, histogram: result.data?.genericProjectMetricHistogram as { data: T }};
return {
...result,
histogram: result.data?.genericProjectMetricHistogram as { data: T },
};
};

export const useProjctMetricDelta = (
Expand Down
6 changes: 2 additions & 4 deletions apps/console/src/graphql/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
Provider,
} from "@pezzo/types";
import { Provider } from "@pezzo/types";
import { GraphQLError } from "graphql-request/build/esm/types";

export interface GraphQLErrorResponse {
Expand All @@ -13,4 +11,4 @@ export interface GraphQLErrorResponse {

export type ReportRequestResponse<
TProviderType extends Provider | unknown = unknown
> = Record<string, any>;
> = Record<string, any>;
2 changes: 1 addition & 1 deletion apps/console/src/pages/projects/overview/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const DashboardPage = () => {
</div>
</div>
</div>
<div className="container p-6 space-y-6">
<div className="container space-y-6 p-6">
<StatisticsSection />
<div className="grid grid-cols-12 gap-6">
<Card className="col-span-6 p-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import { useProjectMetricControls } from "./ProjectMetricContext";
import { TooltipWithTimestamp } from "./TooltipWithTimestamp";
import { useCurrentProject } from "~/lib/hooks/useCurrentProject";
import { useGenericProjectMetricHistogram } from "~/graphql/hooks/queries";
import {
HistogramIdType,
} from "~/@generated/graphql/graphql";
import { HistogramIdType } from "~/@generated/graphql/graphql";
import { useFiltersAndSortParams } from "~/lib/hooks/useFiltersAndSortParams";
import { Loader2Icon } from "lucide-react";
import { MetricsTypes } from "@pezzo/common";
Expand All @@ -27,19 +25,20 @@ export const ExecutionTimeChart = () => {
const controls = useProjectMetricControls();
const { filters } = useFiltersAndSortParams();

const durationHistogram = useGenericProjectMetricHistogram<MetricsTypes.ExeceutionTypeChartResultDataType>(
{
projectId: project?.id,
histogramId: HistogramIdType.RequestDuration,
bucketSize: controls.bucketSize,
startDate: startDate,
endDate: endDate,
filters,
},
{
enabled: !!project && !!startDate && !!endDate,
}
);
const durationHistogram =
useGenericProjectMetricHistogram<MetricsTypes.ExeceutionTypeChartResultDataType>(
{
projectId: project?.id,
histogramId: HistogramIdType.RequestDuration,
bucketSize: controls.bucketSize,
startDate: startDate,
endDate: endDate,
filters,
},
{
enabled: !!project && !!startDate && !!endDate,
}
);

if (durationHistogram.isLoading) {
return (
Expand All @@ -58,8 +57,10 @@ export const ExecutionTimeChart = () => {
);
}


const data = durationHistogram.histogram.data.map((d) => ({ timestamp: d.timestamp, value: d.value }));
const data = durationHistogram.histogram.data.map((d) => ({
timestamp: d.timestamp,
value: d.value,
}));

return (
<ResponsiveContainer width="100%" height="100%">
Expand All @@ -85,7 +86,9 @@ export const ExecutionTimeChart = () => {
cursor={{ opacity: 0.2 }}
content={TooltipWithTimestamp}
formatter={(value, key) =>
key !== "value" ? value : `${((value as number) / 1000).toFixed(2)}s`
key !== "value"
? value
: `${((value as number) / 1000).toFixed(2)}s`
}
/>
<Legend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {
BarChart,
} from "recharts";
import colors from "tailwindcss/colors";
import {
HistogramIdType,
} from "~/@generated/graphql/graphql";
import { HistogramIdType } from "~/@generated/graphql/graphql";
import { useCurrentProject } from "~/lib/hooks/useCurrentProject";
import { useTimeframeSelector } from "~/lib/providers/TimeframeSelectorContext";
import { useProjectMetricControls } from "./ProjectMetricContext";
Expand All @@ -27,23 +25,22 @@ export const SuccessErrorRateChart = () => {
const { filters } = useFiltersAndSortParams();

const { project } = useCurrentProject();
const histogram = useGenericProjectMetricHistogram<MetricsTypes.SuccessErrorRateResultDataType>(
{
projectId: project?.id,
histogramId: HistogramIdType.SuccessErrorRate,
bucketSize: controls.bucketSize,
startDate: startDate,
endDate: endDate,
filters,
},
{
enabled: !!project && !!startDate && !!endDate,
}
);
const histogram =
useGenericProjectMetricHistogram<MetricsTypes.SuccessErrorRateResultDataType>(
{
projectId: project?.id,
histogramId: HistogramIdType.SuccessErrorRate,
bucketSize: controls.bucketSize,
startDate: startDate,
endDate: endDate,
filters,
},
{
enabled: !!project && !!startDate && !!endDate,
}
);

if (
histogram.isLoading
) {
if (histogram.isLoading) {
return (
<div
style={{
Expand Down Expand Up @@ -96,8 +93,18 @@ export const SuccessErrorRateChart = () => {
},
]}
/>
<Bar name="Error" dataKey="error" stackId="a" fill={colors.red["400"]} />
<Bar name="Success" dataKey="success" stackId="a" fill={colors.emerald["400"]} />
<Bar
name="Error"
dataKey="error"
stackId="a"
fill={colors.red["400"]}
/>
<Bar
name="Success"
dataKey="success"
stackId="a"
fill={colors.emerald["400"]}
/>
</BarChart>
</ResponsiveContainer>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/console/src/pages/prompts/PromptNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const PromptNavigation = () => {
icon: GitCommitIcon,
href: `${basePath}/versions`,
isActive: (href) => window.location.pathname === href,
}
},
];

return (
Expand Down
12 changes: 6 additions & 6 deletions apps/console/src/pages/requests/model-display-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ export const modelAuthorDetails = {
openai: {
image: OpenAILogo,
name: "OpenAI",
color: "#3B976B"
color: "#3B976B",
},
mistral: {
image: MistralLogo,
name: "Mistral",
color: "#cf651f"
color: "#cf651f",
},
meta: {
image: MetaLogo,
name: "Meta",
color: "#579BE0"
color: "#579BE0",
},
};

Expand All @@ -26,9 +26,9 @@ export const getModelDisplayDetails = (modelAuthor: string) => {
if (!authorDetails) {
return {
image: <span></span>,
name: "Unknown"
}
name: "Unknown",
};
}

return authorDetails;
}
};
3 changes: 2 additions & 1 deletion apps/server/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.env*
project.json
project.json
volumes
2 changes: 1 addition & 1 deletion apps/server/src/app/clickhouse/clickhouse.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ClickHouseService implements OnModuleInit {
user: username,
password,
database,
timezone: "Z"
timezone: "Z",
},
});

Expand Down
6 changes: 4 additions & 2 deletions apps/server/src/app/common/filters/filter.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ registerEnumType(FilterOperator, {
name: "FilterOperator",
});

export const getSQLOperatorByFilterOperator = (operator: FilterOperator): string => {
export const getSQLOperatorByFilterOperator = (
operator: FilterOperator
): string => {
switch (operator) {
case FilterOperator.eq:
return "=";
Expand All @@ -39,7 +41,7 @@ export const getSQLOperatorByFilterOperator = (operator: FilterOperator): string
default:
throw new Error(`Unknown filter operator: ${operator}`);
}
}
};

@InputType()
export class FilterInput {
Expand Down
Loading

0 comments on commit f35572e

Please sign in to comment.