Add start date to persona (#2407)

* add start date to persona

* remove logs

* rename

* update assistant editor

* update alembic

* update alembic

* update alembic

* udpate alembic

* remove rebase artifacts
This commit is contained in:
pablodanswer
2024-09-20 09:39:34 -07:00
committed by GitHub
parent 5f2644985c
commit 00229d2abe
9 changed files with 73 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
import { generateRandomIconShape, createSVG } from "@/lib/assistantIconUtils";
import { CCPairBasicInfo, DocumentSet, User, UserRole } from "@/lib/types";
import { CCPairBasicInfo, DocumentSet, User } from "@/lib/types";
import { Button, Divider, Italic } from "@tremor/react";
import { IsPublicGroupSelector } from "@/components/IsPublicGroupSelector";
import {
@@ -230,6 +230,9 @@ export function AssistantEditor({
existingPersona?.document_sets?.map((documentSet) => documentSet.id) ??
([] as number[]),
num_chunks: existingPersona?.num_chunks ?? null,
search_start_date: existingPersona?.search_start_date
? existingPersona?.search_start_date.toString().split("T")[0]
: null,
include_citations: existingPersona?.prompts[0]?.include_citations ?? true,
llm_relevance_filter: existingPersona?.llm_relevance_filter ?? false,
llm_model_provider_override:
@@ -284,6 +287,7 @@ export function AssistantEditor({
),
})
),
search_start_date: Yup.date().nullable(),
icon_color: Yup.string(),
icon_shape: Yup.number(),
uploaded_image: Yup.mixed().nullable(),
@@ -373,6 +377,9 @@ export function AssistantEditor({
id: existingPersona.id,
existingPromptId: existingPrompt?.id,
...values,
search_start_date: values.search_start_date
? new Date(values.search_start_date)
: null,
num_chunks: numChunks,
users:
user && !checkUserIsNoAuthUser(user.id) ? [user.id] : undefined,
@@ -385,6 +392,9 @@ export function AssistantEditor({
...values,
is_default_persona: admin!,
num_chunks: numChunks,
search_start_date: values.search_start_date
? new Date(values.search_start_date)
: null,
users:
user && !checkUserIsNoAuthUser(user.id) ? [user.id] : undefined,
groups,
@@ -912,7 +922,7 @@ export function AssistantEditor({
</Italic>
)}
<div className="mt-4 flex flex-col gap-y-4">
<div className="mt-4 flex flex-col gap-y-4">
<TextFormField
small={true}
name="num_chunks"
@@ -930,6 +940,17 @@ export function AssistantEditor({
}}
/>
<TextFormField
width="max-w-xl"
type="date"
small
subtext="Documents prior to this date will not be referenced by the search tool"
optional
label="Search Start Date"
value={values.search_start_date}
name="search_start_date"
/>
<BooleanFormField
small
removeIndent

View File

@@ -21,6 +21,7 @@ export interface Prompt {
export interface Persona {
id: number;
name: string;
search_start_date: Date | null;
owner: MinimalUserSnapshot | null;
is_visible: boolean;
is_public: boolean;

View File

@@ -21,6 +21,7 @@ interface PersonaCreationRequest {
icon_shape: number | null;
remove_image?: boolean;
uploaded_image: File | null;
search_start_date: Date | null;
is_default_persona: boolean;
}
@@ -46,6 +47,7 @@ interface PersonaUpdateRequest {
icon_shape: number | null;
remove_image: boolean;
uploaded_image: File | null;
search_start_date: Date | null;
}
function promptNameFromPersonaName(personaName: string) {
@@ -124,6 +126,7 @@ function buildPersonaAPIBody(
icon_color,
icon_shape,
remove_image,
search_start_date,
} = creationRequest;
const is_default_persona =
@@ -151,7 +154,7 @@ function buildPersonaAPIBody(
icon_shape,
uploaded_image_id,
remove_image,
is_default_persona,
search_start_date,
};
}

View File

@@ -139,6 +139,7 @@ export function TextFormField({
removeLabel,
min,
onChange,
width,
}: {
value?: string;
name: string;
@@ -163,6 +164,7 @@ export function TextFormField({
small?: boolean;
min?: number;
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
width?: string;
}) {
let heightString = defaultHeight || "";
if (isTextArea && !heightString) {
@@ -182,7 +184,7 @@ export function TextFormField({
};
return (
<div className="w-full">
<div className={`w-full ${width}`}>
<div className="flex gap-x-2 items-center">
{!removeLabel && (
<Label className="text-text-950" small={small}>