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

Member enrichment llm lfx 1712 #2688

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
create table "llmPromptHistory" (
id bigserial primary key,
type varchar(255) not null,
model text not null,
"entityId" text null,
metadata jsonb null,
prompt text not null,
answer text not null,
"inputTokenCount" int not null,
"outputTokenCount" int not null,
"responseTimeSeconds" decimal not null,
"createdAt" timestamptz not null default now()
);
Comment on lines +1 to +13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider additional constraints and optimizations

  1. The type column could be more efficient as an enum type
  2. The model column should have a CHECK constraint to validate allowed models
  3. The metadata column should have validation to ensure JSON structure
+create type llm_prompt_type as enum (
+    'organization_merge_suggestion',
+    'member_merge_suggestion'
+    -- add other types as needed
+);
+
 create table "llmPromptHistory" (
     id                    bigserial primary key,
-    type                  varchar(255) not null,
+    type                  llm_prompt_type not null,
     model                 text         not null,
+                         check (model in ('anthropic.claude-v2', 'anthropic.claude-v1')),
     "entityId"            text         null,
-    metadata              jsonb        null,
+    metadata              jsonb        null check (jsonb_typeof(metadata) = 'object'),
     prompt                text         not null,
     answer                text         not null,
     "inputTokenCount"     int          not null,
     "outputTokenCount"    int          not null,
     "responseTimeSeconds" decimal      not null,
     "createdAt"           timestamptz  not null default now()
 );

Committable suggestion skipped: line range outside the PR's diff.


create index "ix_llmPromptHistory_type_entityId" on "llmPromptHistory"("type", "entityId");
create index "ix_llmPromptHistory_entityId" on "llmPromptHistory"("entityId");
create index "ix_llmPromptHistory_type" on "llmPromptHistory"("type");
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table members
drop column "oldEmails";

alter table members
drop column "oldWeakIdentities";
Loading
Loading