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

Minor search UX improvements + Critical connector fixes #2259

Merged
merged 11 commits into from
Aug 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion backend/danswer/server/documents/cc_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def associate_credential_to_connector(
connector_id=connector_id,
credential_id=credential_id,
cc_pair_name=metadata.name,
is_public=metadata.is_public or True,
is_public=True if metadata.is_public is None else metadata.is_public,
groups=metadata.groups,
)

Expand Down
1 change: 1 addition & 0 deletions backend/danswer/server/documents/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def create_connector_from_model(
try:
_validate_connector_allowed(connector_data.source)
connector_base = _check_connector_permissions(connector_data, user)

return create_connector(
db_session=db_session,
connector_data=connector_base,
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/add-connector/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function Page() {
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
onKeyDown={handleKeyPress}
className="flex mt-2 max-w-sm h-9 w-full rounded-md border-2 border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
className="ml-1 w-96 h-9 flex-none rounded-md border border-border bg-background-50 px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
/>

{Object.entries(categorizedSources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
IsPublicGroupSelectorFormType,
} from "@/components/IsPublicGroupSelector";
import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled";
import { AdminBooleanFormField } from "@/components/credentials/CredentialFields";

export type AdvancedConfigFinal = {
pruneFreq: number | null;
Expand Down Expand Up @@ -489,6 +488,7 @@ export default function AddConnector({
}}
>
{(formikProps) => {
console.log(formikProps.values);
setFormValues(formikProps.values);
handleFormStatusChange(
formikProps.isValid && isFormSubmittable(formikProps.values)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SubLabel } from "@/components/admin/connectors/Field";
import { Field } from "formik";
import { Field, useFormikContext } from "formik";

export default function NumberInput({
label,
Expand All @@ -8,14 +8,18 @@ export default function NumberInput({
description,
name,
showNeverIfZero,
onChange,
}: {
value?: number;
label: string;
name: string;
optional?: boolean;
description?: string;
showNeverIfZero?: boolean;
onChange?: (value: number) => void;
}) {
const { setFieldValue } = useFormikContext();

return (
<div className="w-full flex flex-col">
<label className="block text-base font-medium text-text-700 mb-1">
Expand All @@ -29,6 +33,14 @@ export default function NumberInput({
name={name}
min="-1"
value={value === 0 && showNeverIfZero ? "Never" : value}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
const newValue =
e.target.value === "Never" ? 0 : Number(e.target.value);
setFieldValue(name, newValue);
if (onChange) {
onChange(newValue);
}
}}
className={`mt-2 block w-full px-3 py-2
bg-white border border-gray-300 rounded-md
text-sm shadow-sm placeholder-gray-400
Expand Down
14 changes: 9 additions & 5 deletions web/src/app/admin/embeddings/RerankingFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const RerankingDetailsForm = forwardRef<
.nullable()
.oneOf(Object.values(RerankerProvider))
.optional(),
api_key: Yup.string().nullable(),
rerank_api_key: Yup.string().nullable(),
num_rerank: Yup.number().min(1, "Must be at least 1"),
})}
onSubmit={async (_, { setSubmitting }) => {
Expand Down Expand Up @@ -132,6 +132,7 @@ const RerankingDetailsForm = forwardRef<
...values,
rerank_provider_type: card.rerank_provider_type!,
rerank_model_name: card.modelName,
rerank_api_key: null,
});
setFieldValue(
"rerank_provider_type",
Expand Down Expand Up @@ -192,15 +193,18 @@ const RerankingDetailsForm = forwardRef<
>
<div className="w-full px-4">
<TextFormField
placeholder={values.api_key || undefined}
placeholder={values.rerank_api_key || undefined}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value;
setRerankingDetails({ ...values, api_key: value });
setFieldValue("api_key", value);
setRerankingDetails({
...values,
rerank_api_key: value,
});
setFieldValue("rerank_api_key", value);
}}
type="password"
label="Cohere API Key"
name="api_key"
name="rerank_api_key"
/>
<div className="mt-4 flex justify-between">
<Button
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/embeddings/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NonNullChain } from "typescript";
export interface RerankingDetails {
rerank_model_name: string | null;
rerank_provider_type: RerankerProvider | null;
api_key: string | null;
rerank_api_key: string | null;
num_rerank: number;
}

Expand Down
12 changes: 11 additions & 1 deletion web/src/app/admin/embeddings/pages/AdvancedEmbeddingFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ interface AdvancedEmbeddingFormPageProps {
) => void;
advancedEmbeddingDetails: AdvancedSearchConfiguration;
numRerank: number;
updateNumRerank: (value: number) => void;
}

const AdvancedEmbeddingFormPage = forwardRef<
FormikProps<any>,
AdvancedEmbeddingFormPageProps
>(
(
{ updateAdvancedEmbeddingDetails, advancedEmbeddingDetails, numRerank },
{
updateAdvancedEmbeddingDetails,
advancedEmbeddingDetails,
numRerank,
updateNumRerank,
},
ref
) => {
return (
Expand Down Expand Up @@ -154,6 +160,10 @@ const AdvancedEmbeddingFormPage = forwardRef<
name="disableRerankForStreaming"
/>
<NumberInput
onChange={(value: number) => {
updateNumRerank(value);
setFieldValue("num_rerank", value);
}}
description="Number of results to rerank"
optional={false}
value={values.num_rerank}
Expand Down
14 changes: 10 additions & 4 deletions web/src/app/admin/embeddings/pages/EmbeddingFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function EmbeddingForm() {
});

const [rerankingDetails, setRerankingDetails] = useState<RerankingDetails>({
api_key: "",
rerank_api_key: "",
num_rerank: 0,
rerank_provider_type: null,
rerank_model_name: "",
Expand Down Expand Up @@ -118,7 +118,7 @@ export default function EmbeddingForm() {
searchSettings.disable_rerank_for_streaming,
});
setRerankingDetails({
api_key: searchSettings.api_key,
rerank_api_key: searchSettings.rerank_api_key,
num_rerank: searchSettings.num_rerank,
rerank_provider_type: searchSettings.rerank_provider_type,
rerank_model_name: searchSettings.rerank_model_name,
Expand All @@ -128,13 +128,13 @@ export default function EmbeddingForm() {

const originalRerankingDetails: RerankingDetails = searchSettings
? {
api_key: searchSettings.api_key,
rerank_api_key: searchSettings.rerank_api_key,
num_rerank: searchSettings.num_rerank,
rerank_provider_type: searchSettings.rerank_provider_type,
rerank_model_name: searchSettings.rerank_model_name,
}
: {
api_key: "",
rerank_api_key: "",
num_rerank: 0,
rerank_provider_type: null,
rerank_model_name: "",
Expand Down Expand Up @@ -415,6 +415,12 @@ export default function EmbeddingForm() {
<>
<Card>
<AdvancedEmbeddingFormPage
updateNumRerank={(value: number) =>
setRerankingDetails({
...rerankingDetails,
num_rerank: value,
})
}
numRerank={rerankingDetails.num_rerank}
advancedEmbeddingDetails={advancedEmbeddingDetails}
updateAdvancedEmbeddingDetails={updateAdvancedEmbeddingDetails}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export function CCPairIndexingStatusTable({
placeholder="Search connectors..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="ml-2 w-96 h-9 flex-none rounded-md border border-border bg-background-50 px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
className="ml-1 w-96 h-9 flex-none rounded-md border border-border bg-background-50 px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
/>

<Button className="h-9" onClick={() => toggleSources()}>
Expand Down
27 changes: 0 additions & 27 deletions web/src/app/chat/ChatBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"use client";

import ReactMarkdown from "react-markdown";
import { SettingsContext } from "@/components/settings/SettingsProvider";
import { useContext, useState, useRef, useLayoutEffect } from "react";
import remarkGfm from "remark-gfm";
import { Popover } from "@/components/popover/Popover";
import { ChevronDownIcon } from "@/components/icons/icons";
import { Divider } from "@tremor/react";
import { MinimalMarkdown } from "@/components/chat_search/MinimalMarkdown";

export function ChatBanner() {
Expand Down Expand Up @@ -34,27 +31,6 @@ export function ChatBanner() {
return null;
}

const renderMarkdown = (className: string) => (
<ReactMarkdown
className={`w-full text-wrap break-word ${className}`}
components={{
a: ({ node, ...props }) => (
<a
{...props}
className="text-sm text-link hover:text-link-hover"
target="_blank"
rel="noopener noreferrer"
/>
),
p: ({ node, ...props }) => (
<p {...props} className="text-wrap break-word text-sm m-0 w-full" />
),
}}
remarkPlugins={[remarkGfm]}
>
{settings.enterpriseSettings?.custom_header_content}
</ReactMarkdown>
);
return (
<div
className={`
Expand All @@ -65,7 +41,6 @@ export function ChatBanner() {
w-full
mx-auto
relative
bg-background-100
shadow-sm
rounded
border-l-8 border-l-400
Expand All @@ -81,7 +56,6 @@ export function ChatBanner() {
className="line-clamp-2 text-center w-full overflow-hidden pr-8"
>
<MinimalMarkdown
className=""
content={settings.enterpriseSettings.custom_header_content}
/>
</div>
Expand All @@ -90,7 +64,6 @@ export function ChatBanner() {
className="absolute top-0 left-0 invisible w-full"
>
<MinimalMarkdown
className=""
content={settings.enterpriseSettings.custom_header_content}
/>
</div>
Expand Down
Loading
Loading