Hide search tool if no connectors exist

This commit is contained in:
Weves 2024-05-13 01:20:01 -07:00 committed by Chris Weaver
parent c2cdce4d49
commit e8b38d5f63

View File

@ -175,7 +175,9 @@ export function AssistantEditor({
starter_messages: existingPersona?.starter_messages ?? [],
// EE Only
groups: existingPersona?.groups ?? [],
search_tool_enabled: personaCurrentToolIds.includes(searchTool!.id),
search_tool_enabled: existingPersona
? personaCurrentToolIds.includes(searchTool!.id)
: ccPairs.length > 0,
image_generation_tool_enabled: imageGenerationTool
? personaCurrentToolIds.includes(imageGenerationTool.id)
: false,
@ -251,7 +253,7 @@ export function AssistantEditor({
formikHelpers.setSubmitting(true);
const tools = [];
if (values.search_tool_enabled) {
if (values.search_tool_enabled && ccPairs.length > 0) {
tools.push(searchTool!.id);
}
if (
@ -396,6 +398,8 @@ export function AssistantEditor({
<Divider />
<HidableSection sectionTitle="Tools">
<>
{ccPairs.length > 0 && (
<>
<BooleanFormField
name="search_tool_enabled"
@ -403,7 +407,10 @@ export function AssistantEditor({
subtext={`The Search Tool allows the Assistant to search through connected knowledge to help build an answer.`}
onChange={(e) => {
setFieldValue("num_chunks", null);
setFieldValue("search_tool_enabled", e.target.checked);
setFieldValue(
"search_tool_enabled",
e.target.checked
);
}}
/>
@ -428,10 +435,10 @@ export function AssistantEditor({
) : (
"Document Sets"
)}{" "}
that this Assistant should search through. If
none are specified, the Assistant will search
through all available documents in order to try
and respond to queries.
that this Assistant should search through.
If none are specified, the Assistant will
search through all available documents in
order to try and respond to queries.
</>
</SubLabel>
</div>
@ -457,7 +464,9 @@ export function AssistantEditor({
if (isSelected) {
arrayHelpers.remove(ind);
} else {
arrayHelpers.push(documentSet.id);
arrayHelpers.push(
documentSet.id
);
}
}}
/>
@ -472,9 +481,9 @@ export function AssistantEditor({
No Document Sets available.{" "}
{user?.role !== "admin" && (
<>
If this functionality would be useful, reach
out to the administrators of Danswer for
assistance.
If this functionality would be useful,
reach out to the administrators of Danswer
for assistance.
</>
)}
</Italic>
@ -487,15 +496,18 @@ export function AssistantEditor({
placeholder="If unspecified, will use 10 chunks."
subtext={
<div>
How many chunks should we feed into the LLM
when generating the final response? Each chunk
is ~400 words long.
How many chunks should we feed into the
LLM when generating the final response?
Each chunk is ~400 words long.
</div>
}
onChange={(e) => {
const value = e.target.value;
// Allow only integer values
if (value === "" || /^[0-9]+$/.test(value)) {
if (
value === "" ||
/^[0-9]+$/.test(value)
) {
setFieldValue("num_chunks", value);
}
}}
@ -525,6 +537,8 @@ export function AssistantEditor({
)}
</div>
)}
</>
)}
{imageGenerationTool &&
checkLLMSupportsImageGeneration(