Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

online eval backend #1

Open
wants to merge 1 commit into
base: frances/test_promptless
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 40 additions & 11 deletions helicone-cron/src/db/database.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,45 @@ export type Database = {
},
]
}
online_evaluators: {
Row: {
config: Json | null
created_at: string
evaluator: string
id: number
organization: string
}
Insert: {
config?: Json | null
created_at?: string
evaluator: string
id?: number
organization: string
}
Update: {
config?: Json | null
created_at?: string
evaluator?: string
id?: number
organization?: string
}
Relationships: [
{
foreignKeyName: "public_online_evaluators_evaluator_fkey"
columns: ["evaluator"]
isOneToOne: false
referencedRelation: "evaluator"
referencedColumns: ["id"]
},
{
foreignKeyName: "public_online_evaluators_organization_fkey"
columns: ["organization"]
isOneToOne: false
referencedRelation: "organization"
referencedColumns: ["id"]
},
]
}
org_rate_limit_tracker: {
Row: {
created_at: string | null
Expand Down Expand Up @@ -2963,7 +3002,6 @@ export type Database = {
owner_id: string | null
path_tokens: string[] | null
updated_at: string | null
user_metadata: Json | null
version: string | null
}
Insert: {
Expand All @@ -2977,7 +3015,6 @@ export type Database = {
owner_id?: string | null
path_tokens?: string[] | null
updated_at?: string | null
user_metadata?: Json | null
version?: string | null
}
Update: {
Expand All @@ -2991,7 +3028,6 @@ export type Database = {
owner_id?: string | null
path_tokens?: string[] | null
updated_at?: string | null
user_metadata?: Json | null
version?: string | null
}
Relationships: [
Expand All @@ -3013,7 +3049,6 @@ export type Database = {
key: string
owner_id: string | null
upload_signature: string
user_metadata: Json | null
version: string
}
Insert: {
Expand All @@ -3024,7 +3059,6 @@ export type Database = {
key: string
owner_id?: string | null
upload_signature: string
user_metadata?: Json | null
version: string
}
Update: {
Expand All @@ -3035,7 +3069,6 @@ export type Database = {
key?: string
owner_id?: string | null
upload_signature?: string
user_metadata?: Json | null
version?: string
}
Relationships: [
Expand Down Expand Up @@ -3132,7 +3165,7 @@ export type Database = {
Args: {
name: string
}
Returns: unknown
Returns: string[]
}
get_size_by_bucket: {
Args: Record<PropertyKey, never>
Expand Down Expand Up @@ -3172,10 +3205,6 @@ export type Database = {
updated_at: string
}[]
}
operation: {
Args: Record<PropertyKey, never>
Returns: string
}
search: {
Args: {
prefix: string
Expand Down
66 changes: 66 additions & 0 deletions supabase/migrations/20241212204905_online_evaluators.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
create table "public"."online_evaluators" (
"id" bigint generated by default as identity not null,
"created_at" timestamp with time zone not null default now(),
"evaluator" uuid not null,
"config" jsonb,
"organization" uuid not null
);


alter table "public"."online_evaluators" enable row level security;

CREATE UNIQUE INDEX online_evaluators_pkey ON public.online_evaluators USING btree (id);

alter table "public"."online_evaluators" add constraint "online_evaluators_pkey" PRIMARY KEY using index "online_evaluators_pkey";

alter table "public"."online_evaluators" add constraint "public_online_evaluators_evaluator_fkey" FOREIGN KEY (evaluator) REFERENCES evaluator(id) not valid;

alter table "public"."online_evaluators" validate constraint "public_online_evaluators_evaluator_fkey";

alter table "public"."online_evaluators" add constraint "public_online_evaluators_organization_fkey" FOREIGN KEY (organization) REFERENCES organization(id) not valid;

alter table "public"."online_evaluators" validate constraint "public_online_evaluators_organization_fkey";

grant delete on table "public"."online_evaluators" to "anon";

grant insert on table "public"."online_evaluators" to "anon";

grant references on table "public"."online_evaluators" to "anon";

grant select on table "public"."online_evaluators" to "anon";

grant trigger on table "public"."online_evaluators" to "anon";

grant truncate on table "public"."online_evaluators" to "anon";

grant update on table "public"."online_evaluators" to "anon";

grant delete on table "public"."online_evaluators" to "authenticated";

grant insert on table "public"."online_evaluators" to "authenticated";

grant references on table "public"."online_evaluators" to "authenticated";

grant select on table "public"."online_evaluators" to "authenticated";

grant trigger on table "public"."online_evaluators" to "authenticated";

grant truncate on table "public"."online_evaluators" to "authenticated";

grant update on table "public"."online_evaluators" to "authenticated";

grant delete on table "public"."online_evaluators" to "service_role";

grant insert on table "public"."online_evaluators" to "service_role";

grant references on table "public"."online_evaluators" to "service_role";

grant select on table "public"."online_evaluators" to "service_role";

grant trigger on table "public"."online_evaluators" to "service_role";

grant truncate on table "public"."online_evaluators" to "service_role";

grant update on table "public"."online_evaluators" to "service_role";


51 changes: 40 additions & 11 deletions valhalla/jawn/src/lib/db/database.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,45 @@ export type Database = {
},
]
}
online_evaluators: {
Row: {
config: Json | null
created_at: string
evaluator: string
id: number
organization: string
}
Insert: {
config?: Json | null
created_at?: string
evaluator: string
id?: number
organization: string
}
Update: {
config?: Json | null
created_at?: string
evaluator?: string
id?: number
organization?: string
}
Relationships: [
{
foreignKeyName: "public_online_evaluators_evaluator_fkey"
columns: ["evaluator"]
isOneToOne: false
referencedRelation: "evaluator"
referencedColumns: ["id"]
},
{
foreignKeyName: "public_online_evaluators_organization_fkey"
columns: ["organization"]
isOneToOne: false
referencedRelation: "organization"
referencedColumns: ["id"]
},
]
}
org_rate_limit_tracker: {
Row: {
created_at: string | null
Expand Down Expand Up @@ -2963,7 +3002,6 @@ export type Database = {
owner_id: string | null
path_tokens: string[] | null
updated_at: string | null
user_metadata: Json | null
version: string | null
}
Insert: {
Expand All @@ -2977,7 +3015,6 @@ export type Database = {
owner_id?: string | null
path_tokens?: string[] | null
updated_at?: string | null
user_metadata?: Json | null
version?: string | null
}
Update: {
Expand All @@ -2991,7 +3028,6 @@ export type Database = {
owner_id?: string | null
path_tokens?: string[] | null
updated_at?: string | null
user_metadata?: Json | null
version?: string | null
}
Relationships: [
Expand All @@ -3013,7 +3049,6 @@ export type Database = {
key: string
owner_id: string | null
upload_signature: string
user_metadata: Json | null
version: string
}
Insert: {
Expand All @@ -3024,7 +3059,6 @@ export type Database = {
key: string
owner_id?: string | null
upload_signature: string
user_metadata?: Json | null
version: string
}
Update: {
Expand All @@ -3035,7 +3069,6 @@ export type Database = {
key?: string
owner_id?: string | null
upload_signature?: string
user_metadata?: Json | null
version?: string
}
Relationships: [
Expand Down Expand Up @@ -3132,7 +3165,7 @@ export type Database = {
Args: {
name: string
}
Returns: unknown
Returns: string[]
}
get_size_by_bucket: {
Args: Record<PropertyKey, never>
Expand Down Expand Up @@ -3172,10 +3205,6 @@ export type Database = {
updated_at: string
}[]
}
operation: {
Args: Record<PropertyKey, never>
Returns: string
}
search: {
Args: {
prefix: string
Expand Down
1 change: 1 addition & 0 deletions valhalla/jawn/src/lib/handlers/HandlerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export type ProcessedLog = {
heliconeTemplate?: TemplateWithInputs;
assets?: Map<string, string>;
properties?: Record<string, string>;
scores?: Record<string, number | boolean | undefined>;
};
response: {
model?: string;
Expand Down
17 changes: 16 additions & 1 deletion valhalla/jawn/src/lib/handlers/LoggingHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export type BatchPayload = {
requestResponseVersionedCH: RequestResponseRMT[];
searchRecords: Database["public"]["Tables"]["request_response_search"]["Insert"][];
experimentCellValues: ExperimentCellValue[];
scores: {
organizationId: string;
requestId: string;
scores: Record<string, number | boolean | undefined>;
}[];
};

export class LoggingHandler extends AbstractLogHandler {
Expand All @@ -62,6 +67,7 @@ export class LoggingHandler extends AbstractLogHandler {
requestResponseVersionedCH: [],
searchRecords: [],
experimentCellValues: [],
scores: [],
};
}

Expand All @@ -87,6 +93,11 @@ export class LoggingHandler extends AbstractLogHandler {
this.batchPayload.responses.push(responseMapped);
this.batchPayload.assets.push(...assetsMapped);
this.batchPayload.searchRecords.push(...searchRecordsMapped);
this.batchPayload.scores.push({
organizationId: context.orgParams?.id ?? "",
requestId: requestMapped.id ?? "",
scores: context.processedLog.request.scores ?? {},
});

if (s3RecordMapped) {
this.batchPayload.s3Records.push(s3RecordMapped);
Expand Down Expand Up @@ -445,7 +456,11 @@ export class LoggingHandler extends AbstractLogHandler {
assets: context.processedLog.assets
? Array.from(context.processedLog.assets.keys())
: [],
scores: {},
scores: Object.fromEntries(
Object.entries(context.processedLog.request.scores ?? {}).map(
([key, value]) => [key, +(value ?? 0)]
)
),
request_body:
this.extractRequestBodyMessage(context.processedLog.request.body) ?? "",
response_body:
Expand Down
Loading